Microsoft's Freehand Beats Vendor Coding Agents at Half the Cost
Microsoft researchers show frontier coding agents perform better, cheaper, and faster when the harness stops dictating workflows, tools, and memory management.
Takeaways
- Microsoft's Freehand strips agent harnesses to a bash tool, editable JSON transcript, and a cost meter.
- Beats Codex, Claude Code, and Gemini CLI in all 11 settings by 5.1 points at 49% lower cost.
- Cuts cumulative input tokens by 44-91% versus first-party harnesses across five benchmarks.
- On lower-tier models, first-party harnesses still win by 5-7 points: presets are a crutch, not a cage.
- Ablation shows swapping in Codex's prompt and tools alone drops accuracy 3.8 points at 68% higher cost.
- Code and paper are public; models manage memory by editing transcript.json via bash.
Microsoft Research has introduced Freehand, an experimental coding-agent harness built around a short prompt, one bash tool, and model-managed conversation history. A harness is the orchestration layer that supplies tools, instructions, memory policies, and execution rules around a language model. The accompanying research paper reports higher accuracy and lower costs than vendor harnesses when Freehand runs frontier models.
Current coding agents carry substantial orchestration overhead. Codex ships a system prompt spanning thousands of tokens and more than 20 tool entry points. Claude Code injects recurring reminders. Gemini CLI prescribes a research, strategy, and execution lifecycle, with a loop detector activated at turn 30. These choices consume context, shape model behavior, and can add tool calls before the task requires them.
The authors connect their design to the Bitter Lesson, the observation that general methods powered by stronger models tend to overtake hand-engineered rules. Their results suggest that detailed workflows still help lower-tier models, while frontier models perform better with more control over execution and memory.
What the harness adds before work begins
The researchers audited nine production harnesses by reading source code and capturing outbound API payloads. Each product fixed its prompt, tools, and context policy before the model received a task.
| Harness | Static prefix | Tool surface | Context policy |
|---|---|---|---|
| Codex | About 15,100 tokens | 23 callable entry points | Automatic summarization at 90% of the context window |
| Claude Code | About 8,500 tokens | 22 built-in tools | Recurring system reminders |
| DeepSeek Harness | Not specified | 34 tools | Tool outputs pruned above 8,192 characters |
Large static prompts and tool schemas affect every turn in which they remain in context. Workflow rules can also generate planning, polling, summarization, and recovery calls that a model might not need for a given task.
One shell, editable memory
Freehand reduces the model-facing interface to a prompt of roughly 200 words, a single bash function, and a one-line status footer. The footer reports context size, token use, cost, and elapsed time after each turn.
Conversation history is stored in transcript.json using the provider’s native message format. The model can edit that file through bash to remove stale logs, condense completed subtasks, or add new content to its next context. For visual tasks, it can insert a base64-encoded screenshot into the transcript and inspect the image on the following turn.
Five benchmarks, lower bills
The team ran 191 evaluation rounds across five benchmarks and three frontier models: GPT-6-astra, Claude Opus 5.5, and Gemini 4 Carbon. Each model used a high reasoning-effort setting.
| Benchmark | Tasks | Focus |
|---|---|---|
| Terminal-Bench 4 | 63 | Systems and security |
| Terminal-Bench Science | 70 | Scientific computing |
| Agents’ Last Exam | 105 | Research and engineering |
| OSWorld 2.1 | 108 | Ubuntu desktop tasks |
| AutomationBench | 600 | Enterprise workflows |
Across the ten benchmark-model settings involving GPT-6-astra and Claude Opus 5.5, Freehand averaged 63.2% accuracy and $3.23 per task. The first-party harnesses averaged 58.4% and $6.70. Using the paper’s normalized net-runtime measure, Freehand took 31.7 minutes per task and the vendor systems took 33.0 minutes.
| Metric | Freehand | First-party harnesses |
|---|---|---|
| Accuracy | 63.2% | 58.4% |
| Cost per task | $3.23 | $6.70 |
| Normalized runtime | 31.7 minutes | 33.0 minutes |
The paper reports a mean accuracy gain of 5.1 percentage points against vendor harnesses and a 49% reduction in per-task cost. The largest gains reached 7.9 points on OSWorld 2.1 with GPT-6-astra and 7.0 points on Terminal-Bench 4 with Claude Opus 5.5.
Cumulative input tokens fell in all 11 evaluated settings, with reductions ranging from 44% to 91%. On OSWorld 2.1 with GPT-6-astra, input dropped from 12.66 million to 1.11 million tokens. Cumulative input counts the context repeatedly sent across turns, so long prompts and tool schemas compound over an extended run.
The authors attribute the reductions to three design choices: fewer prescribed workflow turns, removal of tool schemas containing 5,000 to 15,000 tokens, and model-controlled context pruning.
Capability changes the best harness
Lower-tier models performed better with the additional structure supplied by first-party systems. On Terminal-Bench 4, Codex led Freehand by 5.7 points with GPT-6 Sol, Claude Code led by 6.7 points with Claude Sonnet 5.5, and DeepSeek Harness led by 5.1 points with DeepSeek V4.1 Flash.
| Model | Leading harness | Margin |
|---|---|---|
| GPT-6 Sol | Codex | 5.7 points |
| Claude Sonnet 5.5 | Claude Code | 6.7 points |
| DeepSeek V4.1 Flash | DeepSeek Harness | 5.1 points |
| GPT-6-astra | Freehand | 2.5 points |
| Claude Opus 5.5 | Freehand | 7.0 points |
| Gemini 4 Carbon | Freehand | 7.6 points |
DeepSeek Harness also trailed Freehand when paired with frontier GPT and Claude models. That cross-harness result supports the paper’s claim that model capability drives the crossover more strongly than the engineering quality of any single vendor system.
An ablation kept Freehand’s execution loop and editable context but substituted Codex’s full system prompt and specialized tools. Accuracy on Agents’ Last Exam fell from 67.5% to 63.7%, while cost rose 68% from $1.92 to $3.23. Terminal-Bench 4 accuracy fell 2.5 points as cost increased 53%. The experiment isolates prescriptive prompts and pre-wrapped tools as major sources of overhead for the frontier models tested.
The loop changes model behavior
Models write task-specific scripts
With raw bash available, frontier models generated scripts tailored to the current task. This approach reduced the need to chain narrowly defined tool calls and allowed one shell process to coordinate several operations.
Workload-aware waits cut polling
On a long optimization task, mini-swe-agent used a fixed 30-second timeout and polled 334 times across 403 calls, costing $70.77. Freehand selected a timeout suited to the workload and waited for as long as 24 minutes in one call. It completed the task in 42 calls for $2.28.
Memory use follows task length
Short AutomationBench workflows averaged about 14 turns, and models left the transcript unchanged on 99.8% of tasks. During multi-hour Terminal-Bench Science runs with Claude Opus 5.5, active context management reduced cumulative input from 24.54 million to 8.92 million tokens, a 64% decrease.
Models edited their context on 78% to 92% of OSWorld 2.1 tasks. Those runs required screenshots, which the model inserted and later removed through the same transcript file.
Shell access sets the security boundary
- Model capability: Lower-tier models remained 5 to 7 points more accurate with first-party harnesses in the reported Terminal-Bench 4 tests. Harness selection should therefore be evaluated for each model tier.
- Execution authority: Unrestricted bash can read files, launch processes, access networks, and invoke available credentials. The paper places enforcement in isolated containers, scoped credentials, filesystem controls, and operating-system permissions.
- Long-running tasks: Freehand ran longer than Codex on Terminal-Bench Science with GPT-6-astra. Codex terminated earlier and recorded lower pass rates. Production trials need explicit limits for elapsed time, tokens, and spend.
- Auditability: A model that can rewrite its transcript can also remove details from its working history. An external append-only event log can preserve commands, outputs, context edits, and billing data for review.
Testing the claim in your stack
A controlled evaluation can reproduce the core design with a small set of components:
- Run the agent in a disposable, isolated environment with one shell tool.
- Use a short system prompt that defines the task interface and safety boundaries.
- Persist provider-native messages in an editable
transcript.jsonfile. - Report context size, token use, cost, and elapsed time after each turn.
- Preserve immutable external logs while allowing the model to edit its working transcript.
- Compare pass rate, cumulative input, cost, runtime, and security outcomes against the existing harness for each target model.
Microsoft publishes the implementation in the Freehand repository and documents the protocol on the project page. The reported results make the harness itself an optimization variable: stronger models may benefit from fewer prescribed steps, fewer tool definitions, and direct control over their working context.