Metadata-Version: 2.4
Name: freehand-ai
Version: 0.1.1
Summary: An agent harness that leaves the decisions to the model, including what stays in its context.
Author: Microsoft Corporation
License-Expression: MIT
Project-URL: Homepage, https://github.com/microsoft/FreeHand
Project-URL: Issues, https://github.com/microsoft/FreeHand/issues
Keywords: agent,coding-agent,llm,cli,chatgpt,openai,anthropic,claude
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Requires-Dist: prompt_toolkit>=3.0.43
Requires-Dist: rich>=13.7
Requires-Dist: anthropic>=1.13
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pyflakes>=3; extra == "dev"
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="docs/assets/readme-header-dark.svg?v=bold-2">
    <img src="docs/assets/readme-header-light.svg?v=bold-2" alt="Freehand. Give the model a freehand!" width="640">
  </picture>
</p>

<p align="center">
  <a href="https://microsoft.github.io/FreeHand/"><img alt="Project Page" src="https://img.shields.io/badge/project_page-FreeHand-FF8A2A?style=for-the-badge&labelColor=0B0B0C"></a>
  <a href="https://arxiv.org/abs/2612.02442"><img alt="arXiv" src="https://img.shields.io/badge/arXiv-2612.02442-FF4A4A?style=for-the-badge&logo=arxiv&logoColor=white&labelColor=0B0B0C"></a>
  <a href="https://pypi.org/project/freehand-ai/"><img alt="PyPI" src="https://img.shields.io/pypi/v/freehand-ai?style=for-the-badge&logo=pypi&logoColor=white&labelColor=0B0B0C&color=0E9FD8"></a>
  <a href="pyproject.toml"><img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10+-D43DD0?style=for-the-badge&logo=python&logoColor=white&labelColor=0B0B0C"></a>
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-3A78FF?style=for-the-badge&labelColor=0B0B0C"></a>
</p>

<p align="center"><b>English</b> · <a href="README.zh-CN.md">简体中文</a> · <a href="README.ja.md">日本語</a> · <a href="README.ko.md">한국어</a> · <a href="README.fr.md">Français</a> · <a href="README.es.md">Español</a></p>

# Freehand

<!-- agentopt-series-line:start -->
> 🧭 **Freehand is part of the AgentOpt series**, which covers each part of an agent system: [SkillLens](https://microsoft.github.io/SkillLens/) · [SkillOpt](https://microsoft.github.io/SkillOpt/) · [Resource2Skill](https://microsoft.github.io/Resource2Skill/) · [EnvOpt](https://microsoft.github.io/EnvOpt/) · [EvalOpt](https://microsoft.github.io/EvalOpt/) · **Freehand**. See the [AgentOpt series page](https://microsoft.github.io/SkillOpt/agentopt/).
<!-- agentopt-series-line:end -->

<p align="center">
  <a href="https://huggingface.co/papers/2612.02442">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hf-daily-1-dark.svg">
      <img src="docs/assets/hf-daily-1-light.svg" alt="Hugging Face Daily Papers: #1 Paper of the Day" width="212" height="64">
    </picture>
  </a>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <a href="https://huggingface.co/papers/trending">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="docs/assets/hf-trending-2-dark.svg">
      <img src="docs/assets/hf-trending-2-light.svg" alt="Hugging Face: #2 Trending Paper" width="205" height="64">
    </picture>
  </a>
</p>

**An agent harness that leaves the decisions to the model.**

Freehand gives a frontier model a runtime description of about 200 words, one `bash` tool, and control over its own
context. Against Codex, Claude Code, Gemini CLI, OpenCode, Pi and DeepSeek Harness, on five benchmarks with three model
families, it scored highest and cost least in every setting we ran, and it was fastest on average.

**Use it with a frontier model.** Freehand leaves the decisions to the model, so it pays off when the model can make
them well: with weaker models, traditional harnesses still do better ([Results](#results)).

[Quick start](#quick-start) · [Paper](https://arxiv.org/abs/2612.02442) · [Usage](docs/usage.md) · [Gateways](docs/gateway.md) ·
[Benchmarks](docs/benchmarks.md) · [Security](docs/security.md) · [Changelog](CHANGELOG.md)

> Alpha. **Freehand has no sandbox:** the model's commands run with your permissions and nothing asks first. Use a
> container or VM for code you do not trust ([how](docs/container.md)), and read the
> [security model](docs/security.md).

<p align="center">
  <img src="docs/assets/readme-header-benchmarks.png" alt="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) and fastest mean normalized time per task (31.7 minutes).">
</p>

## News

- **[2026.12]** 🏆 **Freehand** ranked **#1 Paper of the Day** and **#2 Trending Paper** on [Hugging Face Daily Papers](https://huggingface.co/papers/2612.02442)!
- **[2026.12]** 📄 Released the [Freehand paper](https://arxiv.org/abs/2612.02442) and open-sourced `freehand-ai` on [PyPI](https://pypi.org/project/freehand-ai/).

## Install

Supported platforms: **macOS and Linux**. The CLI and web interface also run in Linux under WSL2.
**Native Windows: coming soon.** Desktop builds target macOS (Apple Silicon and Intel) and Linux (x64);
see [desktop/README.md](desktop/README.md) for build details.

On macOS or Linux:

```bash
curl -LsSf https://raw.githubusercontent.com/microsoft/FreeHand/main/install.sh | sh
```

Or install from [PyPI](https://pypi.org/project/freehand-ai/) (Python 3.10+):

```bash
pip install freehand-ai
# or: uv tool install freehand-ai
```

The script installs [uv](https://docs.astral.sh/uv/) if it is missing, then Freehand with its own Python 3.12. If you
already have uv, the same thing is `uv tool install --python 3.12 git+https://github.com/microsoft/FreeHand`.
`freehand update` upgrades the uv tool installation. To work on Freehand itself, see [Development](#development).

## Quick start

### Terminal

```bash
freehand login            # Continue with ChatGPT (Plus or Pro); or an API key: freehand login openai | anthropic
cd your/project
freehand                  # interactive session in this directory
freehand -c               # continue the last session here
freehand -p "fix the failing test"   # headless: activity on stderr, the final summary on stdout
freehand web              # the same sessions in a browser window
```

Every command, key, slash command and setting is in [docs/usage.md](docs/usage.md) and
[docs/config.md](docs/config.md).

### Desktop app (beta)

<p align="center">
  <img src="docs/assets/desktop-demo.webp" width="900" alt="The Freehand desktop app opens with its animated logo. In the textkit project, the request 'Add a word_count function to textkit.py, with tests.' GPT-6-astra reads the code, adds the function and seven tests, runs them, and reports that all 12 tests pass.">
  <br>
  <sub>GPT-6-astra in the desktop app, from launch. The model's 22 seconds of work play at 2× speed.</sub>
</p>

The desktop app is optional. It puts files, changes, Git and a terminal next to the conversation, and shares its
sessions and settings with the terminal, so a session started in one continues in the other.

Unsigned preview installers (macOS Apple Silicon `.dmg`/`.zip` and Linux `.AppImage`) are available on
[GitHub Releases](https://github.com/microsoft/FreeHand/releases). Because signed and notarized macOS builds are not
published yet, drag **Freehand.app** into **Applications** and clear the quarantine attribute once before opening:

```bash
xattr -cr /Applications/Freehand.app
```

Or build it from source (Node 22.12 or later, and `freehand` from [Install](#install)):

```bash
git clone https://github.com/microsoft/FreeHand.git && cd FreeHand/desktop
npm install
npm run app        # builds desktop/dist/mac-arm64/Freehand.app; `npm start` runs it without building
```

Sign in from the app, or with `freehand login`. More in [desktop/README.md](desktop/README.md),
[docs/web-ui.md](docs/web-ui.md) and [docs/workbench.md](docs/workbench.md).

## The idea

https://github.com/user-attachments/assets/ed6a45ba-9923-444d-b872-0a55e5368f16

The Bitter Lesson holds that knowledge built into AI systems helps at first and is eventually outgrown by general
methods. Mainstream harnesses build in a great deal: prompts prescribe how to approach a task, tool suites and
timeouts fix how to act, and threshold compaction decides what to remember, all before the model has seen the task.
For weaker models these presets are a crutch; for frontier models they become a cage. Freehand follows one rule:
**give the model a shell, its own memory, and a meter, and let it decide everything else.**

<p align="center">
  <img src="docs/assets/harness-overview.png" width="900"
       alt="Mainstream harnesses (Codex, Claude Code, Gemini CLI, OpenCode, Pi) give the model detailed instructions, 20+ preset tools, runtime reminders and auto-compaction at a fixed threshold. Freehand gives it a runtime description of about 200 words and one bash tool with model-set timeouts, and the model prunes its own history.">
</p>

| Decision | Typical harness | Freehand |
|---|---|---|
| How to approach the task (strategy) | rules, workflows and reminders in a long system prompt | a purely descriptive runtime prompt, with no rules |
| What tools to use (execution) | dozens of pre-designed tools | one `bash` tool, from which the model builds what the task needs |
| How long a command runs (execution) | fixed timeouts and poll intervals | the model sets each command's timeout and can run jobs detached |
| What stays in context (memory) | automatic compaction at a fixed threshold | the model manages its own context at runtime |

Before the task begins the model sees about 0.35K tokens and one tool. After every turn it also sees its own meter:
context size, tokens (with the cached share), cost and elapsed time.

The model-facing side stays this small on purpose. The human-facing side is complete: the desktop app (beta), a
browser interface (`freehand web`) and a terminal interface, with streaming Markdown, interrupt, sessions and resume,
per-turn undo, model switching, cost and context display, and HTML export.

## Results

Across 11 settings (five benchmarks with GPT-6-astra, Claude Opus 5.5 and Gemini 4 Carbon), 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, and it also beat OpenCode, Pi, DeepSeek Harness and the bash-only
mini-swe-agent. In a controlled side-by-side rerun on the same machines and API endpoints, each of the other harnesses
took 17–62% longer.

| Benchmark | Model | Freehand (score · cost per task) | First-party harness (score · cost per task) |
|---|---|---|---|
| Terminal-Bench 4 | GPT-6-astra | **57.1%** · **$3.12** | Codex 54.6% · $5.88 |
| | Claude Opus 5.5 | **61.9%** · **$3.38** | Claude Code 54.9% · $4.91 |
| | Gemini 4 Carbon | **57.1%** · **$8.76** | Gemini CLI 49.5% · $13.72 |
| Terminal-Bench Science | GPT-6-astra | **63.8%** · **$7.71** | Codex 58.1% · $12.99 |
| | Claude Opus 5.5 | **55.2%** · **$8.16** | Claude Code 54.3% · $12.86 |
| Agents' Last Exam | GPT-6-astra | **67.5%** · **$1.92** | Codex 63.6% · $4.45 |
| | Claude Opus 5.5 | **66.5%** · **$1.16** | Claude Code 62.2% · $2.29 |
| OSWorld 2.1 | GPT-6-astra | **76.2%** · **$3.96** | Codex 68.3% · $14.94 |
| | Claude Opus 5.5 | **80.1%** · **$2.09** | Claude Code 74.9% · $7.49 |
| AutomationBench | GPT-6-astra | **49.5%** · **$0.56** | Codex 44.8% · $0.89 |
| | Claude Opus 5.5 | **54.4%** · **$0.19** | Claude Code 47.9% · $0.27 |

With lower-tier models the order reverses. On Terminal-Bench 4 the first-party harness scores higher with GPT-6 Sol
(Codex 34.9% vs. 29.2%), Claude Sonnet 5.5 (Claude Code 41.6% vs. 34.9%) and DeepSeek V4.1 Flash (DeepSeek Harness
28.9% vs. 23.8%). Freehand is built for frontier models; with a smaller model, that model's first-party harness may
serve you better.

The other baselines, ablations and analysis are in the paper; [docs/benchmarks.md](docs/benchmarks.md) shows how to
run the benchmarks with Freehand.

## Models and providers

| Provider | How to sign in |
|---|---|
| OpenAI (default) | `freehand login`, with a ChatGPT Plus or Pro plan, or `freehand login openai` with an API key |
| Anthropic | `freehand login anthropic`, then `freehand --provider anthropic` |
| Any OpenAI-compatible Chat Completions API | `freehand --provider openai-chat --api-base <url> --api-key-env <VAR>` |
| A gateway such as LiteLLM, for GPT, Claude and Gemini behind one key | [docs/gateway.md](docs/gateway.md) |

`/model` switches the model, and the provider with it, in a running session.

## Security

Freehand is a local tool that acts with your permissions. It has no sandbox and no approval prompt: you draw the
boundary around Freehand, and inside it every decision is the model's.

- Commands run as you, with your files, network, credentials and environment variables.
- For code you do not trust, use a container or VM: [docs/container.md](docs/container.md).
- Repository content is untrusted input. `AGENTS.md` and project skills load only in folders you have trusted.
- No telemetry. Freehand talks only to the model service and MCP servers you configure (in the web and desktop
  interfaces, public web links in replies also load site favicons from Google's favicon service; see
  [docs/security.md](docs/security.md)).

The full model, including undo, local files and the browser interface, is in [docs/security.md](docs/security.md). To
report a vulnerability, see [SECURITY.md](SECURITY.md).

## Development

```bash
git clone https://github.com/microsoft/FreeHand.git && cd FreeHand
uv sync --extra dev
uv run pyflakes src tests
uv run pytest -q
```

The code layout and the rules for a change are in [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md).

<!-- agentopt-series:start -->
## 🧭 AgentOpt Series

Freehand is part of the **AgentOpt** series from Microsoft Research. Each project tackles one part of an agent system: its skills, its training environments, the evaluator that judges it, or the harness it runs in. Projects are listed by release date.

| Project | What it does | Paper | Code | Project page |
|---|---|---|---|---|
| SkillLens | Studies what makes model-generated skills useful, from experience to extraction to use | [arXiv](https://arxiv.org/abs/2605.23899) | [Code](https://github.com/microsoft/SkillLens) | [Project page](https://microsoft.github.io/SkillLens/) |
| SkillOpt | Trains reusable natural-language skills for frozen agents | [arXiv](https://arxiv.org/abs/2605.23904) | [Code](https://github.com/microsoft/SkillOpt) | [Project page](https://microsoft.github.io/SkillOpt/) |
| Resource2Skill | Distills human tutorials and resources into executable agent skills | [arXiv](https://arxiv.org/abs/2606.29538) | [Code](https://github.com/microsoft/Resource2Skill) | [Project page](https://microsoft.github.io/Resource2Skill/) |
| EnvOpt | Builds the training environments an agent needs | [arXiv](https://arxiv.org/abs/2611.41901) | [Code](https://github.com/microsoft/EnvOpt) | [Project page](https://microsoft.github.io/EnvOpt/) |
| EvalOpt | Evolves evaluators for open-ended tasks from human feedback | [arXiv](https://arxiv.org/abs/2612.02431) | [Code](https://github.com/microsoft/EvalOpt) | [Project page](https://microsoft.github.io/EvalOpt/) |
| **Freehand** (this repo) | An agent harness that leaves the decisions to the model | [arXiv](https://arxiv.org/abs/2612.02442) | [Code](https://github.com/microsoft/FreeHand) | [Project page](https://microsoft.github.io/FreeHand/) |

More AgentOpt projects are on the way. Overview: [AgentOpt series page](https://microsoft.github.io/SkillOpt/agentopt/).
<!-- agentopt-series:end -->

## Contributing

This project welcomes contributions and suggestions. See [CONTRIBUTING.md](CONTRIBUTING.md).

## Citation

If you find Freehand useful in your research, please cite:

```bibtex
@article{zeng2026freehand,
  title  = {Freehand: The Bitter Lesson Comes to Agent Harnesses},
  author = {Zeng, Zezi and Zhao, Yuke and Tian, Muzhao and Yang, Yifan and Dai, Qi and Liu, Bei and Qiu, Kai
            and Zhuang, Bohan and Zhu, Jihua and Luo, Chong},
  journal = {arXiv preprint arXiv:2612.02442},
  year   = {2026}
}
```

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft
sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Freehand is not affiliated with or endorsed by OpenAI, Anthropic or Google. ChatGPT, Codex, Claude, Claude Code,
Gemini and Gemini CLI are trademarks of their owners and are named here only to describe compatibility.

## License

MIT. See [LICENSE](LICENSE).
