Skip to main content

Run Ledger page

The Run Ledger page puts everything one run did on a single timeline. You give it a workflow run id, an agent run or request id, a trace id or a session id, and it lists the requests, MCP and tool calls, guardrail decisions, audit rows, workflow events and step attempts, eval scores, shadow verdicts, online scores and Lens spans that belong to it, with totals. Open it at /ui/run-ledger, or with an id already filled in at /ui/run-ledger?id=<id>. Other pages link here that way, including the Agents page, the run drawer and dead letters on the Workflow Runs page, trigger fire history and approval requests. It sits in the left nav in the AI Gateway group under Agentic, after Workflow Runs. The nav shows it to proxy admins, proxy admin viewers, org admins, internal users and internal viewers. When an admin limits the pages internal users can see (the enabled_ui_pages_internal_users UI setting), internal users only see it if it is on that list. The page has no role guard of its own. The gateway decides what each caller may read. Proxy admins and proxy admin viewers see every row, and everyone else only sees their own rows and their teams' rows. A caller that is not a proxy admin and has no user id gets "Not allowed to view run ledgers".

The page needs no license to open. A ledger that includes agent calls needs the Agent governance license feature, and step attempts and replay lineage need Workflow history, replay and pinned data.

Scenario​

Finance asks why one workflow run cost eleven dollars when its budget was two. The owner pastes the run id into the Run Ledger page and sees the answer in the Totals strip and the entries table. One step retried four times against a rate limited agent, and each attempt was a full model call. The owner exports the ledger as JSON and attaches it to the ticket.

Steps​

  1. Open Run Ledger under Agentic in the left nav, or go to /ui/run-ledger. Other pages link here with the id filled in, for example the run drawer on Workflow Runs and the Runs table of a custom agent.

  2. Paste the workflow run id, request id, trace id or session id into the run id field and click Look up, or press Enter. The page calls the same route as this command.

    curl http://localhost:4000/run_ledger/run_01J... -H "Authorization: Bearer $SPANWAY_API_KEY"
  3. Read the Totals strip for requests, tool calls, guardrail decisions, spend and tokens, then scroll the entries table in time order. Click a run id in Replay lineage to jump to the original run or a replay.

  4. Click Export JSON to download run-ledger-<id>.json, the same data as GET /run_ledger/<id>/export.

Expected result​

The first line names what the id turned out to be, Workflow run in this case, with the workflow type and status. The totals and entries match the API response.

{"id": "run_01J...", "kind": "workflow_run", "session_ids": ["ses_01J..."],
"workflow_run": {"run_id": "run_01J...", "session_id": "ses_01J...", "workflow_type": "release-notes", "status": "completed", "created_at": "2026-10-01T12:00:00Z", "updated_at": "2026-10-01T12:01:33Z"},
"lens": "not_found", "truncated": false,
"totals": {"requests": 12, "mcp_calls": 3, "tool_calls": 5, "guardrail_decisions": 12, "guardrail_interventions": 1, "spend": 0.0841, "total_tokens": 48210, "models": ["claude-sonnet-5-5"], "duration_ms": 93400},
"entries": [{"kind": "workflow_event", "at": "2026-10-01T12:00:00Z", "event_type": "step.started", "step_name": "collect-commits", "sequence_number": 0}, {"kind": "request", "at": "2026-10-01T12:00:01Z", "request_id": "chatcmpl-...", "model": "claude-sonnet-5-5", "total_tokens": 4120, "spend": 0.0071}]}

The downloaded file holds the same JSON.

Lookup​

The page opens with a short explanation of what it collects, then the lookup form.

ControlTypeWhat it does
Run idText fieldThe id to look up. The placeholder reads "Workflow run, request, trace or session id".
Look upButtonLoads the ledger for the trimmed id and puts it in the URL as ?id=, so the browser's back button returns to the previous lookup. Pressing Enter does the same. An empty field clears the result.

A spinner shows while the ledger loads.

Ledger view​

The first line names what the id turned out to be, Workflow run, Agent run, Trace or Session, followed by the id. For a workflow run it adds the workflow type and status, and it lists any session ids found.

ControlTypeWhat it does
Export JSONButtonDownloads the ledger you are looking at as a JSON file named run-ledger-<id>.json, with characters outside letters, digits, dot, dash and underscore replaced. The file holds the same data as the screen.

For a workflow run that is a replay, or that has been replayed, a Replay lineage box shows "Replay of" the original run (and the step it replayed from) or "Replayed as" each replay with its start step and status. Clicking a run id in the box loads that run's ledger. Without Workflow history, replay and pinned data the box is replaced by "Step attempts and replay lineage need a Spanway Enterprise license with Workflow history, replay and pinned data."

When the run logged more spend rows than one ledger holds (2,000), an amber warning says the ledger shows only the first part.

Totals​

CardValueDetail line
SpendTotal spend. Amounts under one cent show six decimals, others four.Eval spend.
RequestsLLM requests.Failed requests, MCP calls and tool calls.
TokensTotal tokens.Prompt tokens in and completion tokens out.
GuardrailsGuardrail decisions.How many intervened and how many flagged.
DurationWall time of the run in seconds, or n/a.The models used, or "no models".
EvalsEval scores.The mean score, or "no scores".
Shadow verdictsShadow verdict count.None.
Online scoresOnline score count.None.
Audit rowsAudit log rows.Workflow events, step attempts (when licensed), and Lens spans with the Lens state, which is included, not found or unavailable.

Entries table​

The table lists every entry in time order.

ColumnMeaning
TimeThe entry time in UTC, ISO format.
KindRequest, MCP call, Tool call, Guardrail, Audit, Workflow event, Step attempt, Eval score, Shadow verdict, Online score or Trace span.
DetailA one line summary that depends on the kind, see below.
RequestThe request id the entry belongs to. Empty for audit rows, workflow events and step attempts.
KindDetail shows
RequestThe model (or call type), tokens, spend, and "failed" when it failed.
MCP callThe tool name, spend, and "failed" when it failed.
Tool callThe tool name.
GuardrailThe guardrail name, its status and its mode.
AuditThe action, table, object id and who changed it.
Workflow eventThe sequence number, event type and step name.
Step attemptThe step key and attempt number (and generation), how it started, its status, "agent not called" when the agent was never reached, the error code and the cost.
Eval scoreThe model, the score and whether it passed.
Shadow verdictThe outcome, the shadow model and the eval spend.
Online scoreThe rule, scorer number and type, the score or "error", whether it passed, and eval spend.
Trace spanThe span type and name, the agent and the duration in milliseconds.

Empty, error and disabled states​

Before you look anything up, the page shows only the explanation and the form. An id the gateway cannot match shows "No run found for id '...'" in red. A session without a user id that is not a proxy admin sees "Not allowed to view run ledgers". Any other failure shows the gateway's message. A ledger that includes agent calls, on a license without Agent governance, shows "Agent calls in the run ledger needs a Spanway Enterprise license" naming Agent governance, with a link to get a trial license. Failed lookups are not retried automatically, so press Look up again to retry.

Differences by role and license​

WhoWhat they see
Proxy admin and proxy admin viewerEvery ledger row on the gateway.
Internal user and internal viewerOnly rows tied to their own user id and to the teams the gateway lets them read logs for.
Org adminIn the nav. The gateway applies the same row scoping as for other non admin callers.
License featureEffect
Agent governanceNeeded for any ledger that includes agent calls. Without it the gateway refuses the whole ledger.
Workflow history, replay and pinned dataAdds step attempts, the step attempt count and replay lineage.

Errors​

What you seeWhat it meansFix
"No run found for id '...'"The id matches no workflow run, request, trace or session you may read.Check the id, and remember that other users' runs are hidden from non admins.
"Not allowed to view run ledgers"The session has no user id and is not a proxy admin.Sign in with a user account, or use a proxy admin session.
"Agent calls in the run ledger needs a Spanway Enterprise license"The ledger includes agent calls and the license lacks Agent governance.Ask sales@spanway.ai to add agent_governance, or look up a run without agent calls.
"Step attempts and replay lineage need a Spanway Enterprise license ..."The license lacks Workflow history, replay and pinned data.The rest of the ledger still shows. Add workflow_history for attempts and lineage.
An amber warning that the ledger shows only the first partThe run logged more than 2,000 spend rows.Narrow the question with a request id or trace id from inside the run.
Any other message in redThe gateway's own error, for example the database is not connected.Fix the cause and click Look up again, the page does not retry on its own.

Logs​

The page writes no log lines of its own. See run ledger.