Two harnesses, one model, and a 20-point gap between them. That was the number that made me rethink Cake's prompt system.
It comes from an audit of Terminal-Bench this year: when the benchmark was repaired to 2.1, accuracy moved more than ten points and leaderboard positions shifted by up to three ranks. The side result is what got me. Extending the wall-clock limit alone closed a 20-point gap between harnesses on one model and shrank a 30-point gap to 5 on another, on the same model and the same tasks. The only thing that changed was a timeout.
A second paper did the controlled version: 35 sequential releases of the Qwen Code CLI, model held fixed, 50 SWE-bench Verified tasks per release, each run twice. Quality moved across releases, and the authors trace individual pull requests to measured quality shifts. Their opening line is that people report regressions after harness updates and then blame the model.
That's why I care: I can't edit the model, and I can edit the thing around it.
The short version
| Rule | What the evidence says | How solid |
|---|---|---|
| 1. Context is a budget | All 18 models tested, frontier ones included, got less reliable as the input grew | strong |
| 2. Mechanisms beat prose | 22.4% of 49 SWE-bench Verified tasks accept a patch that behaves differently from the gold patch, 57.8% against a stronger attacker | strong |
| 3. Instructions get followed, repository overviews don't | No general gain in task success from AGENTS.md files, at more than 20% higher inference cost |
strong, two studies agree |
| 4. Keep the prefix stable | A cache write costs 1.25× base input, a read 0.1×, and one changed character at the front throws away everything after it | documented by the vendor |
| 5. Tool descriptions are an API | 97.1% of 856 descriptions across 103 MCP servers had at least one defect; completeness gained a median 5.85 points of task success | strong |
| 6. "Done" means a check ran | Every frontier agent saturates the visible tests in SpecBench while the held-out gap grows 28 points per tenfold of task length | strong |
| 7. Delegate for isolation | Subagents pay off where a trajectory has sparse bridge edges and stop paying when the work is coupled | one study, directional |
| 8. Write decisions down | Compaction dropped rules about how to work about six times more often than specs of what to build | one study, directional |
| 9. Measure before you change a prompt | 87.7% agreement between two identical runs, so one task in eight flips | one study, directional |
| Retracted: keep the diff minimal | 61% of the extra edits on SWE-bench Verified were tests, 13% documentation, and agent code was at least as necessary as human code (0.887 vs 0.864) | strong, 7,660 trajectories |
I had Cake do the reading: 30 papers and engineering posts, the two repositories worth cloning, and a measurement of what Cake itself sends to a model before it proposed anything. It came back with a source table, a draft design, and three corrections to claims I had already started repeating. Two of them are in here, along with the rules and how much weight I think each one carries.
1. Context is a budget, not a bucket
Chroma tested 18 models, frontier ones included, on tasks as simple as pulling a fact out of a long input and repeating words back. Every model got less reliable as the input grew, and not in a tidy curve. Anthropic's post on context engineering makes the same point from the other side: there is an attention budget, and every token spends some of it.
Real agent instructions are nowhere near minimal. AgentIF, built from 50 production agents, found prompts averaging 1,723 words, up to 15,630, with 11.9 constraints on average. I read that as a warning, not as a target.
2. Mechanisms beat prose
An audit of code-RL environments found that 22.4% of 49 sampled SWE-bench Verified tasks accept a patch that behaves differently from the gold patch. That was checked in Docker, not estimated. Against a stronger attacker it was 57.8%, and models passed the hackable tasks 28.6 points more often than matched tasks of the same difficulty.
A companion paper on the verification horizon argues the old intuition has flipped for coding agents: verifying a solution is now harder than producing one, and every verifier is a proxy for what somebody actually wanted.
So when I catch myself writing "never claim something works without checking", I stop and ask what would enforce it. A sentence in a prompt is a wish. What I want is something that fails when the model is wrong.
3. Instructions get followed, repository overviews don't
An evaluation of AGENTS.md files, over SWE-bench tasks and repositories with developer-written context files, found no general improvement in task success, at more than 20% higher inference cost. Instructions inside those files were followed well. Repository overviews, the "here's what this codebase is about" paragraphs that every guide recommends, were not helpful.
A second, independent ablation of context files puts a bound on it: across two agents and 288 graded runs, the context-injection strategy didn't move correctness by more than 10 to 15 points, and the authors argue that agents fail on implementation skill, not on missing repository knowledge.
Context files are still worth having for the things a model cannot infer: the command that runs the tests, the two directories that look alike and aren't, the convention that differs from the obvious one. I don't use them as a tour of the code.
4. Keep the prefix stable, and keep the volatile stuff out of it
Caching is exact-prefix on every provider I looked at. Anthropic's prompt caching docs have the clearest numbers: a cache write costs 1.25× the base input price with a five-minute TTL, 2× with an hour, a read costs 0.1×, and one changed character at the front invalidates everything after it.
That killed a design I liked. Cake froze the system prompt per conversation to protect the cache, which also meant a defect in that prompt could not be fixed inside a running conversation. You had to start a new one. Freezing the conversation to save a cache write is a bad trade: composing once per turn and keeping clocks and counters out of the prefix gets the same cache behaviour without the lock-in.
5. Tool descriptions are an API, not documentation
An audit of tool descriptions covering 856 descriptions across 103 MCP servers found 97.1% with at least one defect, and 56% that didn't say what the tool was for. Making descriptions complete along six components gained a median 5.85 percentage points of task success. It also raised execution steps by 67% and made things worse in one case out of six, which is the part people skip when they quote the first number.
Wording alone distorts tool choice: edited descriptions got more than ten times the usage of the originals across 17 models. If a one-line edit reorders tool choice by an order of magnitude, that text is load-bearing whether or not you treat it that way.
I write to a fixed shape now: purpose, when to use it, when not to, what it returns, what failure looks like, the limits. Then I test it and keep it short. Completeness helps, but length costs steps.
6. "Done" means a check ran, and every check is a proxy
In SpecBench every frontier agent saturates the visible test suite while a gap persists against held-out tests that compose the same features, and that gap grows by 28 percentage points for every tenfold increase in task length.
It gets worse. In the reward-hack audit above, LLM-written repair tests failed on the gold patch 61.9% of the time, and an LLM judge was wrong on 38% of the verdicts that execution could check.
A check you ran is better evidence than a sentence you wrote, and a check you wrote after seeing the answer is weaker than one that existed before. Who wrote the check and when says more than the word verified.
7. Delegate for isolation, not seniority
The manager handing work to a junior is the popular picture, and the work on when subagents pay off points elsewhere. It models a trajectory as a dependency graph and finds that subagents pay when the graph has sparse bridge edges, pieces that genuinely don't need each other, and stop paying when the work is tightly coupled. Scaling the pool or the recursion depth didn't reliably help either.
Running a reusable procedure as a subagent in a fresh context beats loading its instructions into the main one, but only when the procedure has a clear input/output contract. Otherwise the coordination costs eat the gain.
The case I keep coming back to is verification rather than delegation of work. A child that didn't write the code and can't edit it is a different kind of evidence than a re-read by the agent that just convinced itself.
8. Write decisions down, because compaction keeps the goal and drops the rules
Five compaction strategies inside a fixed scaffold, three frontier models, three long-horizon benchmarks: none beat plain self-summarisation, including one that wrote the pre-compaction context to disk. Strategies that discarded more cost some models up to 20 points while leaving others untouched.
On real user sessions, compaction dropped instructions about how the agent should work and what it should not do about six times more often than specifications of what to build. The first summary on one benchmark had already lost about a third of the task's anti-cheating rules.
I nearly overclaimed this. The same paper tests whether dropped rules cause violations, and finds dropped rules broken about twice as often, but the events are rare and the difference isn't significant. The authors explicitly don't claim causation. What holds is the descriptive part: summaries keep the objective and lose the working rules. So the rules go somewhere that survives the summary.
9. Measure before you change a prompt
Prompt changes are small and noisy. The harness study above got 87.7% run-to-run agreement with each task run twice, so roughly one task in eight flips between two identical runs. A 3-point prompt improvement is invisible against that noise unless you pair runs, repeat them and count.
The first thing I built after the reading was an event table, not a prompt.
The rule I had to retract
"Keep the diff minimal" was on this list, and it's wrong, or at least it's the wrong sentence.
A study that replayed 7,660 resolved trajectories from 18 frontier models reverted each patch unit to see whether it was needed. Agent patches are bigger than developers' patches, but on SWE-bench Verified the extra edits were 61% tests and 13% documentation, and the agents' code was on average at least as necessary as the humans' (0.887 vs 0.864). About 11% of an agent's code units were unnecessary, and 89% of those changed behaviour. Code necessity was unrelated to resolve rate on SWE-bench Verified and negatively correlated on DeepSWE, so minimality doesn't buy correctness.
The rule I keep instead is "no behaviour change nobody asked for", plus don't delete your own tests to look tidy. Tests are the part of the patch that makes the claim checkable.
What this means for long sessions, in any agent
None of this is Cake-specific. If you run Claude Code, Codex, Cursor, Aider or Pi all day, these are the moves I'd make before touching a prompt.
- One goal per session. A session that fixes a bug and then adds a feature has two contexts fighting for the same budget, and the summary will pick one.
- Read narrowly: the function, the call sites, the failing test. Whole files, whole
lstrees and whole command output are how a 200k window turns into 20k of usable attention. - Keep bulk output out. If a command prints six thousand lines, redirect it and grep the file. The model pays for every line it reads and remembers none of them better than a summary would.
- Write decisions down as you make them. Not a plan at the start, a running note of what you settled, what you ruled out and why. That's the thing compaction preserves worst.
- Compact at natural breaks, between tasks and after a commit. Compacting mid-thought is how the agent comes back with the wrong idea about what it was doing.
- Restart after a dead end. If three attempts have failed in the same wrong direction, the context is now full of the wrong direction, and a fresh session with a two-paragraph summary beats another twenty turns of trying harder.
- Don't trust a "done" you didn't see checked. Ask which command proves it. If there isn't one, that's the finding.
What Cake does with this now
Cake is a self-hosted agent harness built on Pi: a web chat, a container per environment, projects, agent profiles. It's pre-0.1, single-user, and I'm the only one who has run it in anger, so take this as what is working for me rather than a shipped product claim. There is a project page and install docs, and Cake keeps its conversations on pi-durable, which runs on Postgres since I wrote a Postgres backend for chord and pi-durable.
Running today
- A reminder on every user message lists what the agent can use: instructions, tools, sub agents, skills, the container's capabilities, the current todo list and a pinned state block. It is split into a stable half and a volatile half, and when the offer hasn't changed, one line replaces the whole account. That split is the single best thing in the codebase; it came from noticing that re-sending an unchanged tool list every turn is pure cost.
- Checks behind
todo_complete: an item can carry acceptance checks, and when the agent says an item is done, the harness runs them in the container. A failing run leaves the item in progress with the output attached, so the model cannot mark it done by asserting it. - Grants per agent. Tools, skills and MCP servers are granted per profile, and there is a read-only selection for verification children. A child that can't write is a different kind of reviewer than one that can.
- A charter for the coding agent. The default Build agent had no task instructions at all, because the seed didn't set the field while the Plan agent six lines below had 350 characters. That's fixed: the agent that writes code now gets a paragraph on reading before writing, on not changing behaviour nobody asked for, on proving it with the project's check, and on the git rules.
- A prompt registry under
apps/backend/src/prompts/, with a compose step and snapshot fixtures that pin the output to what it was before the refactor. Agent instructions and tool descriptions stay where they belong, in editable rows and in the tool schemas, and the prompt became something with an id, a layer and a measured length. - Event recording.
harness_eventsrecords turns, tool calls, prompt composition and check runs: steps, error classes, bytes in and out, whether the reminder was the full account or the digest. Message content isn't stored, only sizes, hashes and closed-vocabulary classes.
Planned, not built yet
- Composing the prompt per turn. The freeze is still in
prompt-snapshot.tsand removing it is a small change, but its caching cost is the first thing the new event table measures, and it lands only if that cost turns out to be irrelevant in practice. - Separating agent, mode and child. Plan is a separate agent whose grants are its role, so every new posture (review, operate, verify by running) needs another seeded agent. I want Plan to be a mode that narrows whatever agent you are already talking to, so a posture is a setting instead of a profile.
- Feature toggles with provenance: turning off, say, the check runner for a project without tests, and seeing exactly which sentence of the prompt came from where. That needs a registry of features with
requiresedges, anexplaincommand and a hash of the resolved set on every turn. - Two gates that decide the rest. A constraint carousel, restating the prohibitions every few turns, comes from a paper whose headline number I could not reproduce from its own tables, whose constraints are formatting rules, and whose policy was delivered once and never repeated, which isn't how Cake works. Observation masking waits on how often conversations actually compact. Both are explicit gates in
docs/harness-telemetry.md: if the digest fires in under 10% of turns, the carousel doesn't get built.
One thing I decided against is rewriting compaction. The compaction prompt belongs to pi-durable, and the evidence says no strategy beats plain self-summarisation. The pinned state block carries the constraints and decisions a summary would drop, and the summariser stays as it is.
Top comments (0)