From 0c41d0bf51e65c0908050616e0ad51dc89ea168d Mon Sep 17 00:00:00 2001 From: Cocoon-Break <54054995+kuishou68@users.noreply.github.com> Date: Fri, 17 Apr 2026 15:09:40 +0800 Subject: [PATCH] fix: guard against KeyError in update_prompt_message_tool loop (#35150) Co-authored-by: Crazywoola <100913391+crazywoola@users.noreply.github.com> --- api/core/agent/fc_agent_runner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/core/agent/fc_agent_runner.py b/api/core/agent/fc_agent_runner.py index d38d24d1e7..29de0b8b1c 100644 --- a/api/core/agent/fc_agent_runner.py +++ b/api/core/agent/fc_agent_runner.py @@ -299,7 +299,9 @@ class FunctionCallAgentRunner(BaseAgentRunner): # update prompt tool for prompt_tool in prompt_messages_tools: - self.update_prompt_message_tool(tool_instances[prompt_tool.name], prompt_tool) + tool_instance = tool_instances.get(prompt_tool.name) + if tool_instance: + self.update_prompt_message_tool(tool_instance, prompt_tool) iteration_step += 1