mirror of
https://github.com/trycua/computer.git
synced 2026-01-05 12:59:58 -06:00
fix telemetry agent_type
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user