One tool: a Python REPL. The model writes the rest.
Install in VS Code · Three ways to run · Architecture · MIT License
rust · python kernel · vs code · acp · mcp · open source
Unharnessed is a coding agent harness built on one idea: the model gets exactly one tool, ipython, a persistent CPython REPL. There is no read, no grep, no edit_file, no web_fetch. Reading a file, searching a repository, patching forty call sites, starting a dev server or calling an MCP service: all of it is Python the model writes, in a kernel that stays alive for the whole session.
The harness around it (Rust) does the rest of the job: the agent loop, compaction, goals, provider retry and failover, sessions, the VS Code panel. It ships as a VS Code extension, a terminal app, a headless CLI and an ACP agent.
Warning
Unharnessed never asks before running a command. The model's Python and shell commands run with your user permissions, and the kernel is not a sandbox. Use it in a container, a VM or a disposable checkout. Why there are no permission prompts.
- Why one tool: the bet
- The kernel: what the model actually gets
- Three ways to run: Turn, Goal, Autonomous
- Wake-ups: the session starts its own turns
- Compaction: the context is summarised, the kernel is not
- Sessions: JSONL, resume, kernel snapshots
- Skills ·
AGENTS.md· MCP - Providers and failover: your subscription, any key, local models
- What we left out: no sub-agents, no memory, no permission prompts
- Surfaces: VS Code, terminal, CLI, ACP
- Architecture · Install · Build from source · Development
Every hardcoded tool is a decision made in advance, on the model's behalf: what a read returns, how an edit is shaped, how much output survives. That was a fair trade when models needed rails. Each generation needs fewer.
Frontier models already reach for Python when they can. A tool list makes them pay for it: each call does one thing, costs a round trip, and pours its result into the context, where it stays. Unharnessed is built for where that curve ends: one tool, and nothing left to take away.
| A tool list | Unharnessed | |
|---|---|---|
| Read, search, edit, check | 4 calls, 4 round trips | 1 cell, 1 round trip |
| A 40,000-line log | 40,000 lines in the context | a variable; the 10 lines it needed in the context |
| A check across 200 files | 200 calls, 200 results | 1 loop, 1 result |
| Helpers it writes | none | functions, kept in the session |
| After compaction | a summary | a summary, plus every variable, function and running process |
The kernel is a CPython process (unharnessed-runtime, Python 3.11+) in a uv-managed venv, built once on first run. It speaks newline-delimited JSON with the Rust host (protocol):
- One persistent
__main__namespace on one asyncio loop. Cells compile withPyCF_ALLOW_TOP_LEVEL_AWAIT, soawaitworks at top level, and tasks a cell starts keep running between cells. - Output is attributed to the cell that wrote it, even from an asyncio task the cell spawned. Raw fd writes (subprocesses, C extensions) are shipped separately and never misattributed.
- The trailing expression is the result, Jupyter style, capped at 1 MiB of
repr. - Interrupts are real:
KeyboardInterruptlands in the running cell, whether it is in sync code or suspended on anawait. - Pre-installed:
requests,httpx,pandas,numpy,scipy,bs4,lxml,pydantic,pyyaml, ... The model adds more withuv pip install, and runs your project through its own environment (uv run,.venv/bin/python), never by polluting the kernel.
This is the static part of the system prompt, in full. It says what the one tool is and how to use it, once. The rest of the room is the model's.
# Unharnessed
You have one tool, `ipython`: a persistent CPython REPL where top-level `await` works. Every other capability is a Python function in that REPL. Messages that start with `[<kind>]` come from the harness, not from the user.
## Functions in the REPL
- `bash(command: str, timeout: float | None = 600) -> BashHandle`: start a shell command in the background and return at once; each call is a new process, a command still running after `timeout` seconds is killed (`None`: no limit), and a notification arrives when a command ends after its cell
- `BashHandle`: `.pid`, `.running`, `.command`, `.tail(n=50)`, `.output()`, `.poll() -> BashResult | None`, `.kill(sig=SIGTERM, grace=5.0)`, and `await handle -> BashResult`
- `BashResult`: `.exit_code`, `.output`, `.duration`
## Rules
- Keep in mind that each tool call is a round trip: steps that do not need a result you have not seen yet can go in one call.
- Run programs with `bash()`, not `subprocess` or `os.system`. Write logic, loops and parsing in Python; use `bash()` only to call programs.
- `os.chdir()` and `os.environ` changes persist and apply to later `bash()` calls.
- Store what you read or compute in named variables instead of reading it again.
- Python variables survive compaction, except single values larger than 16 MiB.
- Run an external project through its own environment (`uv run`, `.venv/bin/python`, its documented commands); do not install its dependencies into the kernel.
- Do not hold the turn with `sleep` or long blocking awaits: end the turn and wait for the notification.
- When you are done, stop calling tools and give the final answer, with any assumption you made.After it come only the dynamic parts: the pre-installed packages, the skills inventory, the MCP servers, the environment, and your AGENTS.md. unharnessed prompt prints the assembled prompt with its layer breakdown.
In most harnesses, a command holds the model until it ends: a ten-minute build is ten minutes of waiting. Here every command starts in the background and hands back a handle.
build = bash("cargo build --release") # returns at once
tests = bash("pytest -x", timeout=None) # no time limit
server = bash("npm run dev", timeout=None) # keeps running across cells
server.tail(20) # last lines, without waiting
result = await build # BashResult(exit_code, output, duration)- Each call is a new process in its own process group, so
kill()takes the whole tree down; an orphan journal reaps leftovers after a crash (a kill-on-close job object on Windows). - A command still running after
timeout(10 minutes by default) gets SIGTERM, then SIGKILL, and its notice says so. - When a command outlives the cell that started it, the model gets a
[bash-done pid:… exit:…]message when it ends. If the session is idle, that message starts a new turn (see Wake-ups). os.chdir()andos.environchanges in Python apply to laterbash()calls.
With tool calls, every result is poured into the context and stays there. Here what the model reads lands in the kernel, under a name, and only what it prints reaches the context.
log = open("server.log").read().splitlines() # 40,000 lines, kept in the kernel
errors = [l for l in log if "ERROR" in l]
errors[-10:] # the only 10 lines the model readsTen turns later, log is still there: no second read, no second copy in the context.
The model writes the helpers it needs: plain Python functions, kept as variables. It calls one again whenever it needs it, rewrites it or deletes it, like any other variable. A check across 200 files is one loop in one call, with one result in the context.
async def find_flaky(paths, runs=5):
results = {}
for p in paths:
outcomes = {(await bash(f"pytest -q {p}")).exit_code for _ in range(runs)}
if len(outcomes) > 1:
results[p] = outcomes
return results
flaky = await find_flaky(test_files) # 200 files, one call
flaky # → 3 flaky testsThis is the difference with code mode: there, the model's script can only call the tools the harness already built. Here, there is no list to call. The model writes the code that does the work.
Unharnessed has three ways to drive the model. They differ on one question: who decides that the work is done?
| Mode | Who decides it's done | Start it with | Use it for |
|---|---|---|---|
| Turn | the model, once | a message | questions, focused changes, back and forth |
| Goal | the model, after auditing its work | /goal <objective> or --goal |
long tasks that take many turns |
| Autonomous | your gates (cargo test, npm run lint, ...) |
/autonomous on or --autonomous |
unattended runs with a hard definition of done |
The default. You send a message, the model calls ipython as many times as it needs, and the turn ends when it answers without a tool call. The hand comes back to you.
A goal is an objective that persists across turns. Each time the model stops, the harness sends it a continuation: the objective, the tokens used, the budget left, and an instruction to audit the current state against every requirement before claiming anything. It keeps going until the model calls, from the kernel:
await goal.complete() # saying "done" is not enough: the goal ends only on this call
await goal.block("reason") # only the user or an outside change can lift this-
Optional token budget (
--goal-token-budget, orgoal.create(..., token_budget=)): when it runs out, the goal turnsbudget_limitedand the model is told to wrap up, not to declare victory. -
Pause, resume, clear from
/goalor from the message box in VS Code, which shows the goal's line and its timer. -
It can't loop forever. A turn is idle when it calls no tool while no
bash()command runs. After 3 idle turns in a row, the harness marks the goalblockedwith the model's last words as the reason, and the hand comes back (-pexits 0).Why: on Terminal-Bench, before this rule, a model that was truly stuck kept answering "Operator action is required, I will not falsely mark the goal complete" to every continuation: 440 replies and $37 on a task where the official Codex run spent $4.82.
-
Waiting is not idling. While a
bash()command runs, a turn without a tool call is the model waiting on it: the next continuation leaves when the last command ends, or every 10 minutes for one that never does (a server).
Autonomous mode replaces the model's judgement with yours: after each turn, the harness runs your gate commands, and the run ends only when they all pass or a limit is hit. A failing gate's output (up to 6,000 characters) is sent back as the next continuation.
unharnessed -p --autonomous \
--autonomous-gate "cargo test" \
--autonomous-gate "cargo clippy -- -D warnings" \
"Make the parser accept trailing commas"| Limit | Flag | Default |
|---|---|---|
| Follow-up continuations | --autonomous-max-continuations |
3 |
| Assistant turns | --autonomous-max-turns |
12 |
| Tokens | --autonomous-max-tokens |
80,000 |
| Wall clock | --autonomous-timeout-ms |
30 min |
| Retries per failed gate | --autonomous-gate-retries |
3 |
| Timeout per gate | --autonomous-gate-timeout-ms |
5 min |
The harness snapshots the git worktree before each gate run: a gate that failed is not re-run over an unchanged workspace, so a model that changes nothing can't burn retries.
An idle session doesn't need you to start its next turn. Three events do it:
- A background
bash()ends after the cell that started it. The model gets[bash-done pid:… exit:…]and picks up from there: start a 20-minute build, end the turn, get woken when it's done. - A goal's backoff ends, or its wait on a running command does.
- A provider quota resets (see Providers and failover).
In VS Code and ACP, the agent starts the turn itself and streams it like any other. With -p, the process waits for them before exiting, at most --background-wait-ms per wait (10 minutes by default, 0 for no wait), then kills what is still running.
A long task outgrows the context, and the conversation has to be summarised. What lived only in the conversation is gone. What lives in the kernel is not: the data, the running server, the functions the model wrote.
- Threshold: compaction runs at a turn boundary when the context nears the model's window, minus a 16,384-token reserve. The last 20,000 tokens are kept verbatim. Both are settings (
compaction.reserveTokens,compaction.keepRecentTokens). - Overflow recovery: if a provider rejects a request for its size, the harness compacts and retries the turn.
- Manual:
/compact [instructions], where the instructions focus the summary. - The model is told what survived. After a compaction, it gets a
[python-state]notice listing the names still defined in the kernel:
[python-state]
Your Python kernel persisted through compaction; its remaining variables, imports, and helpers are still available. These names are still defined: log, errors, find_flaky, server.
Any single variable above 16 MiB is dropped at compaction, and the notice names it.
- Append-only JSONL in
~/.unharnessed/sessions. Resume with-c(last session) or-r <id|path>, branch with--fork, export withunharnessed session export. - The kernel comes back too. When a session ends, its namespace is serialised with
dill, one name at a time (16 MiB per variable, 256 MiB in total). On resume, a fresh kernel revives it, and the model gets a[python-state-restored]notice listing what came back and what didn't, before its first turn. - One process per session file: a lease in
~/.unharnessed/session-leaseskeeps two processes from writing the same session.
A skill is a folder with a SKILL.md (a name, a one-line description, then instructions). Only the name and description go into the system prompt; the model reads the file when the task matches it.
A skill with a pyproject.toml is a Python skill: it's installed in the kernel venv and pre-imported, so the model calls it as a plain Python object, no tool schema involved. The three built-in skills are the kernel's API to the harness:
| Skill | In the kernel | What it does |
|---|---|---|
goal |
await goal.create(...), .get(), .complete(), .block(reason) |
Goals |
mcp |
await mcp.search_tools(...), .call_tool(...), ... |
MCP |
attach-image |
await attach_image(*paths) |
puts images in the model's context |
Skills are discovered from ~/.unharnessed/skills, <project>/.unharnessed/skills, .agents/skills in the project and its parent directories, and the skills setting. --skill <path> adds one, --no-skills turns discovery off.
Both are discovered in the project and its parent directories and loaded into the system prompt. This is where what should always hold goes: your conventions, your commands, what to avoid. You write it, you can read it, you can delete it. (--no-context-files turns it off.)
MCP servers are not exposed as native tools: their tool schemas never fill the context. The model reaches them through the pre-imported mcp object, searches for the tool it needs, and gets results as Python values it can filter before reading.
await mcp.search_tools("search documents")
await mcp.call_tool("notion", "notion-search", {"query": "roadmap"})unharnessed mcp add docs --url https://example.com/mcp --oauth # HTTP
unharnessed mcp add fs -- npx -y @modelcontextprotocol/server-filesystem . # stdioIn VS Code, the settings screen also lists a catalog of services to connect in one click.
Unharnessed is free. Sign in with your browser from the panel, and requests draw on your plan's limits: no API key, no second bill.
| Sign in with | Plan |
|---|---|
| Claude | Pro / Max |
| ChatGPT | Plus / Pro |
| GitHub Copilot | your Copilot plan |
| Google AI | Pro / Ultra |
| Grok | xAI account |
Or bring a key: 25 providers and gateways
Anthropic · OpenAI · Google Gemini · Google Vertex AI · Amazon Bedrock · Azure OpenAI · Mistral · xAI · DeepSeek · Groq · Cerebras · Fireworks · Hugging Face · OpenRouter · Vercel AI Gateway · Cloudflare AI Gateway · Cloudflare Workers AI · Moonshot AI · Kimi For Coding · MiniMax · ZAI · Xiaomi MiMo · OpenCode Zen · OpenCode Go · Prime Inference
Or run it yourself: local model servers
Ollama · LM Studio · llama.cpp · vLLM · any OpenAI-compatible server
The model catalog is fetched live (hourly, with a disk cache and a bundled fallback, so there is no cold start offline). A model that Anthropic, Google or OpenAI just released (through their APIs, a Claude subscription or a ChatGPT subscription) reaches the picker before the catalog lists it: every hour a script compares the catalog with models.dev and with the Codex CLI's model list, and publishes what is missing in catalog/models.additions.v1.json, which the client adds to its catalog. A local ~/.unharnessed/models.json takes precedence.
A long goal shouldn't die on a 529. A failed turn goes through a chain before it reaches you:
- Retry the same provider: 3 times, with exponential backoff from 2 s, honouring the server's
Retry-After. - Fail over to another configured provider serving the same model (say, Claude through your subscription, then through Bedrock): 1 s doubling backoff up to 30 s, at most 8 retries for the whole chain.
- Wait out a quota. When a plan's usage limit is hit and the provider says when it resets, the session parks (up to 24 h by default, 7 days at most) and wakes itself when it does, with a note telling the model to pick up where it stopped.
Every feature below exists in other harnesses. We left each one out on purpose.
To hand work to a sub-agent, the main model has to write it a brief, and a brief is never the whole task. The sub-agent starts from zero, spends tokens finding out what the first model already knew, then sends back a summary. Something is lost at each hand-off. Here, the model that holds your task makes every call itself, and what it needs to know, it reads first-hand. (Parallelism doesn't need sub-agents: bash() and asyncio run things side by side.)
A memory is the agent keeping notes about you from one session to the next. The notes pile up and are loaded every time, so they take context whether they matter or not, and they don't expire when you change your mind: the old preference is still in there, arguing with what you ask today. Here, a new session starts from your repository and your request. What should always hold goes in AGENTS.md.
Most harnesses stop before a command and wait for you to approve it; nothing moves until you're back at the screen. Unharnessed never blocks a call, so a goal can run on its own. It's a bet, taken early: models keep getting better at judging what is safe to run, and a harness built around asking would have to be taken apart later. Today it's the riskier choice: until the bet is won, run it in a container.
Every rule in a system prompt is a decision made for the model, and it sits in the context on every turn. Ours is about 1,700 characters.
Unharnessed Agent puts the agent in the secondary side bar: sign-in, model and reasoning pickers, the conversation, and a kernel panel that shows the running bash() commands (with their live tail, and a stop button) and the variables in the kernel.
- Conversations run in the background. Each one has its own agent process and its own kernel: switching conversations stops nothing, and several can work at once. The history menu marks the ones working and the ones that finished since you last looked.
- Idle conversations sleep after 90 minutes without work: the agent stops and saves its kernel's variables; opening the conversation brings them back. It never sleeps while a turn, a goal or a
bash()command runs. - A context ring next to send shows how full the window is and how much the provider's cache took, and tells when a compaction is coming.
unharnessed, run in a terminal with no -p, opens the same panel full screen: the conversation with its thinking and its cells, the kernel panel (variables, running servers, a stop button), the providers' sign-ins, the model and effort menus, the saved conversations, the settings, MCP servers and skills. It is an ACP client of its own agent process, like the extension. Install it with one command.
unharnessed # a new conversation in this folder
unharnessed "Port the tests" # ... that starts on a message
unharnessed -c # the last conversation, its kernel restored
unharnessed --resume # pick one among the saved conversationsunharnessed -p "Compute 2**100 in the kernel" # text output
unharnessed --mode json -p "..." # JSON event stream
unharnessed -c -p "..." # continue the last session
unharnessed -p --goal "Port the test suite to pytest" --goal-token-budget 2000000
unharnessed model list # every model you have credentials for
unharnessed --model <id> --thinking high -p "..."
unharnessed prompt # the assembled system prompt--mode json streams every event: message deltas, tool calls, compaction_start/compaction_end, goal_update. Built for benchmarks and scripts.
unharnessed --mode acp speaks the Agent Client Protocol over stdio, so any ACP client (Zed, ...) can drive it: model, reasoning-effort and fast-mode pickers as config options, follow-up queueing, and wake-up turns streamed as session/update. The VS Code extension is itself an ACP client.
┌─────────────────────────┐ ACP (JSON-RPC, stdio) ┌────────────────────────────────┐
│ VS Code extension │ ────────────────────────▶ │ unharnessed (Rust) │
│ TypeScript + React │ │ │
└─────────────────────────┘ │ uh-cli binary, -p, logins │
│ uh-tui terminal UI │
│ uh-daemon ACP transport │
unharnessed -p / --mode json ────────▶ │ uh-core session engine │
│ uh-agent turn loop │
│ uh-ai providers │
│ uh-models model catalog │
│ uh-types shared types │
└────────────────┬───────────────┘
│ NDJSON, stdin/stdout
┌────────────────▼───────────────┐
│ Python kernel (uv venv) │
│ rlm.repl · bash · mcp · skills │
└────────────────────────────────┘
| Path | What it is |
|---|---|
crates/uh-types |
the only shared vocabulary: messages, session entries, goal state |
crates/uh-ai |
provider clients (Anthropic, OpenAI Completions/Responses, Google, Bedrock, Mistral, Azure, ...), usage, overflow detection, a faux provider for tests |
crates/uh-models |
the live model catalog: fetch, disk cache, bundled snapshot, transport pinning |
crates/uh-agent |
the turn loop: provider stream, tool dispatch, aborts. Tool-agnostic |
crates/uh-core |
the session engine: kernel, compaction, goals, autonomous mode, retry/failover, wakes, sessions, skills, MCP, system prompt |
crates/uh-daemon |
the ACP transport and the session leases (no daemon, despite the name) |
crates/uh-tui |
the terminal UI: unharnessed in a terminal, an ACP client over its own agent process; --tui-replay plays a recorded conversation |
crates/uh-cli |
the unharnessed binary: flags, -p runtime, provider sign-ins |
unharnessed-runtime |
the Python kernel: the REPL protocol, bash(), the MCP client, snapshots |
skills |
the built-in skills: goal, mcp, attach-image |
vscode |
the extension and its React webview |
Dependencies go one way, from uh-types up to uh-cli. Each crate's README states its scope, its non-goals and its public API.
Terminal (macOS and Linux):
curl -fsSL https://unharnessed.dev/install.sh | shTerminal (Windows, in PowerShell):
irm https://unharnessed.dev/install.ps1 | iexinstall.sh downloads the latest release's build for your machine, checks its SHA-256, puts it in ~/.local/share/unharnessed/<version>/, links ~/.local/bin/unharnessed to it and builds the kernel. Then unharnessed, in a project's folder, opens the terminal UI, and says when a newer release is out (it looks at most once a day): unharnessed update installs it, as the same command does; ... | sh -s -- --version <v> installs one release, ... | sh -s -- --uninstall removes the agent and keeps ~/.unharnessed (your conversations, keys and settings). It edits no shell file: when ~/.local/bin is not on your PATH, it prints the line that adds it. On Windows, install.ps1 does the same in %LOCALAPPDATA%\unharnessed\<version>\, points the junction %LOCALAPPDATA%\unharnessed\current to it and puts that on your user PATH; & ([scriptblock]::Create((irm <url>))) -Uninstall removes it.
VS Code: install Unharnessed Agent from the Marketplace, open the panel and sign in. The agent binary ships inside the extension.
Both need uv to build the kernel the first time:
curl -LsSf https://astral.sh/uv/install.sh | shRust 1.98.1 (pinned in rust-toolchain.toml), uv, and Node for the extension.
cargo build --release -p uh-cli --bin unharnessed
./target/release/unharnessed --unharnessed-bootstrap # build the kernel venv
cd vscode && npm install && npm run build # the extension; F5 runs it against the debug binary
npm run package # a .vsix for this platform, agent includedCredentials come from ~/.unharnessed/auth.json (written by the sign-ins) or the providers' usual environment variables. Settings live in ~/.unharnessed/settings.json and <project>/.unharnessed/settings.json.
make check: fmt, clippy (-D warnings), the tests and the release build. CI runs the same gates pluscargo deny.scripts/unharnessed-smoke.sh <dir>: drives the real binary end to end against a real model.scripts/unharnessed-wakes-e2e.py <dir>: provider retry and wake-ups, in-pand ACP, with the faux provider.scripts/unharnessed-skill-loading.sh <dir>: skill loading, no model needed.uv run scripts/unharnessed-tui-e2e.py <dir>: the terminal UI on a recorded conversation: frames drawn without a terminal, and the replay in a pseudo-terminal.unharnessed --tui-replay crates/uh-tui/recordings/demo.outplays it;scripts/unharnessed-tui-record.py <dir>records another.uv run scripts/unharnessed-tui-live-e2e.py <dir>: the live terminal UI in a pseudo-terminal, over its own agent with the faux provider and a real kernel, its providers' screen (a key saved and removed, a sign-in started, stopped and failing, nothing reachable), its message box (the@menu and the links of the files mentioned, the/menu of the commands, prompts and skills, a message sent into the running turn, the messages sent before), its model and effort menus, its saved conversations (a new one, one opened, one deleted,--resumealone), its kernel's panel (a server's port opened and the server stopped, the panel scrolled), a goal (paused, coming back with its conversation, resumed, ended), its settings (a switch, a number and a model written, the agent restarted; an MCP server added, changed, turned off, signed in to and removed; a Marketplace service added by a token; a skill made and turned off, a folder of skills added; groups of instructions per model), a sent message changed (the conversation gone back), and images (dropped, pasted, sent, refused). It leaves the frames each session exchanged (<dir>/live-*.rec), which--tui-replayplays.uv run scripts/unharnessed-install-e2e.py <dir>: the terminal install on the release binary (cargo build --release -p uh-clifirst): the archivescripts/unharnessed-package.shmakes of it, theninstall.shon machines of its own (a HOME under<dir>, a PATH of the installer's tools), the archives served over HTTP on this machine: installed undersh,dashandbash, updated, gone back, refused (an archive changed, cut short, of another version, of something else, a build that does not run, a file where the link goes, a script cut short), each platform's archive asked for, the kernel built with uv and said without, a session in the installed terminal UI, uninstalled.cd vscode && npm run typecheck: the extension's types. F5 opens an Extension Development Host withUNHARNESSED_BINpointing at the debug binary.cd vscode && npm run test:e2e: drives a real VS Code through each scenario oftest/e2e/run.mjswith the faux provider (UNHARNESSED_E2E_ONLY=<name>runs one).UNHARNESSED_E2E_VSIX=<the .vsix> node test/e2e/run.mjs(fromvscode/): the same scenarios on a packaged.vsix, installed by VS Code.- A pushed tag
vscode-v<version>releases the extension and the terminal's archives:extension-release.ymlbuilds the.vsixand the terminal'sunharnessed-<target>.tar.gzof macOS, Linux and Windows (installed on its runner byinstall.sh, orinstall.ps1), attaches them to a GitHub release, then publishes the.vsixfiles to the Marketplace through Trusted Publishing (the publisher trusts this workflow: no token is kept). Run by hand, the workflow only builds them.unharnessed.dev/install.shandunharnessed.dev/install.ps1redirect toinstall.shandinstall.ps1onmain, which install the latest release.
