Plan First, Pay a Third

A November 9 paper, FlowPlan, had Claude Code plan each fix before editing and check the diff against the plan instead of re-reading and re-testing. Haiku 4.5 used 0.32x the tokens on SWE-bench Verified with no significant change in resolve rate. We priced it: plain Haiku 4.5 cost about 2x Sonnet 5 per resolved issue despite half the token price, and the plan-first loop closes most of the gap. Three charts, a CLAUDE.md rule set, and costfix.py.

Published 2026-11-15 by Dor Amir on the Nadir blog.

Filed under Agents.

TL;DR.

A paper posted to arXiv on November 9, FlowPlan (arXiv:2611.13241), ran Claude Code on 545 real repository issues and asked a simple question: can a coding agent spend fewer tokens if it plans the fix before it edits, and checks the edit against the plan instead of re-reading and re-testing?

The answer was yes, and by a lot:

The paper reports tokens, not dollars. So we priced it, and found the part that matters for anyone choosing models by price per token:

Below: the results in three charts, why the loop is where the cheap model loses, a plan-first rule set you can put in CLAUDE.md today, and costfix.py, 25 lines that price an agent per resolved issue instead of per token.

Token counts, resolve rates and trajectory figures are from Sepidband, Shin, Wang and Hemmati, "FlowPlan: Reducing the Token Cost of Coding Agents with Abstraction-Guided Planning and Verification," arXiv:2611.13241v1. Dollar figures are our estimates at Anthropic list prices as of November 15, 2026, with an assumed token mix; they are not in the paper and are not Nadir customer data.

What FlowPlan does.

Most token-cutting methods for agents take something away: fewer tool calls, compressed observations, skipped test runs. FlowPlan changes what the agent reasons about. Instead of working over raw source files again and again, it works over a small graph of each function.

  1. Abstract. Each candidate function is turned into a control-flow graph (CFG) or a data-flow graph (DFG).
  2. Localize. The agent finds the likely fault on the graph, not by scrolling the file.
  3. Plan. It writes the fix as explicit graph changes: "add a branch on None before the call at node 4", "route the return value through the sanitizer".
  4. Edit. It changes the real source.
  5. Check. FlowPlan rebuilds the graph and compares the structural change it sees with the one that was planned.
  6. Verify once. A final check of the whole repair, then stop.

Everything ran on Claude Code v2.1.220, headless, low reasoning effort, one fresh session per issue. The benchmarks were sampled subsets: 158 SWE-bench Pro Python issues, 218 SWE-bench Verified issues and 169 SecBench C/C++ vulnerabilities. Sessions were capped at 80 turns, $2 and 25 minutes (40 turns and $1.50 on SecBench).

The results.

Grouped horizontal bar chart of mean total tokens per instance, vanilla Claude Code vs FlowPlan (CFG). Haiku 4.5 SWE-bench Pro: 3,715K vs 1,746K (0.47x). Haiku 4.5 SWE-bench Verified: 3,414K vs 1,092K (0.32x). Haiku 4.5 SecBench: 767K vs 522K (0.68x). Sonnet 5 SWE-bench Pro: 1,152K vs 829K (0.72x). Sonnet 5 SWE-bench Verified: 803K vs 586K (0.73x). Sonnet 5 SecBench: 681K vs 640K (0.94x).
Grouped horizontal bar chart of mean total tokens per instance, vanilla Claude Code vs FlowPlan (CFG). Haiku 4.5 SWE-bench Pro: 3,715K vs 1,746K (0.47x). Haiku 4.5 SWE-bench Verified: 3,414K vs 1,092K (0.32x). Haiku 4.5 SecBench: 767K vs 522K (0.68x). Sonnet 5 SWE-bench Pro: 1,152K vs 829K (0.72x). Sonnet 5 SWE-bench Verified: 803K vs 586K (0.73x). Sonnet 5 SecBench: 681K vs 640K (0.94x).
SettingVanilla resolve rateVanilla tokens per issueFlowPlan (CFG)FlowPlan (DFG)
Haiku 4.5, SWE-bench Pro43.0%3,715K0.47x0.46x
Haiku 4.5, SWE-bench Verified61.0%3,414K0.32x0.35x
Haiku 4.5, SecBench29.0%767K0.68x0.74x
Sonnet 5, SWE-bench Pro52.5%1,152K0.72x0.76x
Sonnet 5, SWE-bench Verified73.9%803K0.73x0.74x
Sonnet 5, SecBench37.9%681K0.94x0.92x

Token use fell in all six settings, and significantly in five. The paper also reproduced six earlier methods on the same harness. The strongest, skipping execution entirely ("No-execution"), landed between 0.56x and 0.81x. Others, like SHERLOC (0.85x to 1.33x) and AgentDiet (0.79x to 1.13x), sometimes used more tokens than plain Claude Code. FlowPlan was the best or tied for best in four of six settings.

Two patterns stand out.

The weaker model saves more. Haiku 4.5 dropped to a third or half of its tokens. Sonnet 5 dropped by about a quarter. That's because Haiku had much more to lose: on SWE-bench Verified it used 4.3x the tokens Sonnet 5 did for the same issues.

Short tasks save less. SecBench trajectories were only about 15 calls long, so there was no long post-edit loop to cut. The savings there came from smaller context per call (about 31K tokens instead of 51K).

Where the tokens were going.

Stacked bar chart of Haiku 4.5 tokens per session before and after the first edit, in millions. SWE-bench Pro vanilla: 1.20 before, 2.42 after, 3.62 total. SWE-bench Pro FlowPlan: 0.55 before, 0.96 after, 1.51 total. SWE-bench Verified vanilla: 1.15 before, 2.19 after, 3.34 total. SWE-bench Verified FlowPlan: 0.48 before, 0.48 after, 0.96 total.
Stacked bar chart of Haiku 4.5 tokens per session before and after the first edit, in millions. SWE-bench Pro vanilla: 1.20 before, 2.42 after, 3.62 total. SWE-bench Pro FlowPlan: 0.55 before, 0.96 after, 1.51 total. SWE-bench Verified vanilla: 1.15 before, 2.19 after, 3.34 total. SWE-bench Verified FlowPlan: 0.48 before, 0.48 after, 0.96 total.

The trajectory analysis is the most useful part of the paper. In plain Claude Code on Haiku 4.5:

The agent wasn't wasting tokens finding the bug. It was wasting them deciding whether it had fixed it. Without a written plan, "am I done?" has no crisp answer, so the agent reads the file again, runs the tests again, looks at the diff again. A plan turns that into a comparison: did the change I made match the change I meant to make?

There's a striking detail here. The plans weren't usually right. Across 1,090 sessions, the planned graph change matched the reference fix only 39% of the time, and every step agreed with the reference in just 22%. Yet resolution didn't drop. The plan's value was less as a map to the right answer and more as a stopping rule: a definition of done that the agent could check cheaply. We made the case that stopping is the expensive decision in The Stopping Problem; FlowPlan is the first result we've seen that improves the stop without capping steps.

The cheaper model cost more.

The paper stops at tokens. Here's what those tokens cost at list prices.

Haiku 4.5 is $1.25 / $0.10 / $5.00 per million for cache writes, cache reads and output. Sonnet 5 is $2.50 / $0.20 / $10.00. Every line is exactly half. So whatever the mix of reads, writes and output in a session, Haiku costs half as much per token. We assumed 97% cache reads (inside the paper's 96% to 98%), 2% cache writes and 1% output to get dollar figures, but the ratios between the two models don't depend on that assumption.

Horizontal bar chart of estimated list-price cost per resolved issue. SWE-bench Pro: Haiku 4.5 vanilla $1.49, Sonnet 5 vanilla $0.75, Haiku 4.5 with FlowPlan $0.70, Sonnet 5 with FlowPlan $0.54. SWE-bench Verified: Haiku 4.5 vanilla $0.96, Sonnet 5 vanilla $0.37, Haiku 4.5 with FlowPlan $0.31, Sonnet 5 with FlowPlan $0.27.
Horizontal bar chart of estimated list-price cost per resolved issue. SWE-bench Pro: Haiku 4.5 vanilla $1.49, Sonnet 5 vanilla $0.75, Haiku 4.5 with FlowPlan $0.70, Sonnet 5 with FlowPlan $0.54. SWE-bench Verified: Haiku 4.5 vanilla $0.96, Sonnet 5 vanilla $0.37, Haiku 4.5 with FlowPlan $0.31, Sonnet 5 with FlowPlan $0.27.
Estimated costPer sessionPer resolved issue
SWE-bench Pro
Haiku 4.5, vanilla$0.64$1.49
Sonnet 5, vanilla$0.40$0.75
Haiku 4.5 + FlowPlan$0.30$0.70
Sonnet 5 + FlowPlan$0.29$0.54
SWE-bench Verified
Haiku 4.5, vanilla$0.59$0.96
Sonnet 5, vanilla$0.28$0.37
Haiku 4.5 + FlowPlan$0.19$0.31
Sonnet 5 + FlowPlan$0.20$0.27

FlowPlan rows hold each setting's baseline resolve rate, since the paper found no significant change.

Read it from the top. The model that costs half as much per token cost twice as much per fix on SWE-bench Pro, and 2.6x as much on Verified. It used 3.2x and 4.3x the tokens, and it solved fewer issues, so you pay for its failures too. On SecBench, where sessions are short, the order flips back: Haiku 4.5 used only 1.13x Sonnet's tokens and came out about a quarter cheaper per fix.

Then add FlowPlan. Haiku's cost per fix falls by more than half, below plain Sonnet 5 on both benchmarks ($0.70 vs $0.75, $0.31 vs $0.37). Sonnet with FlowPlan is still cheapest, but the gap shrinks from 2x to 1.3x on Pro and to 1.1x on Verified. The cheap model wasn't overpriced. It was under-scaffolded: it lacked a way to know when it was done, and paid for that in re-reads.

This is the same lesson we keep finding from different angles. A cheaper model that needs more turns can cost more, as in Cheaper on Paper and The Retry Tax. Agents are mostly re-reading their own context, as in Mostly Rereading. FlowPlan puts a clean number on how much of that is the verification loop, and shows that a structural change to the loop beats both a cheaper model and a step cap.

Two cautions. These are 2026's older models: Haiku 4.5 and Sonnet 5, not Haiku 5.5 or Sonnet 5.5. Haiku 5.5 is a tenth of Haiku 4.5's price below 100K tokens but bills 5x past that line (details), and long agent sessions cross that line. We don't know how much Haiku 5.5 loops. And each method ran once per issue, on one agent and one provider, so the authors are explicit that this doesn't prove generalization.

Plan first in Claude Code today.

FlowPlan builds real CFGs and DFGs, and its code isn't something you install in your agent today. But its core idea, a written plan as the definition of done, is something you can approximate with a few lines in CLAUDE.md (or AGENTS.md for Codex). This is our approximation, not the paper's method, and you should measure it on your own repository before trusting it.

## Fixing a bug or making a scoped change

Before editing:
1. Name the function(s) you will change. Read only those, plus direct callers if needed.
2. Write a PLAN of at most 5 lines, in structural terms:
   - which branch, condition, call or return value changes, and how
   - which test will show the fix (one test, by name)

After editing:
3. Compare `git diff` against the PLAN. Do not re-read whole files.
   - If the diff matches the plan: run the one test named in the plan.
   - If it doesn't: say what differs, then fix the plan or the code.
4. Stop when the diff matches the plan and the named test passes.
   Run the wider suite once at the end, not after every edit.

Three things make it work:

If you use subagents, this matters even more for the cheap ones. The model you delegate small fixes to is exactly the one FlowPlan helped most.

Price your agent per fix, not per token.

costfix.py turns a session's token count and a resolve rate into a cost per resolved issue. Swap in your own models, token counts and pass rates.

"""costfix.py: price a coding agent per resolved issue, not per token.
Anthropic list prices, $ per million tokens, November 15, 2026."""
RATES = {  # 5-min cache write, cache read, output
    "haiku-4.5":  (1.25, 0.10, 5.00),
    "sonnet-5":   (2.50, 0.20, 10.00),
    "sonnet-5.5": (2.50, 0.10, 10.00),
}
MIX = {"read": 0.97, "write": 0.02, "output": 0.01}  # share of total tokens

def per_session(model, tokens):
    write, read, out = RATES[model]
    blended = MIX["read"] * read + MIX["write"] * write + MIX["output"] * out
    return tokens * blended / 1e6

# (label, model, mean tokens per session, resolve rate)
RUNS = [
    ("Haiku 4.5, vanilla",   "haiku-4.5", 3_715_000, 0.430),
    ("Sonnet 5, vanilla",    "sonnet-5",  1_152_000, 0.525),
    ("Haiku 4.5 + FlowPlan", "haiku-4.5", 3_715_000 * 0.47, 0.430),
    ("Sonnet 5 + FlowPlan",  "sonnet-5",  1_152_000 * 0.72, 0.525),
]
for label, model, tokens, resolved in RUNS:
    cost = per_session(model, tokens)
    print(f"{label:22} {tokens/1e6:5.2f}M tokens  ${cost:.2f}/session  ${cost/resolved:.2f}/fix")

It prints:

Haiku 4.5, vanilla      3.71M tokens  $0.64/session  $1.49/fix
Sonnet 5, vanilla       1.15M tokens  $0.40/session  $0.75/fix
Haiku 4.5 + FlowPlan    1.75M tokens  $0.30/session  $0.70/fix
Sonnet 5 + FlowPlan     0.83M tokens  $0.29/session  $0.54/fix

To get your own token counts, `npx nadir-receipt` reads your local Claude Code and Codex history, prices it at API list prices, and splits it into re-reading context, adding context and answers. If re-reading dominates and your sessions run long after the first edit, you have FlowPlan's problem. It runs locally and makes no network calls; details are on the receipt page.

What this means for choosing models.

The usual way to cut an agent bill is to pick a cheaper model. FlowPlan shows why that can backfire: price per token is a property of the model, but tokens per fix is a property of the model and the loop together. Change the loop and the cheapest model for the job can change too.

So the useful question is never "which model is cheapest?" It's "which model, with this scaffold, on this kind of task, gets it done for the least?" Short, well-scoped fixes with a clear test: a cheap model with a plan-first loop. Long investigations where the model can't tell when it's done: a stronger model may be cheaper per fix even at twice the token price.

Where Nadir fits.

That per-task choice is the one Nadir Auto makes in Claude Code and Codex. Before each turn it asks for a model, keeps the model you configured as the quality fallback and cost ceiling, and checks what a switch would cost in cache re-writes before moving you. It writes a local receipt for every turn, so you can compare what you'd spend per finished task, not per token. It works without a Nadir key on the anonymous decision quota, and inference stays on your own provider account.

For teams, Nadir Lens shows coding-agent spend by team and member, cache economics and agent loops, which is where a long post-edit verification loop shows up first.

We don't publish a savings rate. Measure your own loops first: start with How to Reduce Claude Code Costs, then try the plan-first rules above on a week of real tickets and compare the receipts.

More on agents

Pages on this site

Machine-readable summaries of this site: llms.txt and llms-full.txt.