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 telemetry agent_type

Sarina Li42a437c5c213
diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.py
index fbcab3e1aa..47e0bae3e4 100644
--- a/libs/python/agent/agent/agent.py
+++ b/libs/python/agent/agent/agent.py
@@ -237,13 +237,6 @@ class ComputerAgent:
if self.instructions:
self.callbacks.append(PromptInstructionsCallback(self.instructions))
- # Add telemetry callback if telemetry_enabled is set
- if self.telemetry_enabled:
- if isinstance(self.telemetry_enabled, bool):
- self.callbacks.append(TelemetryCallback(self))
- else:
- self.callbacks.append(TelemetryCallback(self, **self.telemetry_enabled))
-
# Add logging callback if verbosity is set
if self.verbosity is not None:
self.callbacks.append(LoggingCallback(level=self.verbosity))
@@ -297,6 +290,13 @@ class ComputerAgent:
self.agent_loop = config_info.agent_class()
self.agent_config_info = config_info
+ # Add telemetry callback AFTER agent_loop is set so it can capture the correct agent_type
+ if self.telemetry_enabled:
+ if isinstance(self.telemetry_enabled, bool):
+ self.callbacks.append(TelemetryCallback(self))
+ else:
+ self.callbacks.append(TelemetryCallback(self, **self.telemetry_enabled))
+
self.tool_schemas = []
self.computer_handler = None
diff --git a/libs/python/agent/agent/callbacks/telemetry.py b/libs/python/agent/agent/callbacks/telemetry.py
index d8e77e1d93..dc86ca746b 100644
--- a/libs/python/agent/agent/callbacks/telemetry.py
+++ b/libs/python/agent/agent/callbacks/telemetry.py
@@ -60,11 +60,14 @@ class TelemetryCallback(AsyncCallbackHandler):
def _record_agent_initialization(self) -> None:
"""Record agent type/model and session initialization."""
+ # Get the agent loop type (class name)
+ agent_type = "unknown"
+ if hasattr(self.agent, "agent_loop") and self.agent.agent_loop is not None:
+ agent_type = type(self.agent.agent_loop).__name__
+
agent_info = {
"session_id": self.session_id,
- "agent_type": (
- self.agent.agent_loop.__name__ if hasattr(self.agent, "agent_loop") else "unknown"
- ),
+ "agent_type": agent_type,
"model": getattr(self.agent, "model", "unknown"),
**SYSTEM_INFO,
}