Skip to content

Commit eaf1f9c

Browse files
committed
change fix to use original function name from gemini
1 parent c3843b1 commit eaf1f9c

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

stagehand/agent/google_cua.py

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _process_provider_response(
349349
action_type_str = "function"
350350
action_payload_dict = {
351351
"type": "function",
352-
"name": "search",
352+
"name": "goto",
353353
"arguments": {"url": "https://www.google.com"},
354354
}
355355
else:
@@ -567,34 +567,19 @@ async def run_task(
567567
)
568568
current_url = self.handler.page.url
569569

570-
function_name_called_for_feedback = ""
571-
if agent_action.action_type == "function" and isinstance(
572-
agent_action.action.root, FunctionAction
573-
):
574-
function_name_called_for_feedback = (
575-
agent_action.action.root.name
576-
)
577-
self._format_action_feedback(
578-
function_name_called=function_name_called_for_feedback,
579-
action_result=action_result,
580-
new_screenshot_base64=current_screenshot_b64,
581-
current_url=current_url,
582-
function_call_args=function_call_args,
570+
if not invoked_function_name:
571+
self.logger.error(
572+
"Original Google function name not found for feedback loop (was None).",
573+
category="agent",
583574
)
584-
else:
585-
if not invoked_function_name:
586-
self.logger.error(
587-
"Original Google function name not found for feedback loop (was None).",
588-
category="agent",
589-
)
590-
else:
591-
self._format_action_feedback(
592-
function_name_called=invoked_function_name,
593-
action_result=action_result,
594-
new_screenshot_base64=current_screenshot_b64,
595-
current_url=current_url,
596-
function_call_args=function_call_args,
597-
)
575+
576+
self._format_action_feedback(
577+
function_name_called=invoked_function_name,
578+
action_result=action_result,
579+
new_screenshot_base64=current_screenshot_b64,
580+
current_url=current_url,
581+
function_call_args=function_call_args,
582+
)
598583

599584
if task_completed:
600585
self.logger.info(

stagehand/handlers/cua_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async def perform_action(self, action: AgentAction) -> ActionExecutionResult:
142142
# specific_action_model is FunctionAction
143143
name = specific_action_model.name
144144
args = getattr(specific_action_model, "arguments", {})
145-
if name == "search" and args.url:
145+
if name == "goto" and args.url:
146146
await self.page.goto(args.url)
147147
return {"success": True}
148148
elif name == "navigate_back":

0 commit comments

Comments
 (0)