Skip to content

Commit c712ebc

Browse files
docs: finding 0001 — OCH pack cuts agent token usage 2–4× (live Move 2 data) (#273)
## What The first live measurement from the Move 2 variance probe, written up as a findings doc. On real tasks, an OCH pack cut a coding agent's **total token usage 2.18×–4.08×** and **cost 1.9×–3.3×** — by replacing the agent's repo exploration with the pack's prebuilt structure map. | Task | without pack | with pack | reduction | |---|---:|---:|---:| | open-ended ("where to add a rule type") | 658,318 tok / $0.64 | 161,285 tok / $0.20 | **4.08× / 3.26×** | | enumeration ("list exports") | 623,098 tok / $0.70 | 286,379 tok / $0.36 | **2.18× / 1.91×** | The saving is almost entirely **cache tokens** — the file-reads and tool-runs the agent does to reconstruct structure. Output tokens barely moved, so it's exploration-avoided, not shorter answers. This is the *opposite* of the arXiv "+10% tokens" framing: OCH's pack replaces exploration rather than adding to it. ## Why this reframes the headline Move 2 was specced to measure answer *variance*. On these tasks `output_hash` dispersion came back null — because it compares answer **text**, and a frontier model rephrases prose every run (saturated). Measuring decision convergence on prose needs the `judge` oracle, which the CLI doesn't yet wire. Token efficiency, by contrast, is a directly-measured resource number with no saturation, and it **replicated across both task regimes**. It's the more defensible claim. ## Honest scope Marked **Preliminary**: N=5, one small repo, one agent (Claude Sonnet 4.5), two tasks. A signal, not a benchmark. The doc says so plainly, with a reproduce recipe and next steps (wire the judge oracle; scale to more tasks/repos/Codex/larger N). Docs-only — no code change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent df12cf9 commit c712ebc

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Finding 0001 — An OCH pack cuts a coding agent's token usage 2–4× on real tasks
2+
3+
- Status: **Preliminary** — first live measurement, 2026-06-30.
4+
- Author: Bonk + Laith.
5+
- Instrument: `codehub code-pack --variance-probe` (Move 2, spec 010), the
6+
direct-CLI runner on Amazon Bedrock.
7+
- Scope guard: 2 tasks × 5 runs/arm × 1 agent (Claude Code, Sonnet 4.5) × 1
8+
repo. This is a signal, not a benchmark. See "What this is not" below.
9+
10+
## The headline
11+
12+
Giving a coding agent an OpenCodeHub pack (the symbol skeleton + file-tree +
13+
deps + xrefs map) instead of letting it explore the repo cut its **total token
14+
usage 2.18×–4.08×** and its **dollar cost 1.9×–3.3×** across two tasks — while
15+
producing the same quality of answer. The agent stopped re-reading files and
16+
running tools to reconstruct structure it was handed up front.
17+
18+
This is the opposite direction from the variance-anchoring literature
19+
(arXiv:2606.26979, "deterministic anchoring halves run-to-run variance at ~10%
20+
*more* tokens"). OCH's pack does not *add* context on top of exploration — it
21+
*replaces* the exploration. On a structure-discovery task that makes it
22+
cheaper, not dearer.
23+
24+
## The measurement
25+
26+
Two tasks against an isolated snapshot of `@opencodehub/policy` (4 source files,
27+
indexed to 106 graph nodes / 181 edges; pack `9fe66179`). Each task ran the
28+
agent 5 times with the pack in context and 5 times without, holding
29+
commit / instruction / agent / model fixed. Token totals include the cached
30+
system prompt Claude Code injects per call (`cache_creation` + `cache_read`),
31+
which dominates the count and was the subject of the bug fix in PR #271.
32+
33+
| Task | Arm | Total tokens | of which cache | Cost (5 runs) |
34+
|---|---|---:|---:|---:|
35+
| **A.** open-ended: "name the exact files + symbols to edit to add a `max_file_count` rule type" | without pack | 658,318 | 653,571 | $0.6412 |
36+
| | with pack | 161,285 | 157,349 | $0.1965 |
37+
| | **delta** | **4.08× fewer** | | **3.26× cheaper** |
38+
| **B.** enumeration: "list every exported function and type" | without pack | 623,098 | 617,267 | $0.6969 |
39+
| | with pack | 286,379 | 283,049 | $0.3644 |
40+
| | **delta** | **2.18× fewer** | | **1.91× cheaper** |
41+
42+
The reduction is almost entirely **cache tokens** — the tokens the agent spends
43+
reading files and running tools to reconstruct the codebase's shape. Without
44+
the pack the agent burned 617K–654K such tokens per arm; with the pack, handed
45+
the structure directly, it spent 157K–283K and stopped hunting. Output tokens
46+
(the answer itself) barely moved (3.3K–5.6K), confirming the saving comes from
47+
*exploration avoided*, not *shorter answers*.
48+
49+
## Why "variance" was the wrong headline
50+
51+
Move 2 was specced to measure run-to-run answer *variance* (does the pack make
52+
the agent's answer wander less?). On these tasks the `output_hash` dispersion
53+
metric came back **null** (delta 0, and −0.2 on Task B — noise at N=5). The
54+
reason is mechanical, not a pack failure: `output_hash` compares answer *text*,
55+
and a frontier model rephrases a free-text answer slightly every run, so every
56+
answer hashes as distinct regardless of context. Measuring *decision*
57+
convergence on prose needs the `judge` oracle (semantic-equivalence scoring),
58+
which the CLI does not yet wire — tracked as the next gap.
59+
60+
Token efficiency, by contrast, is a directly measured resource number with no
61+
such saturation problem — and it replicated cleanly across both task regimes.
62+
It is the more defensible claim.
63+
64+
## What this is NOT
65+
66+
- **Not a benchmark.** N=5, one small repo, one agent, one model. The 2–4×
67+
range is a real signal on these tasks, not a published figure. A defensible
68+
number needs more tasks, more repos, larger N, and the second agent (Codex).
69+
- **Not a variance result.** The variance question is still open pending the
70+
judge oracle (see above).
71+
- **Not a correctness claim.** The probe did not score answer correctness here
72+
(the `output_hash` oracle only checks textual identity). The token saving is
73+
real; "same quality" is an eyeball judgment on the answers, not a graded one.
74+
75+
## Reproduce
76+
77+
```
78+
# 1. Analyze a target repo so a pack can be generated.
79+
codehub analyze /path/to/repo --no-scan
80+
81+
# 2. Write a task file (see packages/eval/examples/variance-task.yaml).
82+
# 3. Run the probe (Claude on Bedrock, instance-role creds):
83+
CLAUDE_CODE_USE_BEDROCK=1 AWS_REGION=us-east-1 \
84+
codehub code-pack --variance-probe task.yaml \
85+
--runs 5 --harness claude \
86+
--model-claude us.anthropic.claude-sonnet-4-5-20250929-v1:0 --json
87+
```
88+
89+
The emitted JSON reports per-arm `tokens` (`inputTokens` + `outputTokens` +
90+
`cacheTokens`) and `tokenOverhead` (with/without total); a value below 1.0
91+
means the pack reduced tokens.
92+
93+
## Next
94+
95+
1. Wire a `JudgeScorer` into `runVarianceProbe` so the `judge` oracle works
96+
end-to-end — unblocks the variance measurement on open-ended tasks.
97+
2. Scale the token measurement: more tasks (build/fix/explain regimes), a
98+
second repo, the Codex arm, larger N — turn the 2–4× signal into a figure.
99+
3. Revisit `DEFAULT_CLAUDE_MODEL` (`us.anthropic.claude-sonnet-4-6`): not
100+
confirmed available in the test account; sonnet-4-5 was used.

0 commit comments

Comments
 (0)