From a8625ee5d9e62e2ca0b0dd51b2141cf2a7c8ee9c Mon Sep 17 00:00:00 2001 From: Jeffrey95 Date: Thu, 27 Mar 2025 23:54:54 +0800 Subject: [PATCH 1/2] fix: infinite loop in simple question until max_step is reached --- app/agent/browser.py | 16 ++++++++-------- app/agent/toolcall.py | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/agent/browser.py b/app/agent/browser.py index ae0ce2f..ec1b573 100644 --- a/app/agent/browser.py +++ b/app/agent/browser.py @@ -111,14 +111,14 @@ class BrowserAgent(ToolCallAgent): ) self.memory.add_message(image_message) - # Replace placeholders with actual browser state info - self.next_step_prompt = NEXT_STEP_PROMPT.format( - url_placeholder=url_info, - tabs_placeholder=tabs_info, - content_above_placeholder=content_above_info, - content_below_placeholder=content_below_info, - results_placeholder=results_info, - ) + # Replace placeholders with actual browser state info + self.next_step_prompt = NEXT_STEP_PROMPT.format( + url_placeholder=url_info, + tabs_placeholder=tabs_info, + content_above_placeholder=content_above_info, + content_below_placeholder=content_below_info, + results_placeholder=results_info, + ) # Call parent implementation result = await super().think() diff --git a/app/agent/toolcall.py b/app/agent/toolcall.py index 76f6f01..66b74c0 100644 --- a/app/agent/toolcall.py +++ b/app/agent/toolcall.py @@ -115,6 +115,7 @@ class ToolCallAgent(ReActAgent): # For 'auto' mode, continue with content if no commands but content exists if self.tool_choices == ToolChoice.AUTO and not self.tool_calls: + self.state = AgentState.FINISHED return bool(content) return bool(self.tool_calls) From 34c610857f2d194dff98f02a972274f64ed1e39d Mon Sep 17 00:00:00 2001 From: mannaandpoem <52203545+mannaandpoem@users.noreply.github.com> Date: Sat, 29 Mar 2025 16:02:28 +0800 Subject: [PATCH 2/2] Update toolcall.py remove `self.state = AgentState.FINISHED` --- app/agent/toolcall.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/agent/toolcall.py b/app/agent/toolcall.py index 66b74c0..76f6f01 100644 --- a/app/agent/toolcall.py +++ b/app/agent/toolcall.py @@ -115,7 +115,6 @@ class ToolCallAgent(ReActAgent): # For 'auto' mode, continue with content if no commands but content exists if self.tool_choices == ToolChoice.AUTO and not self.tool_calls: - self.state = AgentState.FINISHED return bool(content) return bool(self.tool_calls)