Observability

Every agent run’s ledger, OpenTelemetry traces and metrics, and the Prometheus endpoint.

Every agent run keeps a ledger: each step it took, in order, with a line a person reads. The same steps go to OpenTelemetry as one trace per run, and counters go to /metrics and OTLP.

The run ledger

GET /agents/v1/runs/{id}/ledger (service key, the run's agent, or the run itself):

JSON
{
  "run": "run_7f3c...",
  "entries": [
    {"id": "led_...", "run_id": "run_7f3c...", "seq": 1, "at": 1764633600000, "kind": "run.created", "status": "ok",
     "duration_ms": null, "actor": "agent:claims_bot", "summary": "Run started by claims_bot: close claim 2", "detail": {...}},
    {"kind": "sql", "status": "ok", "duration_ms": 3, "actor": "run:run_7f3c...",
     "summary": "UPDATE in its world, 1 rows", "detail": {"sql": "update claims set ...", "params": 4, "rows": 1, "tool": "run_sql"}},
    {"kind": "run.proposed", "actor": "run:run_7f3c...", "summary": "Proposed its changes to main, under policy large_claims", "detail": {"policy": "large_claims"}},
    {"kind": "run.held", "actor": "policy", "summary": "Held for a person: it changes claims, a table under review"},
    {"kind": "run.merged", "actor": "link:ops@example.com", "summary": "Merged 1 rows, approved by link:ops@example.com"}
  ],
  "next": null
}
KindRecorded when
run.created, run.held, run.merged, run.rejected, run.conflict, run.discarded, run.expired, run.undonethe event of the same name happens
run.proposedthe run asks to merge (before the policy decides)
run.propose_failed, run.approve_refuseda proposal or an approval fails
sqla statement runs through POST /runs/{id}/sql, the SDK's sql() or MCP's run_sql (failures too)
toolan MCP tool reads the run (run_changes, get_run)
job.attemptan attempt of an agent function's job ends
job.succeeded, effect.<channel>the event of the same name happens for the run
  • status is ok or error. A failed statement keeps its error in detail.error.
  • actor says who caused the step: service, agent:<name>, run:<id>, policy, link:<email>, job:<function>.
  • detail.via is mcp for steps taken through the MCP server.
  • SQL text is kept up to observe.sql_text_bytes (4000) bytes; longer text is cut, with detail.truncated set and the full length in detail.sql_bytes. 0 keeps only the length. Parameter values are never kept, only their count.
  • ?limit= (1 to 5000, default 1000) and ?after=<entry id> page through it; next is the last id of a full page.
  • ?format=jsonl answers JSON lines (application/x-ndjson), one entry per line, for jq or a log pipeline.
  • The dashboard's run sheet shows the same ledger as a timeline, with each statement's SQL a click away.

What the ledger can't see: statements an agent runs straight through its run's database_url with a Postgres driver. Those reach the engine without passing Forkbase. Their effect is still in the run's changes (GET /runs/{id}/changes), its proposal and its merge, which are in the ledger.

Entries are written in batches a quarter of a second apart, so a burst of steps costs one transaction. Reading the ledger writes what's waiting first. If the database can't keep up, entries beyond 10,000 waiting are dropped and counted (forkbase_ledger_dropped_total); the run itself is never slowed or failed by its ledger.

Entries older than observe.retention_days (30) are deleted once a day; 0 keeps them.

OpenTelemetry

Set an OTLP/HTTP endpoint and Forkbase sends traces and metrics there, JSON over HTTP, to any OpenTelemetry collector, Grafana, Honeycomb, Datadog, Langfuse, Arize Phoenix or similar:

shell
FORKBASE_OTLP_ENDPOINT=http://127.0.0.1:4318 forkbase start
# or the standard variables
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=... forkbase start
  • One trace per run. Its id is made from the run's id, so every step of the run, recorded by any server or job, lands in the same trace.
  • The run's own span, invoke_agent <agent>, spans the run from start to end. It is sent when the run ends (merged, rejected, discarded or expired), with gen_ai.operation.name = invoke_agent, gen_ai.agent.name, gen_ai.agent.id, gen_ai.conversation.id (the run id), forkbase.run.intent and forkbase.run.outcome.
  • Each statement and tool call is a child span, execute_tool run_sql (or the tool's name), with gen_ai.tool.name, db.system.name, db.query.text, forkbase.rows and its duration; a failure has an error status. Every other ledger entry is a child span named by its kind.
  • Names and attributes follow the OpenTelemetry GenAI semantic conventions, so tools that understand agent traces show runs as agents, and their SQL as tool calls.
  • Export never blocks a request: spans go out with each ledger batch, metrics every observe.metrics_every_s (60). An endpoint that refuses or is down is logged, and nothing is retried.

Metrics

GET /metrics (Prometheus text) has, beside the server's own gauges:

MetricTypeLabels
forkbase_ledger_entries_totalcounterkind, status
forkbase_ledger_dropped_totalcounter
forkbase_runs_totalcounteroutcome: created, held, merged, rejected, conflict, discarded, expired, undone
forkbase_agent_tool_duration_secondshistogramtool

With an endpoint set, the same go out over OTLP as forkbase.ledger.entries, forkbase.ledger.dropped, forkbase.runs and forkbase.agent.tool.duration. Counters start at zero when the server starts.

Configuration

[observe] in forkbase.toml; see Configuration.

TOML
[observe]
retention_days = 30
sql_text_bytes = 4000
otlp_endpoint = "http://otel-collector:4318"
service_name = "forkbase"
metrics_every_s = 60

Something wrong or missing? Edit this page on GitHub or open an issue.

Observability · Forkbase