Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix output of gpt 4o

Sarina Li1cb405c9f84d
diff --git a/libs/python/agent/agent/loops/omniparser.py b/libs/python/agent/agent/loops/omniparser.py
index 14ef3a92b2..bb232abbfc 100644
--- a/libs/python/agent/agent/loops/omniparser.py
+++ b/libs/python/agent/agent/loops/omniparser.py
@@ -243,18 +243,20 @@ async def replace_computer_call_with_function(
"id": item.get("id"),
"call_id": item.get("call_id"),
"status": "completed",
- # Fall back to string representation
- "content": f"Used tool: {action_data.get("type")}({json.dumps(fn_args)})",
}
]
elif item_type == "computer_call_output":
- # Simple conversion: computer_call_output -> function_call_output
+ output = item.get("output")
+
+ if isinstance(output, dict):
+ output = [output]
+
return [
{
"type": "function_call_output",
"call_id": item.get("call_id"),
- "content": [item.get("output")],
+ "output": output,
"id": item.get("id"),
"status": "completed",
}
@@ -338,7 +340,26 @@ class OmniparserConfig(AsyncAgentConfig):
if _on_api_start:
await _on_api_start(api_kwargs)
- print(str(api_kwargs)[:1000])
+ # Debug: Check for duplicate IDs
+ import json as json_module
+ all_ids = []
+ all_call_ids = []
+ for msg in messages:
+ if msg.get("id"):
+ all_ids.append(msg.get("id"))
+ if msg.get("call_id"):
+ all_call_ids.append(msg.get("call_id"))
+
+ duplicate_ids = [x for x in all_ids if all_ids.count(x) > 1]
+ duplicate_call_ids = [x for x in all_call_ids if all_call_ids.count(x) > 1]
+
+ if duplicate_ids:
+ print(f"WARNING: Duplicate IDs found: {set(duplicate_ids)}")
+ if duplicate_call_ids:
+ print(f"WARNING: Duplicate call_ids found: {set(duplicate_call_ids)}")
+
+ print("=== Messages being sent ===")
+ print(json_module.dumps(messages, indent=2)[:2000])
# Use liteLLM responses
response = await litellm.aresponses(**api_kwargs)