From c3843b1cb2a1a9e5911ac0023811e0b1ff31a1b3 Mon Sep 17 00:00:00 2001 From: Derek Meegan Date: Mon, 20 Oct 2025 16:36:20 -0700 Subject: [PATCH 1/4] fix search tool --- stagehand/agent/google_cua.py | 2 +- stagehand/handlers/cua_handler.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stagehand/agent/google_cua.py b/stagehand/agent/google_cua.py index 4410061d..4c8f7132 100644 --- a/stagehand/agent/google_cua.py +++ b/stagehand/agent/google_cua.py @@ -349,7 +349,7 @@ def _process_provider_response( action_type_str = "function" action_payload_dict = { "type": "function", - "name": "goto", + "name": "search", "arguments": {"url": "https://www.google.com"}, } else: diff --git a/stagehand/handlers/cua_handler.py b/stagehand/handlers/cua_handler.py index 2708aa3d..3b4f869a 100644 --- a/stagehand/handlers/cua_handler.py +++ b/stagehand/handlers/cua_handler.py @@ -142,7 +142,7 @@ async def perform_action(self, action: AgentAction) -> ActionExecutionResult: # specific_action_model is FunctionAction name = specific_action_model.name args = getattr(specific_action_model, "arguments", {}) - if name == "goto" and args.url: + if name == "search" and args.url: await self.page.goto(args.url) return {"success": True} elif name == "navigate_back": From eaf1f9c71724a13c152ae59d0789603b1254306e Mon Sep 17 00:00:00 2001 From: Derek Meegan Date: Tue, 21 Oct 2025 14:30:28 -0700 Subject: [PATCH 2/4] change fix to use original function name from gemini --- stagehand/agent/google_cua.py | 41 ++++++++++--------------------- stagehand/handlers/cua_handler.py | 2 +- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/stagehand/agent/google_cua.py b/stagehand/agent/google_cua.py index 4c8f7132..6f534a46 100644 --- a/stagehand/agent/google_cua.py +++ b/stagehand/agent/google_cua.py @@ -349,7 +349,7 @@ def _process_provider_response( action_type_str = "function" action_payload_dict = { "type": "function", - "name": "search", + "name": "goto", "arguments": {"url": "https://www.google.com"}, } else: @@ -567,34 +567,19 @@ async def run_task( ) current_url = self.handler.page.url - function_name_called_for_feedback = "" - if agent_action.action_type == "function" and isinstance( - agent_action.action.root, FunctionAction - ): - function_name_called_for_feedback = ( - agent_action.action.root.name - ) - self._format_action_feedback( - function_name_called=function_name_called_for_feedback, - action_result=action_result, - new_screenshot_base64=current_screenshot_b64, - current_url=current_url, - function_call_args=function_call_args, + if not invoked_function_name: + self.logger.error( + "Original Google function name not found for feedback loop (was None).", + category="agent", ) - else: - if not invoked_function_name: - self.logger.error( - "Original Google function name not found for feedback loop (was None).", - category="agent", - ) - else: - self._format_action_feedback( - function_name_called=invoked_function_name, - action_result=action_result, - new_screenshot_base64=current_screenshot_b64, - current_url=current_url, - function_call_args=function_call_args, - ) + + self._format_action_feedback( + function_name_called=invoked_function_name, + action_result=action_result, + new_screenshot_base64=current_screenshot_b64, + current_url=current_url, + function_call_args=function_call_args, + ) if task_completed: self.logger.info( diff --git a/stagehand/handlers/cua_handler.py b/stagehand/handlers/cua_handler.py index 3b4f869a..2708aa3d 100644 --- a/stagehand/handlers/cua_handler.py +++ b/stagehand/handlers/cua_handler.py @@ -142,7 +142,7 @@ async def perform_action(self, action: AgentAction) -> ActionExecutionResult: # specific_action_model is FunctionAction name = specific_action_model.name args = getattr(specific_action_model, "arguments", {}) - if name == "search" and args.url: + if name == "goto" and args.url: await self.page.goto(args.url) return {"success": True} elif name == "navigate_back": From 2c8f8b3d5158d1174d4ff068b512ab3f5efa69e0 Mon Sep 17 00:00:00 2001 From: Derek Meegan Date: Tue, 21 Oct 2025 14:35:13 -0700 Subject: [PATCH 3/4] remove unused import --- stagehand/agent/google_cua.py | 1 - 1 file changed, 1 deletion(-) diff --git a/stagehand/agent/google_cua.py b/stagehand/agent/google_cua.py index 6f534a46..125fd0fc 100644 --- a/stagehand/agent/google_cua.py +++ b/stagehand/agent/google_cua.py @@ -23,7 +23,6 @@ AgentConfig, AgentExecuteOptions, AgentResult, - FunctionAction, ) from .client import AgentClient From 17dd5829d8f4352b388346fe588be5590b89f081 Mon Sep 17 00:00:00 2001 From: Derek Meegan Date: Tue, 21 Oct 2025 16:37:20 -0700 Subject: [PATCH 4/4] add changeset --- .changeset/dramatic-worm-of-pizza.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/dramatic-worm-of-pizza.md diff --git a/.changeset/dramatic-worm-of-pizza.md b/.changeset/dramatic-worm-of-pizza.md new file mode 100644 index 00000000..86f5f040 --- /dev/null +++ b/.changeset/dramatic-worm-of-pizza.md @@ -0,0 +1,5 @@ +--- +"stagehand": patch +--- + +Fix search, navigate, go back, and go forward for gemini cua agent