From 4315f33e88429f785b4c9d43f82d219b86d6a6e3 Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Tue, 22 Jul 2025 10:34:10 -0400 Subject: [PATCH] fix: cast dict values to str in _format_prompt - Add str() casts for type safety - These values are always strings when called from invoke --- src/crewai/agents/crew_agent_executor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/crewai/agents/crew_agent_executor.py b/src/crewai/agents/crew_agent_executor.py index 44b54aafa..d8fbbd9c2 100644 --- a/src/crewai/agents/crew_agent_executor.py +++ b/src/crewai/agents/crew_agent_executor.py @@ -371,10 +371,13 @@ class CrewAgentExecutor(CrewAgentExecutorMixin): training_data[agent_id] = agent_training_data training_handler.save(training_data) - def _format_prompt(self, prompt: str, inputs: Dict[str, str]) -> str: - prompt = prompt.replace("{input}", inputs["input"]) - prompt = prompt.replace("{tool_names}", inputs["tool_names"]) - prompt = prompt.replace("{tools}", inputs["tools"]) + def _format_prompt( + self, prompt: str, inputs: Dict[str, Union[str, bool, None]] + ) -> str: + # Cast to str to satisfy type checker - these are always strings when called + prompt = prompt.replace("{input}", str(inputs["input"])) + prompt = prompt.replace("{tool_names}", str(inputs["tool_names"])) + prompt = prompt.replace("{tools}", str(inputs["tools"])) return prompt def _handle_human_feedback(self, formatted_answer: AgentFinish) -> AgentFinish: