diff --git a/src/crewai/agents/crew_agent_executor.py b/src/crewai/agents/crew_agent_executor.py index b144872b1..ed89008fd 100644 --- a/src/crewai/agents/crew_agent_executor.py +++ b/src/crewai/agents/crew_agent_executor.py @@ -519,7 +519,11 @@ class CrewAgentExecutor(CrewAgentExecutorMixin): color="yellow", ) self._handle_crew_training_output(initial_answer, feedback) - self.messages.append(self._format_msg(f"Feedback: {feedback}")) + self.messages.append( + self._format_msg( + self._i18n.slice("feedback_instructions").format(feedback=feedback) + ) + ) improved_answer = self._invoke_loop() self._handle_crew_training_output(improved_answer) self.ask_for_human_input = False @@ -566,7 +570,11 @@ class CrewAgentExecutor(CrewAgentExecutorMixin): def _process_feedback_iteration(self, feedback: str) -> AgentFinish: """Process a single feedback iteration.""" - self.messages.append(self._format_msg(f"Feedback: {feedback}")) + self.messages.append( + self._format_msg( + self._i18n.slice("feedback_instructions").format(feedback=feedback) + ) + ) return self._invoke_loop() def _log_feedback_error(self, retry_count: int, error: Exception) -> None: diff --git a/src/crewai/translations/en.json b/src/crewai/translations/en.json index 6385d5862..0c45321ea 100644 --- a/src/crewai/translations/en.json +++ b/src/crewai/translations/en.json @@ -24,7 +24,8 @@ "manager_request": "Your best answer to your coworker asking you this, accounting for the context shared.", "formatted_task_instructions": "Ensure your final answer contains only the content in the following format: {output_format}\n\nEnsure the final output does not include any code block markers like ```json or ```python.", "human_feedback_classification": "Determine if the following feedback indicates that the user is satisfied or if further changes are needed. Respond with 'True' if further changes are needed, or 'False' if the user is satisfied. **Important** Do not include any additional commentary outside of your 'True' or 'False' response.\n\nFeedback: \"{feedback}\"", - "conversation_history_instruction": "You are a member of a crew collaborating to achieve a common goal. Your task is a specific action that contributes to this larger objective. For additional context, please review the conversation history between you and the user that led to the initiation of this crew. Use any relevant information or feedback from the conversation to inform your task execution and ensure your response aligns with both the immediate task and the crew's overall goals." + "conversation_history_instruction": "You are a member of a crew collaborating to achieve a common goal. Your task is a specific action that contributes to this larger objective. For additional context, please review the conversation history between you and the user that led to the initiation of this crew. Use any relevant information or feedback from the conversation to inform your task execution and ensure your response aligns with both the immediate task and the crew's overall goals.", + "feedback_instructions": "User feedback: {feedback}\nInstructions: Use this feedback to enhance the next output iteration.\nNote: Do not respond or add commentary." }, "errors": { "force_final_answer_error": "You can't keep going, here is the best final answer you generated:\n\n {formatted_answer}", diff --git a/src/crewai/utilities/training_handler.py b/src/crewai/utilities/training_handler.py index b6b3c38b6..2d34f3261 100644 --- a/src/crewai/utilities/training_handler.py +++ b/src/crewai/utilities/training_handler.py @@ -35,6 +35,4 @@ class CrewTrainingHandler(PickleHandler): def clear(self) -> None: """Clear the training data by removing the file or resetting its contents.""" if os.path.exists(self.file_path): - with open(self.file_path, "wb") as file: - # Overwrite with an empty dictionary - self.save({}) + self.save({})