Poll status, get full audit trails, and register webhooks
Every agent run produces a complete audit trail — the final output, every tool call, token usage, and execution logs. Two ways to get notified when a run completes: polling and webhooks.
Returns everything: the output, every step the agent took, token usage, and execution logs.
Copy
Ask AI
const details = await client.agents.runs.getDetails(run.id)console.log(details.result.output) // Final text outputconsole.log(details.steps.length) // Number of steps taken
Response
Copy
Ask AI
{ "id": "run_abc123", "agentId": "agent_xyz", "status": "completed", "prompt": "Research employment law...", "result": { "output": "## Research Report\n\nBased on my analysis of the vault documents...", "logs": { "opencode": "opencode server listening on http://0.0.0.0:4096...", "runner": "[runner] Sending prompt to OpenCode..." } }, "usage": { "model": "anthropic/claude-sonnet-4.6", "inputTokens": 45000, "outputTokens": 3200, "toolCalls": 12, "durationMs": 317000 }, "steps": [ { "id": "step_001", "type": "tool_call", "toolName": "bash", "toolInput": { "command": "casedev vault list" }, "toolOutput": "{ \"vaults\": [...] }", "durationMs": 1200, "timestamp": "2025-01-15T10:30:10Z" }, { "id": "step_002", "type": "output", "content": "I found 3 vaults. Let me search the most relevant one...", "timestamp": "2025-01-15T10:30:12Z" } ], "createdAt": "2025-01-15T10:30:00Z", "startedAt": "2025-01-15T10:30:05Z", "completedAt": "2025-01-15T10:35:22Z"}