Turnloom is a coding agent for the terminal and desktop that emphasizes transparent context, controllable operations, and measurable cost. It can read and edit files, run commands after user approval, and fold older tool outputs out of the prompt into a local archive, which both the user and the model can read back at any time. Every edit is shown as a diff before it lands and can be undone afterward; every model call is metered.
Key capabilities:
- Visible context: long tool outputs are folded out of the prompt rather than discarded as summaries, with the original content kept in a local archive; the model reads it back via recall, and the user can open the same reference in Studio.
- Controllable operations: commands, edits, and MCP calls wait for user approval by default; edits are presented as diffs; turnloom undo can undo the edits of a given turn, even across sessions.
- Known cost: each run ends with a receipt containing input, output, and cached token counts, folded character counts, changed files, and estimated cost; a budget can be set to stop a task before overspending.
- Lightweight and autonomous: built on the Python standard library plus one dependency, one loop, and a few tools; no accounts, no telemetry, no background services; MIT license.
How to use: Requires Python 3.11 or later. Run it without installation via uvx turnloom chat, or run it in a container with docker run ghcr.io/bhaskargurram-ai/turnloom; on Windows, clone the repository and double-click Open Turnloom Studio.cmd. Supports any OpenAI-compatible endpoint, including hosted providers, OpenRouter, or local models running via Ollama, LM Studio, vLLM, or llama.cpp; LiteLLM adds Anthropic, Bedrock, Vertex AI, and Azure. turnloom connect ollama uses local models, turnloom connect openrouter --tier free logs in through the browser and lists free models, and turnloom doctor checks the setup.
Use cases:
- Read-only code review (read-only sessions have no editing, shell, or MCP tools).
- Sustained work across multiple conversation turns, continuing the next day.
- Setting a spending cap for a task.
- Planning, building, and reviewing in stages (meteringThe planning and review phases are not editable, and the three share a budget).
- Uses local models, so data never leaves the machine.
- Runs unattended in a container (--yes approves everything; requires a sandbox).
- Reviews every pull request in CI.
- Provides MCP tools to agents, searching and calling server tools with approval.
- Driven from the editor (turnloom acp supports the Agent Client Protocol and can be configured in Zed's settings.json).
- Lets other agents delegate tasks (turnloom serve is an MCP server; --allow-run accepts tasks).
- Called from Python.
Studio is a workbench in a standalone window or browser tab; it runs with the base installation, and the studio extra component adds a native window, policy gate, exact token counting, and documentation tools. Sessions are saved in the workspace and can be created or resumed; Ctrl+K opens the command palette. Studio listens only on 127.0.0.1, and every request must carry a token generated at each startup.
Controls and limits: Approval is requested before running commands, editing files, or calling MCP tools; reading and searching files within the workspace requires no approval, but these reads are sent to the connected model. --budget can limit estimated cost, --max-steps limits the number of model calls (default 100), and --deadline limits wall-clock time. Commands run with the user's permissions, model API keys are removed from the command environment, and files that typically hold secrets (such as .env, private keys, and credential files) are closed to file tools; file tools can only access the workspace, and anything outside the workspace requires an approved shell command.
Policy gate: Before a tool call runs, Provio checks it against provio.yaml in the repository and writes each decision to the hash-chained ledger at .provio/ledger.jsonl. When that file exists in the workspace and the guard extra component is installed, Turnloom automatically enables the gate; the gate covers shell commands, file reads, file edits, and MCP tool calls, and it fails closed: if Provio cannot answer, the tool does not run. --no-gate bypasses the policy for a single run.
Context mechanisms:
- Folding: the three most recent tool results are kept intact; earlier results of 4000 characters or more are replaced in the prompt with a shortened version of the beginning and endShort preview and citations; results not yet read by the model are not folded.
- Archive: the full text is kept in the session archive; when command output is too long, the prompt gets the head and tail, and the archive keeps the rest.
- Recall: the model uses a citation to call recall to read a fragment of an archived result or to search; users can open the same citation in Studio.
- Overflow: if the conversation still exceeds the model window, the oldest exchange is moved into the archive as a whole, and its citation is listed to the model; content is never dropped with no way back. Each session's record is a JSON Lines file under the workspace's .turnloom/, with a .gitignore to prevent it from being tracked into version control; --resume rebuilds the conversation and archive from that file. Studio and the agent also append each model call to .turnloom/usage.jsonl. --no-fold lets you compare runs with and without folding; folding rewrites earlier messages and, on providers that support prompt caching, sacrifices some cache hits in exchange for a smaller prompt, so it is recommended to measure on your own tasks before relying on it.
Benchmark: Turnloom was compared with seven other agents on the same 19 Terminal-Bench 2.1 tasks, with the same model (gpt-5.1), one attempt per task, and the same metering. Tasks solved: Turnloom 10/19, best agent 11, six of the eight between 9 and 11, a tie at 19 tasks. Cost: $0.160 per task, in the middle; OpenCode and Goose were cheaper, at $0.091 and $0.101 respectively. Tokens: Turnloom sent 70,000 input tokens per task, while the other five agents were between 110,000 and 327,000; output tokens were more than the cheapest agent, and cost came mainly from output. This is a small sample, a single run, performed by the Turnloom authors; the run also found three issues in Turnloom, fixed in 0.7.1.
What Turnloom is not: It is a small agent: one loop, a few tools, no background service, no telemetry. It does not sandbox commands at the OS level, nor does it index repositories; if you need isolation, run it in the provided container.
License: MIT. Built-in roles retain the Agency Agents license; provider presets are derived from Models.dev and its license; the open-source JavaScript packages bundled with Studio are listed in THIRD-PARTY.txt.source JavaScript packages are listed in THIRD-PARTY.txt.