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.

moved trajectory dir fix

Dillon DuPontdb1d8a4c5dbc
diff --git a/libs/python/agent/agent/integrations/hud/__init__.py b/libs/python/agent/agent/integrations/hud/__init__.py
index 81f829255c..787613deb4 100644
--- a/libs/python/agent/agent/integrations/hud/__init__.py
+++ b/libs/python/agent/agent/integrations/hud/__init__.py
@@ -7,7 +7,6 @@ from hud import run_job as hud_run_job
from .agent import ComputerAgent
from .adapter import ComputerAgentAdapter
from .computer_handler import HUDComputerHandler
-from agent.callbacks.trajectory_saver import TrajectorySaverCallback
async def run_job(
@@ -49,15 +48,6 @@ async def run_job(
Returns:
Job instance from HUD
"""
- # Handle trajectory_dir by adding TrajectorySaverCallback
- trajectory_dir = agent_kwargs.pop("trajectory_dir", None)
- callbacks = agent_kwargs.get("callbacks", [])
-
- if trajectory_dir:
- trajectory_callback = TrajectorySaverCallback(trajectory_dir, reset_on_run=False)
- callbacks = callbacks + [trajectory_callback]
- agent_kwargs["callbacks"] = callbacks
-
# combine verbose and verbosity kwargs
if "verbose" in agent_kwargs:
agent_kwargs["verbosity"] = logging.INFO
diff --git a/libs/python/agent/agent/integrations/hud/agent.py b/libs/python/agent/agent/integrations/hud/agent.py
index 580954175a..cb810b3655 100644
--- a/libs/python/agent/agent/integrations/hud/agent.py
+++ b/libs/python/agent/agent/integrations/hud/agent.py
@@ -86,6 +86,16 @@ class ComputerAgent(Agent[BaseComputerAgent, dict[str, Any]]):
dimensions=(self.width, self.height)
)
+ # Handle trajectory_dir by adding TrajectorySaverCallback
+ trajectory_dir = kwargs.pop("trajectory_dir", None)
+ callbacks = kwargs.get("callbacks", [])
+
+ if trajectory_dir:
+ from agent.callbacks.trajectory_saver import TrajectorySaverCallback
+ trajectory_callback = TrajectorySaverCallback(trajectory_dir, reset_on_run=False)
+ callbacks = callbacks + [trajectory_callback]
+ kwargs["callbacks"] = callbacks
+
# Initialize ComputerAgent with HUD computer handler
self.computer_agent = BaseComputerAgent(
model=model,
@@ -212,7 +222,7 @@ class ComputerAgent(Agent[BaseComputerAgent, dict[str, Any]]):
# ComputerAgent.run returns an async generator
async for result in self.computer_agent.run(self.conversation_history, stream=False):
# if the result has computer_call_output, immediately exit
- if result.get("output", [])[-1].get("type") == "computer_call_output":
+ if result.get("output", []) and result.get("output", [])[-1].get("type") == "computer_call_output":
break
# otherwise add agent output to conversation history
self.conversation_history += result["output"]