Use case · Thinking in Code

# My agent opened a 7 MB JSON file and ran out of room. *Now a script reads it. The model reads the answer.*

With Thinking in Code, your agent writes a short script, the script reads the whole file, and only what it prints or returns reaches the model. One question about a 7 MB JSON file came back as 407 bytes, and data analysis cost 64% less on Claude Haiku 4.5.

[Get started free](https://console.context-mode.com/login) [Read the docs](https://context-mode.com/docs/how-saving-works#code-mode)

How many versions of react are on npm?

Fetch tool Shell script Thinking in Code The bill

Fetch tool: a helper model reads the start of the file.

The file **7,011,585 B** A helper model sees **100,000 chars**

A helper model reads

- The first 1.4% of the file

Never read

- The other 98.6%

The answer needs the whole file. The agent sees the start.

Shell script: the agent downloads the file and runs its own script.

```
// the agent writes its own download and script
$ curl -s https://registry.npmjs.org/react -o react.json
$ node count.js
// each command and its output stay in the thread
```

Every later call sends them again.

Thinking in Code: Context Mode runs the script and keeps only its answer.

The script reads **7,011,585 B** The model reads **407 B**

Sent to the model

- The version count (2,959), the first and latest stable release, and their dates

Never sent

- The 7 MB file itself

[Long-Context Data Analysis · Claude Haiku 4.5 **$0.175 → $0.062** *64% lower* lower in 12 of 12 pairs](https://context-mode.com/docs/benchmarks)

The bill: data analysis, cost per task.

Haiku 4.5, direct **$0.175** Haiku 4.5, Context Mode **$0.062** Opus 5.5, direct **$0.223** Opus 5.5, Context Mode **$0.201**

Drawn to scale. Paired runs, 2026-09-29. Correct answers were equal in both arms.

The problem

## The answer is in the file. *The file does not fit.*

**The fetch tool sees the start**

It hands the first 100,000 characters to a helper model: about 1.4% of the 7,011,585-byte `react` registry document.

**A shell script fills the thread**

If the agent writes its own download and script, every command and its output stay in the conversation.

**You pay again on each turn**

Text in the conversation goes back to the model on every later call of the session.

How it works

## The script reads the file. *The model reads the answer.*

1. 01 **The agent writes a script** For example: count the versions in the `react` registry document.
2. 02 **Context Mode runs it** Public pages and APIs run in a sandbox. Files on your machine run as your agent's own shell call.
3. 03 **Only the result comes back** The script read 7,011,585 bytes. The model read 407: the version count (2,959), the first and latest stable release, and their dates.

**1 · Your agent**

asks about a 7 MB file and writes a short script.

**2 · Context Mode**

runs the script, which reads all 7,011,585 bytes. It keeps only what the script prints or returns, and checks hosts if Protect is on.

**3 · The model**

reads the 407-byte answer.

The file never enters the conversation. The model reads only what the script prints or returns.

Proof

## Data analysis, run twice. *Lower cost, same answers.*

**64% lower** cost per task on Claude Haiku 4.5, $0.175 to $0.062, 12 of 12 pairs

**407 bytes** reached the model from a 7,011,585-byte file: one measured query, not a benchmark figure

**$113 less** per 1,000 data-analysis tasks on Haiku 4.5

| Long-Context Data Analysis | Context Mode | Direct | Lower, correct answers |
| --- | --- | --- | --- |
| Claude Haiku 4.5 | $0.062 | $0.175 | 64% · 11 of 12 correct, both arms |
| Claude Opus 5.5 | $0.201 | $0.223 | 10% · 20 of 20 correct, both arms |

Paired runs on 2026-09-29: questions about the `react` and `express` npm registry documents. In earlier runs (2026-09-28), Opus 5.5 going direct often wrote its own script, so the gap is smaller. [Method and sources →](https://context-mode.com/docs/benchmarks#data-analysis)

Products used

## What this *uses.*

**[Thinking in Code](https://context-mode.com/thinking-in-code)**

The agent writes a script; only its result enters the conversation.

**[How saving works](https://context-mode.com/docs/how-saving-works)**

The two tools, the before and after, and why it is safe.

**[Benchmarks](https://context-mode.com/docs/benchmarks)**

The paired runs, with their data and pre-registration.

**Related**

[Context Saving](https://context-mode.com/context-saving) · [Cut agent spend](https://context-mode.com/solutions/cut-agent-spend) · [For developers](https://context-mode.com/solutions/developers)

## Ask about the whole file. *Send the model only the answer.*

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

[Get started free →](https://console.context-mode.com/login) [Read the docs →](https://context-mode.com/docs/how-saving-works#code-mode)
