Token flow
Token flow answers one question for an agent: where did the tokens go. It draws usage left to right, from the total, through the work type each request belongs to and the model deployment that served it, to whether the request completed or errored. This page walks through turning it on, reading the diagram, and drilling into the runs behind it

Demo data from the Lens UI preview
Before you start
You need recorded agent traces for the agent. Turning on work types also needs a proxy administrator and one chat model on the connected LiteLLM gateway, which Lens uses to classify runs. No discovery or embedding model is required
If the agent already has recorded or discovered categories in Profiles, skip to Read the diagram; Token flow uses those categories as its work types
Turn it on
Open Profiles, select the agent, and choose a time range. Select the Token flow tab, then choose Enable with defaults

Enable with defaults creates eight work types and starts classifying new runs: coding and feature work, troubleshooting, bug fixes, incident remediation, Slack responses, data analysis, presentations and documentation, and admin work. The line under the buttons names the model that will classify
To start from your own list instead, choose Customize before enabling. Rename or reword any work type, remove the ones that do not apply, use Add work type for new ones, pick the Classification model, then choose Enable token flow. The descriptions are what the model reads when it sorts a run, so write them as a plain statement of what belongs there

Lens classifies each new run from the first 1,500 characters of its first request. That text is sent to the classification model through your gateway and incurs provider charges. Runs from before you enabled stay Unclassified, and runs waiting for a result are counted as pending, so the diagram fills in as new traffic arrives
Read the diagram
Read the columns left to right: Total, Work type, Model, Outcome. Each column lists its largest entry first, and the width of a band is its share of the total. The cards above the diagram give total tokens, known spend, requests, and the completed share for the same selection
Hover a node or a band to highlight every path that runs through it. Hovering a work type shows which models served it and how much of it errored; hovering Errored shows which work types and models the failures came from
The table under the diagram lists each work type with its share, input tokens, output tokens, requests, and errored share. Use it when you need the numbers behind a band
Switch between tokens and cost
Measure switches the diagram between Tokens, which is input plus output, and Cost, which is the spend the gateway recorded. A work type that uses a cheaper model takes a smaller share by cost than by tokens, so compare both before deciding where to optimize. Requests without a matching billing record add nothing to cost

Filter by harness
Harness narrows the diagram to one harness, such as a single coding agent, when your traces record it. Choose All harnesses to return to the full view. If the selected harness has no usage in the range, the tab says so and offers Clear harness filter
Open the runs behind a work type
Select a work type in the diagram or the table, or one of its bands, to open Classified runs. The list shows each matching run with its model, tokens, and cost. Select a run to see what Lens classified it from: the bounded preview of the first user prompt, the tool names, the classifier's confidence, and its rationale, then open its trace to follow the full run
Use this to check a surprising share. If runs land in the wrong work type, choose Customize work types and tighten the names and descriptions
Preview the export
The Export tab shows the same usage as one enriched event per request, with its work type, model, outcome, tokens, and cost. Switch between OTLP logs, Webhook, and S3 to see the payload for each destination, and download the events as NDJSON to load into an existing dashboard
This is a preview on demo data. Lens does not deliver these events to a destination yet

How requests are counted
Token flow counts each gateway request once, even when it was exported more than once, and leaves out requests that belong to another agent or are shared with one. A request is Errored when any of its calls ended with an error status; the outcome does not say whether the work was merged, closed, or accepted. Long ranges can be partial, and the tab says so when they are
See the Token flow reference for the API routes and counting rules