Skip to main content

Overview

Call track_agent_response after the LLM returns its completion. This event captures the output text, token counts, and optional cost, and links back to the originating track_agent_call event via the shared messageId / message_id.

Required fields

Node.js / Python SDK: distinctId / distinct_id is also required. Browser SDK: optional if the user has already called Trodo.identify() in the session.
Field (Node / Browser)Field (Python)TypeDescription
agentIdagent_idstringThe registered agent ID — e.g. 'agt_abc12345'
conversationIdconversation_idstringStable ID for the conversation thread
messageIdmessage_idstringUnique ID for this specific message turn
distinctIddistinct_idstringLinks the event to a Trodo user (required in Node/Python; optional in Browser if identify() was called)

Optional fields

Field (Node / Browser)Field (Python)TypeDescription
outputoutputstringThe LLM’s text output (optional — may be large)
modelmodelstringLLM identifier — e.g. 'gpt-4o', 'claude-3-5-sonnet'
inputTokensinput_tokensnumberPrompt / input token count
outputTokensoutput_tokensnumberCompletion / output token count
costcostnumberTotal cost in USD for this response
timestamptimestampISO 8601 stringOverride event time

Examples

Trodo.track_agent_response({
  agentId: 'agt_abc12345',
  conversationId: 'conv_9kx2m7pq',
  messageId: 'msg_01jf3t8r',
  output: 'Your last invoice (inv_4421) for $149.00 was paid on March 12.',
  model: 'gpt-4o',
  inputTokens: 312,
  outputTokens: 28,
  cost: 0.00137,
});