# Freehand

> Microsoft Research's minimal agent harness that leaves the decisions to the model

- Category: AI Coding / Autonomous Coding Agents
- Language: Python
- Licence: MIT
- Repository: https://github.com/microsoft/FreeHand
- Website: https://microsoft.github.io/FreeHand/
- Canonical page: https://ai-tldr.dev/tools/freehand/
- Updated: 2026-12-01

## In short

Freehand is an open-source agent harness from Microsoft Research, released with the paper "Freehand: The Bitter Lesson Comes to Agent Harnesses" (arXiv:2612.02442). It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Python and licensed MIT. To get started: install.

## Overview

Freehand is an open-source agent harness from Microsoft Research, released with the paper "Freehand: The Bitter Lesson Comes to Agent Harnesses" (arXiv:2612.02442). Its idea is the opposite of most coding agents: instead of detailed instructions, a fixed tool suite, preset timeouts and automatic compaction, Freehand gives a frontier model a runtime prompt of about 200 words, a single `bash` tool and control over its own context, and lets the model decide the rest.

After every turn the model sees a meter with its context size, token usage (including the cached share), cost and elapsed time. It sets its own command timeouts, can start detached jobs, and prunes its own history through bash. Automatic compaction exists but is off by default. The authors argue that fixed harness rules help weaker models but hold frontier models back, and the paper reports that with lower-tier models the first-party harnesses do better again.

In the paper's tests across five domains and three frontier model families, Freehand outscored each model's first-party harness (Codex, Claude Code, Gemini CLI) in all 11 settings, by 5.1 points on average at 49% lower cost. These are the authors' own results. The project is MIT-licensed, written in Python, and marked alpha: it has no sandbox and runs commands with your permissions. It runs on macOS and Linux, with the CLI and web UI also working under WSL2.

## What it does

- A minimal model-facing setup: a ~200-word runtime prompt and one `bash` tool, with command timeouts set by the model and support for detached jobs
- The model manages its own context; automatic compaction is available but off by default
- A per-turn meter showing context size, token usage with cached share, cost and elapsed time
- Three interfaces over the same sessions: a terminal UI, a browser UI (`freehand web`) and a beta desktop app
- Sessions with resume, per-turn undo, interrupt, model switching, streaming Markdown and HTML export
- Headless mode (`freehand -p`) that writes activity to stderr and the final summary to stdout, for scripts and CI
- Works with OpenAI (ChatGPT Plus/Pro sign-in or API key), Anthropic, experimental GitHub Copilot, and any OpenAI-compatible Chat Completions endpoint, including gateways such as LiteLLM

## Getting started

Freehand needs Python 3.10+ on macOS or Linux (WSL2 works for the CLI and web UI). It has no sandbox, so run it in a project you are comfortable letting the model change.

1. Install

   Use the install script, or install the `freehand-ai` package with pip or uv.

```bash
curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh
# or
pip install freehand-ai
# or: uv tool install freehand-ai
```

2. Sign in to a model provider

   OpenAI is the default: sign in with a ChatGPT Plus or Pro plan, or pass an API key. Anthropic is also supported.

```bash
freehand login            # Continue with ChatGPT (Plus or Pro)
freehand login openai     # or an OpenAI API key
freehand login anthropic  # then run: freehand --provider anthropic
```

3. Start a session in your project

   Run Freehand inside the directory you want it to work on. `-c` continues the last session in that directory.

```bash
cd your/project
freehand
freehand -c
```

4. Run it headless or in a browser

   `-p` runs one task without the interactive UI; `freehand web` opens the same sessions in a browser window.

```bash
freehand -p "fix the failing test"
freehand web
```

5. Use another endpoint

   Any OpenAI-compatible Chat Completions API works through the `openai-chat` provider.

```bash
freehand --provider openai-chat --api-base <url> --api-key-env <VAR>
```

## When to use it

- Run a frontier model on long coding, terminal or research tasks with less harness overhead and a lower token bill
- Compare a model's raw ability against first-party harnesses such as Codex or Claude Code on your own tasks
- Script one-shot agent jobs in CI with headless mode, reading the final summary from stdout
- Study harness design: a small, readable baseline for testing which harness rules still help a given model

## Version history

- 2026-12-01: Microsoft Research releases Freehand with its paper and publishes the freehand-ai package on PyPI. The authors report it beats the first-party harnesses of Codex, Claude Code and Gemini CLI in all 11 tested settings at 49% lower cost.
