From 58836d84fe0efdda354269cb239f7ba479a6993c Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Mon, 13 Oct 2025 09:34:44 +0800 Subject: [PATCH] Fix: Mcp reset error, #10497 (#10498) ### What problem does this PR solve? Fix #10497 ### Type of change - [X] Bug Fix (non-breaking change which fixes an issue) --- agent/component/agent_with_tools.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py index aa1ac296d..32458fc85 100644 --- a/agent/component/agent_with_tools.py +++ b/agent/component/agent_with_tools.py @@ -347,6 +347,10 @@ Respond immediately with your final comprehensive answer. return "Error occurred." def reset(self, temp=False): + """ + Reset all tools if they have a reset method. This avoids errors for tools like MCPToolCallSession. + """ for k, cpn in self.tools.items(): - cpn.reset() + if hasattr(cpn, "reset") and callable(cpn.reset): + cpn.reset()