Class: ActionAgent::AgentRegistrar
- Inherits:
-
Object
- Object
- ActionAgent::AgentRegistrar
- Defined in:
- app/services/action_agent/agent_registrar.rb
Overview
Registers an Agent for each distinct agent action we observe in telemetry.
Agents authored in the dashboard have records; agents running inside a customer's own app only ever reported traces, so the Agents list read 0 while Traces and Interactions were full of their runs. Ingest calls this to give every observed agent an identity that evaluations, versions, and per-agent metrics can hang off.
Identity is (account, service_name, agent_class, agent_action) — one agent per action, not per class. Clara.respond (admin assistant, every MCP tool, ~$0.03/run) and Clara.title (no tools, temperature 0.2, ~$0.0004/run) are different agents that share a class name because one app method spawns both. Collapsing them would blend a $0.03 agent with a $0.0004 one into a single meaningless cost-per-run.
Never raises: a registration failure must not fail a customer's telemetry.
Constant Summary collapse
- MAX_OBSERVED_PER_OWNER =
Guards against a misconfigured reporter with a dynamic agent class creating unbounded records.
200
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(trace) ⇒ AgentRegistrar
constructor
A new instance of AgentRegistrar.
Constructor Details
#initialize(trace) ⇒ AgentRegistrar
Returns a new instance of AgentRegistrar.
32 33 34 |
# File 'app/services/action_agent/agent_registrar.rb', line 32 def initialize(trace) @trace = trace end |
Class Method Details
.call(trace) ⇒ Object
25 26 27 28 29 30 |
# File 'app/services/action_agent/agent_registrar.rb', line 25 def self.call(trace) new(trace).call rescue StandardError => e Rails.logger.warn("[AgentRegistrar] #{e.class}: #{e.}") nil end |
Instance Method Details
#call ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/action_agent/agent_registrar.rb', line 36 def call return if @trace.agent_id.present? return if agent_class.blank? owner = owner_for_trace return if owner.nil? && ActionAgent.multi_tenant? agent = find_or_create_agent(owner) return if agent.nil? @trace.update_columns(agent_id: agent.id) touch_observation(agent) agent end |