@@ -148,10 +148,8 @@ async def run_task(
148
148
tools = self .tools ,
149
149
betas = ["computer-use-2025-01-24" ],
150
150
)
151
- self .logger .info (f"Anthropic response: { response } " )
152
151
end_time = asyncio .get_event_loop ().time ()
153
152
total_inference_time_ms += int ((end_time - start_time ) * 1000 )
154
- self .logger .info (f"Total inference time: { total_inference_time_ms } " )
155
153
if response .usage :
156
154
total_input_tokens += response .usage .input_tokens or 0
157
155
total_output_tokens += response .usage .output_tokens or 0
@@ -316,23 +314,24 @@ def _process_provider_response(
316
314
def _convert_tool_use_to_agent_action (
317
315
self , tool_name : str , tool_input : dict [str , Any ]
318
316
) -> Optional [AgentAction ]:
319
- if tool_name != "computer" :
317
+ if tool_name != "computer" and tool_name != "goto" :
320
318
self .logger .warning (
321
319
f"Unsupported tool name from Anthropic: { tool_name } " ,
322
320
category = StagehandFunctionName .AGENT ,
323
321
)
324
322
return None
325
323
326
- action_type_str = tool_input .get ("action" )
324
+ if tool_name == "goto" :
325
+ action_type_str = "function"
326
+ else :
327
+ action_type_str = tool_input .get ("action" )
327
328
if not action_type_str :
328
329
self .logger .error (
329
330
"Missing 'action' in Anthropic computer tool_input" ,
330
331
category = StagehandFunctionName .AGENT ,
331
332
)
332
333
return None
333
334
334
- self .logger .info (f"Action type: { action_type_str } " )
335
-
336
335
action_model_payload : Optional [AgentActionType ] = None
337
336
reasoning = tool_input .get ("reasoning" )
338
337
@@ -527,21 +526,22 @@ def _convert_tool_use_to_agent_action(
527
526
)
528
527
action_type_str = "screenshot" # Normalize
529
528
530
- elif action_type_str == "goto" :
531
- url = tool_input .get ("url" )
532
- if url :
533
- action_model_payload = AgentActionType (
534
- type = "function" ,
535
- name = "goto" ,
536
- arguments = FunctionArguments (url = url ),
537
- )
538
- action_type_str = "function"
539
- else :
540
- self .logger .warning (
541
- "Goto action from Anthropic missing URL" ,
542
- category = StagehandFunctionName .AGENT ,
543
- )
544
- return None
529
+ elif action_type_str == "function" :
530
+ if tool_name == "goto" :
531
+ url = tool_input .get ("url" )
532
+ if url :
533
+ action_model_payload = AgentActionType (
534
+ type = "function" ,
535
+ name = "goto" ,
536
+ arguments = FunctionArguments (url = url ),
537
+ )
538
+ action_type_str = "function"
539
+ else :
540
+ self .logger .warning (
541
+ "Goto action from Anthropic missing URL" ,
542
+ category = StagehandFunctionName .AGENT ,
543
+ )
544
+ return None
545
545
else :
546
546
self .logger .warning (
547
547
f"Unsupported action type '{ action_type_str } ' from Anthropic computer tool." ,
0 commit comments