lumen

Reads coding-agent session logs and reports cost, cache hits and tool loops.

measure
built, unpublished

Why Lumen

the problem

Coding agents already log every turn, tool call and token. Each one writes a different format.

what it does

Lumen reads those logs and tells you what a session cost, whether the prompt cache worked and where the agent went in circles.

It’s the observe step in Orin DX. Prism checks a change against what Lumen sees. Wisp holds the context that change edits.

Get Lumen

Build from source with a current stable Rust toolchain. The lumen-cli crate on crates.io is a different project.

One session, two views

A six-turn test session. The dollar figures show the arithmetic, not a typical session.

lumen audit: tokens by cache tier, cost and the no-cache baseline
 Token Economics & Cache Audit: a1b2c3d4-1234-4567-89ab-1234567890ab
 Model: claude-3-5-sonnet-20241022

╭─────────────────────────────┬─────────╮
│ Metric                      ┆ Value   │
╞═════════════════════════════╪═════════╡
│ Uncached Input Tokens       ┆ 39200   │
│ Cache Creation (5m Write)   ┆ 2500    │
│ Cache Creation (1h Write)   ┆ 0       │
│ Cache Read (0.10x Discount) ┆ 140000  │
│ Output Tokens               ┆ 270     │
│ Reasoning Tokens            ┆ 0       │
│ Cache Hit Ratio             ┆ 77.1%   │
│ Actual USD Spend            ┆ $0.1730 │
│ Baseline Cost (No Cache)    ┆ $0.5492 │
│ Net Savings USD             ┆ $0.3761 │
│ Efficiency Multiplier       ┆ 3.17x   │
╰─────────────────────────────┴─────────╯
lumen trace: turn by turn, with tool calls and token counters
 Session Trajectory: a1b2c3d4-1234-4567-89ab-1234567890ab
 Orchestrator: ClaudeCode | Model: claude-3-5-sonnet-20241022
 Turns: 6 | Wall Time: 0ms

│ Turn ┆ Role       ┆ Tool Invocations                   ┆ Tokens (In / Write / Read / Out) │
│ 0    ┆ User       ┆ -                                  ┆ -                                │
│ 1    ┆ Assistant  ┆ view_file(call_read_01)            ┆ 12500/2500/45000/85              │
│ 2    ┆ ToolResult ┆ -                                  ┆ -                                │
│ 3    ┆ Assistant  ┆ replace_file_content(call_edit_01) ┆ 13200/0/47500/140                │
│ 4    ┆ ToolResult ┆ -                                  ┆ -                                │
│ 5    ┆ Assistant  ┆ -                                  ┆ 13500/0/47500/45                 │

Micro-benchmarks

Criterion on an Apple M3 Pro. Ingestion speed on large files hasn’t been measured.

82–229 ns
Detect which agent wrote a log
Short fixture files for Antigravity, OpenCode and Claude Code. Codex isn’t in the benchmark.
1.16 ms
One analysis pass over 10,000 turns
Synthetic turns with one file read each, 19 accumulators.
10.7 µs
Loop detection on a 500-node graph
Synthetic graph with planted loops.

Before you try it

  • Not on crates.io and no release binaries. Build it from source.
  • The lumen-cli crate on crates.io is a different project.
  • Runs after the session. No live monitoring, daemon or agent hooks.
  • Codex logs give session totals only: no per-turn cost and no loop detection.
  • Antigravity logs carry no token counts, so cost reads unknown.
  • lumen ingest reads one directory level. Codex’s dated folders go in a day at a time.
  • The CLI shows cost, cache, loops and review stalls. Latency, retries and the rest need the Rust library.
  • Historical price changes aren’t modelled yet.

What it reports

Cost and cache

  • Tokens by tier: uncached input, 5-minute and 1-hour cache writes, cache reads, output.
  • Cache hit ratio: cache reads over all input tokens.
  • Cost priced per turn, at that turn’s timestamp.
  • An unpriced model reads “unknown”, never $0.00.
  • Subagent spend rolls up into the parent session.
  • Compacted sessions are counted once, not twice.

Loops

  • Tool calls become a graph. Cycles are found with Tarjan’s algorithm.
  • A circular loop: three or more steps around the same symbol with no edit.
  • A review stall: a drafter and auditor past two rounds.

How to read the numbers

  • Observed: token counts as the agent logged them.
  • Derived: cost and cache hit ratio, calculated from observed tokens and a versioned price table.
  • Modelled: the no-cache baseline, savings and multiplier. What the session would have cost without caching, not a saving anyone recorded.

Commands, all local

  • lumen audit and lumen trace read one file and write nothing.
  • lumen ingest stores sessions in a local SQLite file.
  • lumen sessions and lumen session read them back.
  • lumen trends compares cost, cache and loops across sessions.
  • --json on every command.
  • No network client. Prices ship with the binary.

What it supports

Which agents it reads

Lumen reports what each agent logs. Some log less.

Agents
agenttool callstokenscost
Claude CodeIn the logs: Yes, with subagents and compactionIn the logs: Per turn, every cache tierIn the logs: Per turn
OpenCodeIn the logs: YesPartly, or coarser: Per message, no 1-hour cache splitIn the logs: Per message
CodexNot in the logs: NoPartly, or coarser: Session totals onlyPartly, or coarser: Per session
AntigravityIn the logs: YesNot in the logs: None in the logsNot in the logs: Unknown
  • In the logs
  • Partly, or coarser
  • Not in the logs

Inside Orin DX

  • lumen
  • prismPrism reads transcripts with Lumen’s parsers, so both count cost and cache the same way.
  • wispTelemetry from Wisp and Monokl, so context changes show up in the numbers. Planned.
  • michiTOON output through Michi. Planned.
lumen
  • prismPrism reads transcripts with Lumen’s parsers, so both count cost and cache the same way.
  • wispTelemetry from Wisp and Monokl, so context changes show up in the numbers. Planned.
  • michiTOON output through Michi. Planned.

What’s next

  • A measurement basis on every figure in the output: observed, derived or modelled.
  • More agents: older OpenCode storage and Gemini-style logs such as Qwen Code.
  • Telemetry from Wisp and Monokl, so context changes show up in the numbers.
  • Sessions handed to Prism as regression tasks.
  • Workflow classification and missed-savings insights.