Skip to main content

The usage log

Each question a user asks is one run of the agent runner. A run makes one or more calls to the model. With prompt caching on, the model reads most of each call's input from a cache. Reading from the cache is faster and cheaper than reading the input fresh.

The agent runner writes a log line for each finished run. The line counts the model calls and the tokens, and says how many tokens came from the cache. Use this page to chart cache use and model calls in your log collector.

What a line looks like​

Each line is one JSON object on its own line. The agent runner container writes it to standard output when the run ends:

{"event":"run_usage","source":"runner","ts":"2026-11-24T10:00:00.000Z",
"run_id":"r_8f2c41d0b7e8","customer_id":"acme","project_id":"default",
"agent_id":"a_5b1e9c2a7d4f","session_id":"s_0c2f8d3b4e17",
"model":"claude-sonnet","status":"success","error_code":null,
"llm_calls":4,"input_tokens":4,"cache_read_tokens":42620,
"cache_write_tokens":20654,"output_tokens":812,
"cache_read_ratio":0.674,"duration_ms":15250}

The real line has no line breaks. The example is wrapped to fit the page.

The fields​

FieldWhat it is
eventrun_usage
sourcerunner
tswhen the line was written, in UTC
run_idthe run. One question is one run
customer_id, project_idthe Agent Router organization and project the run used
agent_idthe agent that ran
session_idthe conversation the run belongs to
modelthe model the run's last model call used
statussuccess, error, or discarded. discarded means the run had already ended another way, for example the user stopped it. The model calls still happened, so the line still counts them
error_codea code when the run failed with a known cause, else null. The error's text is never on the line
llm_callsthe number of model calls in the run
input_tokensinput tokens the model read fresh, not from the cache
cache_read_tokensinput tokens the model read from the cache
cache_write_tokensinput tokens the model wrote to the cache, for later calls to read
output_tokenstokens the model wrote
cache_read_ratiocache_read_tokens divided by all input, rounded to three places. All input is input_tokens + cache_read_tokens + cache_write_tokens. null when the run sent no input
duration_mshow long the run took

Every model call goes to the model, with or without caching. So "cache hits against model calls" is not the measure. The measure is the share of input read from the cache: cache_read_ratio for one run, or the sums below for a day.

A run that stops on an internal error of the agent runner, before the runner has its result, writes no line. There are no counts to write. The run still shows as failed in the chat.

The token counts are the ones the agent runner counted. Agent Router may report slightly different totals for the same run.

What is never in a line​

The line never carries the question, the answer, a tool call or its result. It never carries an error's text. It never carries a user's name, address or id. The session_id and run_id find the conversation in the agent runner's database if your support contact needs it.

Find the lines​

Search your log collector for "event":"run_usage". The runner writes the JSON with no spaces. If your collector reads JSON fields, search for event=run_usage.

In Splunk, this search shows each day's model calls and tokens, and the share of input read from the cache:

"run_usage" earliest=-7d
| spath
| search event=run_usage
| bin _time span=1d
| stats dc(run_id) AS runs sum(llm_calls) AS llm_calls sum(input_tokens) AS fresh
sum(cache_read_tokens) AS cache_read sum(cache_write_tokens) AS cache_write
sum(output_tokens) AS output BY _time
| eval cache_share=round(cache_read/(fresh+cache_read+cache_write), 3)

To see the lines without a log collector, read the runner's log. Use your release name in place of prism:

kubectl logs deploy/prism-agent-runner -n <namespace> | grep run_usage

Before this release​

Runs from before this release wrote no line. Their numbers are in the agent runner's database, in the runs table. This query gives daily sums:

SELECT date_trunc('day', created_at) AS day,
count(*) AS runs,
sum(jsonb_array_length(request_ids)) AS llm_calls,
sum((usage->>'inputTokens')::bigint) AS fresh,
sum((usage->>'cachedInputTokens')::bigint) AS cache_read,
sum((usage->>'cacheWriteTokens')::bigint) AS cache_write
FROM runs
WHERE created_at > now() - interval '7 days'
GROUP BY 1 ORDER BY 1;

After Agent Router reports a run's cost, the runner replaces that run's input and output token counts in the database with Agent Router's figures. The log line keeps the runner's own counts.