Taewoo Park

Projects

Agent-Blackbox

An agent's account of its own run is a narration, and a measurably unreliable one. So I take the record back — what was read, changed, run, delegated and wasted — from the events themselves rather than from the summary.

Open the black box while the flight is still in the air

A 2026 study of eight frontier models on agentic coding found they predict their own token usage with a correlation of just 0.39, and systematically underestimate the real bill. The same task on the same model varies by up to 30× in tokens, and agentic runs already burn roughly a thousand times more tokens than ordinary coding — almost all of it input context.

That bites hardest in the era of loop engineering, where I no longer prompt an agent turn by turn: the loop finds the work, verifies it, decides the next action. What one person can set in motion went up; verification got harder. The result is an agent that cannot price its own work being handed the job of checking itself.

So I stopped asking it. Every run becomes a live, replayable operational graph reconstructed from observed events, scored on how economically the context window was used, with the waste named file by file and command by command.

A real multi-agent run as a session map, with the efficiency score in the right rail
A real multi-agent run as a session map, with the efficiency score in the right rail

Observe, don't trust the narrator

Every node on the map is an event the agent actually emitted — a read, an edit, a command and its exit code, a delegation — never a sentence it wrote about itself. I treat cost as evidence on the same footing: the score and every suggestion come from observed sizes and token snapshots, not from the model's account of its own thrift.

Traces stay on the machine, prompts and file contents are redacted by default, and I put no API key anywhere in the product. Even the optional model-written advice runs locally, on a digest.

Three hosts, and two of them need no install at all

Claude Code needs nothing installed: the daemon tails the transcripts the CLI already writes, so any session is recorded the moment claude runs. Codex needs no recorder either — the adapter tails its rollout sessions across CLI and desktop, picking up token, patch, search, MCP, compaction and subagent signals. OpenCode records through a thin plugin.

Coverage is keyed off the host event rather than the model, so reads, edits, bash calls, skills, MCP tools, permissions, subagents, slash commands, compaction and model switches are all captured. I filter known noise; anything I have not modelled yet still surfaces as a labelled node rather than being dropped.

The map assembles itself as the agent works

The recorder streams events to a local daemon and the dashboard updates over a WebSocket: moments appear, files connect by sweeping arcs, tokens tick, a failed test marks in oxblood, the fix resolves it. Consecutive repeats aggregate — Tests passed ×6 — so even a large run stays scannable.

Real delegations fork the trunk into their own branch, and each lane is named by role. A task prompt beginning You are a literature-search specialist… becomes a lane called literature-search specialist, so a run with dozens of parallel agents reads as a team. Clicking a moment opens a popover with evidence, files and tokens; dragging the timeline rewinds the graph to an exact sequence point.

Focus — one moment, then one agent's lane, with the rest of the diagram receding
Focus — one moment, then one agent's lane, with the rest of the diagram receding

Two questions kept apart, on a yardstick that fits the task

The score is computed from eleven observed metrics: context pressure, cache hit ratio, redundant re-reads, read amplification, large injections, retry waste, yield density, tool overhead, edit churn, large file reads, and unused reads. Each flagged metric expands into a concrete fix rather than a warning.

The score is conditioned on what kind of run it was, applied only once the classification is confident — a research run is not penalised for reading widely, a debug run weighs retries harder. A separate effectiveness score answers whether the task landed, so an efficient-but-failed run reads differently from a wasteful-but-shipped one.

Every run is also scored against your own past runs of the same kind in the same project, which turns a bare number into a judgement — score 40 against your usual 87 for research.

One run, both axes — wasteful at 62, but the task shipped at 100
One run, both axes — wasteful at 62, but the task shipped at 100

The advice is required to cite the run's own numbers

Both the rule-based floor and the local-model prompt encode a per-metric fix playbook, and I require every action to cite the run's own figures, name the offending file or command, and give an expected effect. I distilled the playbook from published context-engineering work rather than inventing it.

Anthropic's context-engineering guidance supplies compaction, sub-agent isolation and just-in-time retrieval. Manus supplies the cache hit rate as the primary cost lever — cached tokens roughly ten times cheaper — plus a byte-stable prompt prefix. Liu et al. supply the finding that models systematically under-use the middle of long contexts, which is why the advice favours trimming over adding.

Only a redacted digest ever leaves the process, even for a local model: metric statuses, counts and sizes, plus coarse offender labels such as billing.ts ×2 so the advice can name what to fix — never contents, paths, arguments or secrets.

Write the fix back into the file the agent already reads

Advice I have to reapply by hand is friction, so the optimizer turns findings into a managed memory block appended between markers at the end of the host's memory file, leaving the stable prompt-cache prefix undisturbed. It names concrete offenders — files to read once, verified commands to reuse.

It accumulates across runs: a pattern seen repeatedly ranks first with its count, while one-offs fade, so the block reflects the project's real habits rather than the last session. Every write is marked, opt-in and never silent, and a check pass after the next run auto-rolls-back on a clear score drop — the actuator half of the recorder: observe, diagnose, write, measure, roll back if it did not help.

The exact block, previewed before it is written to CLAUDE.md
The exact block, previewed before it is written to CLAUDE.md

One lever pinned, and the waste it was aimed at disappeared

I ran the before-and-after on a real multi-agent ultrawork session over one task — add a modulo operation end to end. The first run's explore subagents re-read nine files; Agent-Blackbox flagged it and pinned an instruction into AGENTS.md to read three named files once. The second run started from the identical pristine repository, git-reset between them, on a brand-new session with no carried context.

Context-efficiency score went from 80 to 99. Redundant re-reads went from nine files and roughly 1.8k reclaimable tokens to none. Total tokens fell from 939k to 521k, a 44 % drop; tool calls from 619 to 253; yield density rose from 63 per thousand tokens to 154.

I am careful about what that proves. The harness is stochastic, so part of the token drop is variance — but the redundant-reads elimination is the memory working directly. The two-run cycle is a benchmark validating the mechanism, not the workflow: in real use the memory is applied once and pays off on later tasks, with no extra run.

The first run — 80, nine files re-read, 939k tokens, the lever named in the right rail
The first run — 80, nine files re-read, 939k tokens, the lever named in the right rail

Cut the waste inside the current run, with no re-run at all

The cross-run memory pays off on future tasks; the in-run optimizer pays off now. When the agent re-reads a file it already read this run, the hook rewrites the result — unchanged content becomes a note to reuse the earlier copy, edited content becomes only the changed line range. Measured on a 120-line file, that is 96 % fewer tokens on an unchanged re-read and 94 % on an edited one.

I made it correct by construction rather than aggressive. Re-reads are never blocked, and the substitution only fires when no compaction has happened since that file was last served, so the content is provably still in context. After a compaction the full file is served again, because the agent may have lost it.

Pick the run up somewhere else without re-reading everything

When a run has to continue elsewhere — a teammate, the next agent, or the same agent after a context reset — the handoff export is a structured summary covering the objective, the files in play, the decisions, the commands and verification, the blockers, and the next safe action. One click copies it as Markdown.

It pairs best with heavy multi-agent harnesses, which is where I needed the instrument most: a run that spends tokens hard to ship complex work is exactly the run whose cost is invisible from inside the harness.

Session map, dark console, efficiency co-pilot, handoff
Session map, dark console, efficiency co-pilot, handoff
The handoff card over a dimmed map, one click from Markdown
The handoff card over a dimmed map, one click from Markdown