Skip to main content

AgentRun

An AgentRun is one execution of an Agent against one Email. AgentRuns are append-only: written by the worker, read-only via the API.

Purpose​

  • Provide a per-execution audit trail (model, tokens, cost, duration).
  • Allow debugging of failures without re-running.
  • Aggregate cost back to the workspace's monthly counters.

Schema​

FieldTypeDescription
idUUIDInternal id.
workspace_idUUIDOwning workspace.
inbox_idUUIDInbox that produced the email.
agent_idUUIDAgent that ran.
email_idUUIDTarget email.
llm_modelstringResolved model id at run time (frozen — Agent.llm_model may have changed since).
statusenumrunning, success, failed.
errorstring | nullStack trace / message when status=failed.
input_tokensintPrompt tokens (system + user).
output_tokensintCompletion tokens.
cache_readintTokens served from prompt cache.
cache_writeintTokens written to prompt cache.
cost_per_tokendecimalBlended USD/token at execution time.
total_costdecimalcost_per_token * (input + output), after cache discounts.
duration_msint | nullWall time of the LLM call.
started_atdatetime | nullSet when the run leaves the queue.
finished_atdatetime | nullSet on terminal state.
created_at / updated_at / deleted_atdatetime

Example​

{
"id": "d5e6f7a8-9b0c-4d1e-2f3a-4b5c6d7e8f9a",
"workspace_id": "a8b2c1d4-9e7f-4a3b-8c5d-1f2e3a4b5c6d",
"inbox_id": "b3c4d5e6-7a89-4b0c-9d1e-2f3a4b5c6d7e",
"agent_id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
"email_id": "e5f6a7b8-9c0d-4e1f-2a3b-4c5d6e7f8a9b",
"llm_model": "anthropic/claude-sonnet-4-6",
"status": "success",
"error": null,
"input_tokens": 1842,
"output_tokens": 312,
"cache_read": 1200,
"cache_write": 642,
"cost_per_token": "0.00000400",
"total_cost": "0.00328400",
"duration_ms": 4127,
"started_at": "2026-05-17T10:00:14.700Z",
"finished_at": "2026-05-17T10:00:18.827Z",
"created_at": "2026-05-17T10:00:14.500Z",
"updated_at": "2026-05-17T10:00:18.827Z",
"deleted_at": null
}

Reading​

MethodPath
GET/agent-runs?agent_id=…&email_id=…
GET/agent-runs/{id}

Filters: agent_id, inbox_id, email_id, status, created_at[gte|lt].

No write endpoints​

AgentRuns are created by the worker. To re-execute an agent against an email use POST /v1/emails/{id}/reprocess; a new AgentRun row will be produced.