Skip to content
←Back to Open Source

OPEN SOURCE DEEP DIVE

Agent HarnessMicrosoftContext ManagementBitter Lesson

FreeHand: the harness that lets the model decide

Microsoft Research's open-source agent harness: a ~200-word descriptive prompt, one bash tool, a transcript the model edits itself, and a per-turn meter for context, cost and time. The authors report the highest score and lowest cost in all 11 settings (five benchmarks with three frontier models); with weaker models the order reverses. No sandbox, no approval prompt, alpha — run untrusted code in a container or VM.

microsoft/FreeHand490PythonMIT13 min read

What FreeHand Is

FreeHand (CLI name freehand, PyPI package freehand-ai) is an agent harness open-sourced by Microsoft Research under MIT, written mostly in Python, with the repository created on November 17, 2026 and currently labeled alpha. It ships with a paper, Freehand: The Bitter Lesson Comes to Agent Harnesses (arXiv:2612.02442), which reached #1 Paper of the Day and #2 Trending Paper on Hugging Face Daily Papers in December 2026. The project belongs to Microsoft Research's AgentOpt series — SkillLens, SkillOpt, Resource2Skill, EnvOpt and EvalOpt each tackle one part of an agent system; FreeHand tackles the runtime the model stands on.

The design fits in one sentence: give a frontier model a purely descriptive runtime description of about 200 words, one bash tool, a transcript it can edit itself, and a meter that reports context size, tokens, cost and elapsed time after every turn — then let the model decide everything else. The authors report that against Codex, Claude Code, Gemini CLI, OpenCode, Pi and DeepSeek Harness, across 11 settings (five benchmarks with three frontier model families), FreeHand scored highest and cost least in every one, with the shortest mean time per task. The same README states the flip side plainly: with weaker models the order reverses and traditional harnesses do better.

The Bitter Lesson, Applied to the Runtime Layer

The README's starting point is Sutton's Bitter Lesson: knowledge built into AI systems helps at first and is eventually outgrown by general methods. The authors move that claim from model weights to the harness. Mainstream harnesses decide a great deal before the model ever sees the task: long system prompts prescribe how to approach it, dozens of preset tools fix how to act, fixed timeouts fix how long commands run, and threshold-triggered compaction decides what stays in memory. For weaker models these presets are a crutch; for frontier models they become a cage. FreeHand keeps one rule: give the model a shell, its own memory, and a meter, and let it decide everything else.

Mainstream harnesses give the model detailed instructions, 20+ preset tools, runtime reminders and auto-compaction at a fixed threshold; FreeHand gives a ~200-word runtime description, one bash tool with model-set timeouts, and a history the model prunes itself
The official comparison: mainstream harnesses (Codex, Claude Code, Gemini CLI, OpenCode, Pi) preset instructions, tools, reminders and compaction thresholds; FreeHand supplies a descriptive prompt, one bash tool, and model-managed history.

The four decision points, translated from the README's table:

DecisionTypical harnessFreeHand
How to approach the task (strategy)Rules, workflows and reminders in a long system promptA purely descriptive runtime prompt, with no rules
What tools to use (execution)Dozens of pre-designed toolsOne bash tool, from which the model builds what the task needs
How long a command runs (execution)Fixed timeouts and poll intervalsThe model sets each command's timeout and can run jobs detached
What stays in context (memory)Automatic compaction at a fixed thresholdThe model manages its own context at runtime

A 200-Word Prompt and One Bash Tool

The system prompt is src/freehand/prompt.md in the repository: seven lines. Before the task begins the model sees about 0.35K tokens and one tool. It opens like this:

You are a coding agent. You run inside a minimal framework: one loop that sends this conversation to you, executes the tools you call, and appends their results. Nothing else is decided for you. How you approach the task, how you use your context, and so on are all yours to manage. ...

Tool: bash.

Your editable context is stored in {transcript_path}. The framework writes it after every turn. You can edit it to remove, shorten or reorganize anything; if the file changes, your version is what gets sent next. ...

Note the wording: it describes what the framework does (send the conversation, execute tools, append results) and never prescribes how the model should work. The only asks are efficiency and accuracy, plus how to finish — a reply without a tool call ends the task, so that reply must say what was produced and where.

The single bash tool carries a few engineering details worth recording (from runtime/agent.py). Commands run as bash -lc in the configured workdir and return combined stdout+stderr with the exit code. The timeout is not a global constant: the model passes timeout_s per call, and the whole process group is killed when it expires. For long jobs the prompt teaches nohup CMD > LOG 2>&1 & and reading the log later. The tool schema also requires a description parameter — a clear, active-voice, plain-language account of what the command does, never an echo of the command text or file paths, because the human often reads only that description. Over-long tool output is truncated in the middle of the transcript, with the full text saved under log/outputs/. The loop has two hard stops: max_turns and max_cost_usd.

The Model Manages Its Own Context; the Meter Reports Every Turn

Context management is FreeHand's most distinctive move. The conversation transcript is a file the framework writes after every turn, and the model may edit it directly — remove, shorten or reorganize anything. If the file changes, the model's version is what gets sent next. To look at an image, it adds the image as an image part to the transcript and sees it on the next turn. This hands the question "what is worth remembering" back from the framework's compaction algorithm to the model.

After each turn the framework appends one status line (an example reading constructed in the source's format):

[harness] turn 12 | context 48,213 tokens | total in 312,450 (cached 287,900) out 18,320 | $2.41 | 14.6 min elapsed

Context size, cumulative input (with the cached share), output, cost and elapsed time are visible to the model every turn, so "how much budget is left" becomes an object it can reason about. The product turns this into a visible event as well: whenever the model shrinks its own context, the context bar in the terminal footer moves to a center stage and plays a "slam" animation (meter.py hard-codes a 30 fps keyframe plan), and a line stays in the activity log. Automatic compaction exists but is opt-in and off by default: when enabled it runs provider-neutral rolling summaries, keeps recent messages intact, and its summarization prompt explicitly says to summarize only what is present in the input and never invent file operations.

Results: A Clean Sweep Across 11 Settings — Frontier Models Only

The headline result in the README: five benchmarks (Terminal-Bench 4, Terminal-Bench Science, Agents' Last Exam, OSWorld 2.1, AutomationBench) with three frontier models (GPT-6-astra, Claude Opus 5.5, Gemini 4 Carbon), 11 settings in total. FreeHand had the highest score and the lowest cost in every one, and the shortest mean time per task. Against the first-party harnesses it scored 5.1 points higher at 49% lower cost; in a controlled side-by-side rerun on the same machines and API endpoints, each of the other harnesses took 17–62% longer. It also beat OpenCode, Pi, DeepSeek Harness and the bash-only mini-swe-agent. Averaged over the five benchmarks with GPT-6-astra and Claude Opus 5.5: best mean score 63.2%, lowest mean cost per task $3.23, fastest mean normalized time per task 31.7 minutes.

FreeHand versus first-party harnesses, OpenCode, Pi and DeepSeek Harness, averaged over five benchmarks with GPT-6-astra and Claude Opus 5.5: best mean score 63.2%, lowest mean cost per task $3.23, fastest mean normalized time 31.7 minutes
The official results chart (GPT-6-astra and Claude Opus 5.5, five-benchmark averages): score, cost per task and normalized time all favor FreeHand.

The per-setting numbers from the README table (score · cost per task):

BenchmarkModelFreeHandFirst-party harness
Terminal-Bench 4GPT-6-astra57.1% · $3.12Codex 54.6% · $5.88
Claude Opus 5.561.9% · $3.38Claude Code 54.9% · $4.91
Gemini 4 Carbon57.1% · $8.76Gemini CLI 49.5% · $13.72
Terminal-Bench ScienceGPT-6-astra63.8% · $7.71Codex 58.1% · $12.99
Claude Opus 5.555.2% · $8.16Claude Code 54.3% · $12.86
Agents' Last ExamGPT-6-astra67.5% · $1.92Codex 63.6% · $4.45
Claude Opus 5.566.5% · $1.16Claude Code 62.2% · $2.29
OSWorld 2.1GPT-6-astra76.2% · $3.96Codex 68.3% · $14.94
Claude Opus 5.580.1% · $2.09Claude Code 74.9% · $7.49
AutomationBenchGPT-6-astra49.5% · $0.56Codex 44.8% · $0.89
Claude Opus 5.554.4% · $0.19Claude Code 47.9% · $0.27

The reversal has numbers too. On Terminal-Bench 4 with lower-tier models, the first-party harness scores higher: GPT-6 Sol with Codex 34.9% vs. FreeHand 29.2%; Claude Sonnet 5.5 with Claude Code 41.6% vs. 34.9%; DeepSeek V4.1 Flash with DeepSeek Harness 28.9% vs. 23.8%. The authors' framing is direct: FreeHand is built for frontier models, and with a smaller model that model's first-party harness may serve you better. This is a boundary, not a footnote — "leave the decisions to the model" presupposes a model that makes them well.

The Human-Facing Side Is Complete

The model-facing side stays small on purpose; the human-facing side is fully built. Terminal, browser (freehand web) and the desktop app (beta) share the same sessions and settings, so a session started in one continues in another. Streaming Markdown, interrupt, session resume, per-turn undo, model switching mid-session, cost and context display, and export to a self-contained HTML page are all there. A few concrete mechanisms:

Skills use the Agent Skills format (agentskills.io): a directory with a SKILL.md opening with name and description, placed in ~/.freehand/skills/ or, in trusted folders, the repository's .agents/skills/ and .freehand/skills/. Only each skill's name, description and path sit in context; the model reads the file itself when a task matches, so a skill ecosystem does not inflate the system prompt. MCP does not add tools either: servers are reached through bash commands (freehand mcp call ...), a session is told only the server names and the tools/call commands, and tool descriptions enter context only when the model asks for them. Server-initiated requests (sampling, roots, elicitation) are declined, and a repository cannot add servers.

Mid-turn steering has a notable detail: with the GPT-6 family at OpenAI, the interactive session and browser use the Responses API's WebSocket mode and deliver your message into the response the model is writing (response.steer). The model finishes the item it is on and continues in a new response that carries your message, so it changes course without first finishing the whole turn. Headless runs (freehand -p) put activity on stderr and the final summary on stdout; with --json, stdout carries one event per line (session/model_call/text/tool_start/tool_end/context_edit/retry/result, schema 1), and exit codes 0/1/2/130 each have defined meanings. freehand stats reads Codex and Claude Code usage from their local logs and shows your last 7 days of tokens next to theirs.

Security: The Boundary Is Drawn Outside

Read this section before adopting it. FreeHand has no sandbox and no approval prompt: every command the model runs executes with your account's permissions — your files, network, credentials (SSH keys, git, cloud CLIs) and environment variables — in the terminal, the browser and headless runs alike, and nothing asks first. The official formulation: you draw the boundary around FreeHand, and inside it every decision is the model's. For code you do not trust, use a container or a VM (docs/container.md provides a ready Dockerfile).

The mitigations it does have each cover a specific thing, and the distinctions matter. Folder trust decides exactly one thing: whether that folder's AGENTS.md/CLAUDE.md and project skills load into the session's first message; it does not limit what commands can do. A pre_bash hook sees every command before it runs and can refuse it — that is where your own policy goes (for example, no git push). shell_environment_policy can keep *KEY*/*SECRET*/*TOKEN* variables out of the command environment. Undo is a convenience, not a backup: per-turn snapshots cover only files inside the working directory that are not gitignored and not over 1 MB; anything sent over the network, anything outside the directory, and any git push cannot be taken back. Credentials live in ~/.freehand/auth.json (mode 0600), but commands run as you and can read it too; sessions are plain text containing everything the model saw. The web interface listens on 127.0.0.1 only and requires the token in the address it prints. There is no telemetry; the only exceptions are favicons for public links in the web/desktop interfaces via Google's service (private hosts, IPs and major code hosts are never sent), the manual models --sync reading the models.dev catalog, and desktop release builds checking GitHub Releases for updates. When a provider's safety classifier stops a response, nothing from it is kept or run, and the request is not retried on another model.

Install, Platforms and Providers

curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh
# or: pip install freehand-ai   (Python 3.10+)
freehand login            # ChatGPT Plus/Pro sign-in, or freehand login openai | anthropic for an API key
cd your/project && freehand

Supported platforms are macOS and Linux, including Linux under WSL2; native Windows is marked coming soon. The desktop app is an unsigned preview (macOS Apple Silicon/Intel, Linux x64); on macOS, clear the quarantine attribute once with xattr -cr /Applications/Freehand.app before opening. Four provider paths: OpenAI Responses (default, ChatGPT subscription or API key), Anthropic Messages (API key only — Claude subscriptions cannot be used), any OpenAI-compatible Chat Completions endpoint, and gateways such as LiteLLM. The cost display has an honest detail: prices come from a built-in list-price table, a model the table does not know shows no cost rather than a wrong one, and with a ChatGPT sign-in the figure is what the tokens would cost at API prices, not what you are charged.

Boundaries and What to Judge for Yourself

First, every result comes from the authors' own runs — the README's wording is "in every setting we ran." We have not reproduced them, and this site has no independent benchmark. Scores in the harness domain are a product of model × runtime; change the model or the version and the conclusion may change. The paper and docs/benchmarks.md provide a Harbor recipe, and the benchmark adapter even fixes flat prices ($10/$1/$50 per million input/cached/output tokens) so runs stay comparable. Second, the frontier-model dependency is a design boundary: if you only have mid-tier models, the README's own numbers advise using their first-party harnesses. Third, alpha plus no sandbox is a double reminder — execution is fully delegated to the model, and a container or VM is the officially recommended way to run it, not optional hardening. Fourth, the repository was created on November 17, 2026; stars and ecosystem are early. The engineering care shows (a stdlib-only runtime that runs on Python 3.9 so it can be copied into task containers as is), but long-term maintenance and community size remain to be seen. We file it under the harness domain because it pushes the question "how much should the runtime decide for the model" to one extreme and backs it with checkable comparative numbers — not because its conclusions are beyond further verification.

Related Projects

NousResearch/hermes-agentMIT

Hermes Agent: the open-source agent that turns self-improvement into a closed learning loop

The self-improving agent from Nous Research (248k+ stars). Its learning loop has five mechanisms: periodic memory nudges, autonomous skill creation after tasks, skills that self-improve in use, FTS5 session search with LLM summarization, and Honcho user modeling. One TUI, seven terminal backends (local/Docker/SSH/Singularity/Modal/Daytona/Vercel Sandbox), six chat platforms from a single gateway, no model lock-in. It doubles as a trajectory data-production apparatus. Self-improvement is falsifiable and no controlled experiment has been run, so this is graded as needing reproduction.

Agent HarnessSelf-Improving Agents
deepseek-ai/deepseek-harnessMIT

DeepSeek Harness: the open-source agent runtime where everything is a plugin

DeepSeek AI's open-source agent harness (CLI dsh, MIT, 233k+ stars). The kernel provides only plugin-system semantics; tools, surfaces and model access all attach as plugins, on top of Cordis' paradigm for spatiotemporal composability (arXiv:2608.25512). It is in developer preview with an explicit warning about compatibility-breaking changes, and SAFETY.md is required reading before you run it. Not benchmarked yet, so this entry is graded as needing reproduction.

Agent HarnessPlugin Architecture
earendil-works/piMIT

Pi: a layered agent harness monorepo

Pi Agent Harness (formerly badlogic/pi-mono; 108k+ stars, MIT/TypeScript). Not one CLI but layered packages usable on their own: pi-coding-agent (interactive coding agent), pi-agent-core (runtime with tool calling and state), pi-ai (unified multi-provider LLM API), plus chord composition runtime, pi-telemetry contracts, pi-durable persistence and pi-tui differential terminal rendering. The README states plainly that there is no built-in permission system and offers micro-VM / Docker / sandbox paths instead. Not independently benchmarked; graded needs-reproduction.

Agent HarnessCoding Agent
JuliusBrussee/cavemanNOASSERTION

Caveman: The Token-Cutting Skill, Proxy and Middleware for Coding Agents

A MIT rule file makes agents talk like cavemen (code and errors never shortened), a local Go proxy compresses what agents read before each call with byte-exact originals recoverable, and middleware brings the same to your own app. JetBrains' 86-task A/B: -8.5% output tokens, quality flat; the repo's pinned 54-run suite: -33.2% input tokens, 18/18 checks passed.

Token OptimizationAgent Harness

As an Amazon Associate, we earn from qualifying purchases.