record_session
Store an agent run's token usage, latency, and tool trace, and receive a new session ID to query it later.
Instructions
Append ONE agent execution's metrics to this server's store; returns the new session_id.
This is how a remote agent gets its own runs into the server, rather than only being able to query what the server owner recorded locally. Attributed to the connected identity: your Google account if you signed in via /auth/login, or owner=None for the owner token. NOT idempotent -- each call mints a new session_id. Never updates or deletes an existing session; the get_* tools read what this writes.
prompt: the user prompt that started the run. model_id: the provider model identifier, e.g. "anthropic.claude-3-5-sonnet-20241022-v2:0". loop_result: the run's token / latency / trace payload. Required keys: input_tokens (int), output_tokens (int), total_tokens (int), latency_ms (float), turns (list). Optional: trace (list), context_blocks (list -- omit if you don't have per-block context data; get_context_timeline needs it).
each
turnsitem: input_tokens (int), output_tokens (int), latency_ms (float); optional cache_read_input_tokens / cache_write_input_tokens (int, default 0).each
traceitem: tool (str), args (dict), status (str); optional latency_ms (float, default 0), timestamp (float epoch seconds, default record time).each
context_blocksitem: category (str), label (str), char_count (int), token_estimate (int); optional turn_n (int or null -- null for a pre-conversation block), status (str), content (str).
Example loop_result:
{
"input_tokens": 1200, "output_tokens": 340, "total_tokens": 1540,
"latency_ms": 4210.0,
"turns": [
{"input_tokens": 1200, "output_tokens": 340, "latency_ms": 4210.0,
"cache_read_input_tokens": 800, "cache_write_input_tokens": 0}
],
"trace": [
{"tool": "grep_logs", "args": {"pattern": "ERROR"}, "status": "ok",
"latency_ms": 120.0, "timestamp": 1756400000.0}
]
}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | ||
| model_id | Yes | ||
| loop_result | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |