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.

Added error output

Dillon DuPontdb652a5998ec
diff --git a/libs/python/computer-server/computer_server/main.py b/libs/python/computer-server/computer_server/main.py
index 78a8fbcc07..1cfd30d816 100644
--- a/libs/python/computer-server/computer_server/main.py
+++ b/libs/python/computer-server/computer_server/main.py
@@ -632,6 +632,8 @@ async def agent_response_endpoint(
# return out
# messages = inline_image_urls(messages)
+ error = None
+
with _EnvOverride(env_overrides):
# Prepare tools: if caller did not pass tools, inject our DirectComputer
tools = agent_kwargs.get("tools")
@@ -645,26 +647,32 @@ async def agent_response_endpoint(
total_usage: Dict[str, Any] = {}
turns = 0
- async for result in agent.run(messages):
- total_output += result["output"]
- # Try to collect usage if present
- if isinstance(result, dict) and "usage" in result and isinstance(result["usage"], dict):
- # Merge usage counters
- for k, v in result["usage"].items():
- if isinstance(v, (int, float)):
- total_usage[k] = total_usage.get(k, 0) + v
- else:
- total_usage[k] = v
- turns += 1
- if turns > 2:
- break
-
+ try:
+ async for result in agent.run(messages):
+ total_output += result["output"]
+ # Try to collect usage if present
+ if isinstance(result, dict) and "usage" in result and isinstance(result["usage"], dict):
+ # Merge usage counters
+ for k, v in result["usage"].items():
+ if isinstance(v, (int, float)):
+ total_usage[k] = total_usage.get(k, 0) + v
+ else:
+ total_usage[k] = v
+ turns += 1
+ if turns > 2:
+ break
+ except Exception as e:
+ logger.error(f"Error running agent: {str(e)}")
+ logger.error(traceback.format_exc())
+ error = str(e)
+
# Build response payload
payload = {
- "success": True,
"model": model,
+ "error": error,
"output": total_output,
"usage": total_usage,
+ "status": "completed" if not error else "failed"
}
# CORS: allow any origin
diff --git a/libs/typescript/agent/src/types.ts b/libs/typescript/agent/src/types.ts
index 85ea7d968a..30e7340adb 100644
--- a/libs/typescript/agent/src/types.ts
+++ b/libs/typescript/agent/src/types.ts
@@ -29,12 +29,13 @@ export interface AgentRequest {
// #endregion
-
// #region Response
// Response types
export interface AgentResponse {
output: AgentMessage[];
usage: Usage;
+ status: 'completed' | 'failed';
+ error?: string;
}
// Usage information
export interface Usage {