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.
git clone https://github.com/orin-dx/lumen.git && cd lumencargo build --release --workspace./target/release/lumen --help
One session, two views
A six-turn test session. The dollar figures show the arithmetic, not a typical session.
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 │
╰─────────────────────────────┴─────────╯ 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.
| agent | tool calls | tokens | cost |
|---|---|---|---|
| Claude Code | In the logs: Yes, with subagents and compaction | In the logs: Per turn, every cache tier | In the logs: Per turn |
| OpenCode | In the logs: Yes | Partly, or coarser: Per message, no 1-hour cache split | In the logs: Per message |
| Codex | Not in the logs: No | Partly, or coarser: Session totals only | Partly, or coarser: Per session |
| Antigravity | In the logs: Yes | Not in the logs: None in the logs | Not in the logs: Unknown |
- In the logs
- Partly, or coarser
- Not in the logs
Inside Orin DX
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.