withTool and events appearing in the dashboard. This mental model helps you debug queue issues, tune flush intervals, and reason about guardrail timing.
The lifecycle
From your agent’s perspective, the SDK follows a simple pattern: register → enqueue → batch → flushRegistration
When you construct the client withenabled: true (the default):
- An HTTP client is created with your
baseUrlandapiKey(Bearer auth). - A background event queue starts flushing on an interval.
- Agent registration begins immediately (
POST /v1/agents/identify). - If
capabilitiesare configured, they are declared after registration succeeds.
ready() to await registration. Most track* and withTool methods call this internally.
After registration you can read:
apie.agentId— registered agent IDapie.agentVersionId— registered version ID
Event queue
Telemetry is not sent synchronously on every tool call. Events are enqueued and flushed:- Periodically every
flushIntervalMs(default 2000ms) - On demand via
flush() - Before run completion — completing a run flushes first
- On shutdown —
shutdown()stops the timer and flushes remaining events
maxBatchSize (default 25) per POST /v1/events.
Guard evaluation
When Enforce mode is active,withTool and withGuard call POST /v1/guardrails/evaluate before your callback runs:
| Policy decision | Monitor mode effective behavior | Enforce mode effective behavior |
|---|---|---|
allow | Proceed | Proceed |
warn | Proceed, log warning | Proceed, log warning |
block | Proceed, log “would block” | Throw — callback never runs |
require_approval | Proceed, log “would require approval” | Wait for dashboard approval |
Disabled mode
Setenabled: false to get a no-op client with synthetic IDs. Useful for local development without sending telemetry:
What you’ll see in the dashboard
- Agents — registered identity and version metadata
- Sessions — grouped runs with replay timeline
- Events — tool calls, actions, guardrail evaluations, approvals
- Runtime intelligence — generated session summaries, story timelines, action items, and guardrail recommendations
- Guardrails — matched policies and decisions
Next steps
Reliable telemetry
Tune queue, persistence, and shutdown.
Runtime intelligence
Understand the generated session story built from telemetry.
Diagnose your setup
Use doctor and queue diagnostics.
