Use case · Context Saving

I pay for 600 test results to fix 1. Pay for the 1.

Context Mode keeps the failing test and the summary, and folds the 599 passing tests into one line. On npm test with 600 tests, 17.0 KB becomes 1.2 KB. A Ruby minitest fix loop on Claude Opus 5.5 cost 61% less.

Your agent runs

600 tests. 1 fails.

Printed17.0 KB
Sent to the model1.2 KB
$ npm test
1 failing: the test and its assertion, as printed
… 599 passing tests folded (599 lines)
then a label: 599 passing tests folded, full output under an id, do NOT re-run the command

The failing test, its assertion and the summary line stay as printed.

Ruby, 401 tests. 1 fails.

Printed16.2 KB
Sent to the model0.7 KB

Sent to the model

  • The failing test and its error
  • The summary line
  • One line for the tests that passed

Kept in your archive

  • All 401 results, word for word

Measured on the test fixtures of the folding A/B, Claude Haiku 4.5.

The agent needs one passing line after all. It asks your archive for it by id.

context-mode-search
{"docid":
 "context-mode-toolcap-<hash>-<length>"}

Sent to the model

  • The lines it asks for

Kept in your archive

  • The full output, under that id

No second test run. The label tells the agent not to run the command again.

Test fix loops, run with and without Context Mode. Cost per task.

Ruby minitest, direct$0.157
Ruby minitest, Context Mode$0.061
Ruby minitest fix loop · Claude Opus 5.5$0.157 → $0.06161% lower8 of 8 pairsnpm test fix loop · Claude Opus 5.5$0.087 → $0.06822% lower15 of 16 pairsnpm test fix loop · Claude Haiku 4.5$0.069 → $0.03253% lower12 of 12 pairs

Your own Anthropic or OpenAI account pays the model. We add no fee on tokens.

The problem

One test fails. You pay tokens for all 600.

The full log goes in

Your agent runs the tests, and the runner's output enters the conversation.

It goes again on every call

The agent sends the whole conversation to the model on each later call, so the passing lines are sent again and again.

The fix loop repeats it

Run the tests, fix the code, run them again. Each run adds one more full log.

How it works

Keep the failure. Fold the passes.

  1. 01Your agent runs the tests

    As usual: npm test, minitest -v or another runner.

  2. 02Context Mode folds the output

    The failing test, its assertion and the summary line stay as printed. Passing tests fold into one counted line.

  3. 03The full log stays in your archive

    The short version names an id. The agent reads any line back with context-mode-search, with no second test run.

Your agentRuns npm test. The runner prints 17.0 KB: 600 tests, 1 failing.
→
Context ModeFolds the output the first time it goes through.
  • Keeps the failing test and its assertion
  • Keeps the summary line
  • Folds 599 passing tests into one line
  • Archives the full 17.0 KB under an id
→
The modelReads 1.2 KB, with the failure in full. Your own account pays for it.
Your agent sends the full test output. Context Mode, in blue, folds the passing tests before the model reads them. The full output stays in your archive.
Proof

The same test fix loop, run twice. Cost per task.

17.0 KB → 1.2 KBnpm test output, 600 tests, 1 failing
61% lowera Ruby minitest fix loop on Claude Opus 5.5, $0.157 to $0.061, 8 of 8 pairs
53% loweran npm test fix loop on Claude Haiku 4.5, $0.069 to $0.032, 12 of 12 pairs
Test outputContext ModeDirect
npm test, 600 tests, 1 failing1.2 KB17.0 KB
Ruby minitest -v, 401 tests, 1 failing0.7 KB16.2 KB
Test fix loop, cost per taskContext ModeDirectLower
Ruby minitest fix loop, Opus 5.5$0.061$0.15761%
npm test fix loop, short, Opus 5.5$0.068$0.08722%
npm test fix loop, Haiku 4.5$0.032$0.06953%

Paired runs at API list price, with the same task success with and without Context Mode. The output sizes come from the test fixtures of the folding A/B. Your own saving depends on your mix of work. Method and sources →

Products used

What this uses.

Context Saving

Folds long tool output before the model reads it. Errors stay in full.

How saving works

The 15 filters, the fold rules and the archive read-back.

Benchmarks

Every paired run, with its evidence file.

Plans

Start free. Your own Anthropic or OpenAI account pays the model. We add no fee on tokens.

Related: Cut agent spend · For developers · Long sessions

Try it on your next test run.

npx @context-mode/cli connects your agents. 1,000 requests free, no card.

Get started free

Your coding agent costs less and remembers your project.

Start free: 1,000 requests, every feature, no card. After you sign in, the console gives you one command to connect Claude Code or Codex.

Read the docs