Skip to content

Commit 9c9166c

Browse files
docs: how gitagent works in detail; README results first, 93.03%
docs/HOW-IT-WORKS.md gives the mechanical account of the harness: the prompt assembly order, the loop, the shell and its end marker, the output shaper's steps and numbers, the loop detector's hash, the time budget, the three masking modes and the context-editing request, the compaction request and message, the stop check's patterns and verdict, the snapshot probe, sub-agents and the plan engine, the records, the sandbox, offline learning, memory, hooks and approvals. The README puts Results before the story, adds a subsection on why the score is higher than the other harnesses', uses 93.03% throughout, and links to the detailed document. The results chart is redrawn with a readable axis.
1 parent e3a4d41 commit 9c9166c

3 files changed

Lines changed: 198 additions & 63 deletions

File tree

‎README.md‎

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</p>
1111

1212
<p align="center">
13-
<img src="https://img.shields.io/badge/Terminal--Bench_2.1-93.0%25-e05a44?style=flat-square" alt="Terminal-Bench 2.1: 93.0%" />
13+
<img src="https://img.shields.io/badge/Terminal--Bench_2.1-93.03%25-e05a44?style=flat-square" alt="Terminal-Bench 2.1: 93.0%" />
1414
<img src="https://img.shields.io/badge/version-2.0.0-2a1f18?style=flat-square" alt="version 2.0.0" />
1515
<img src="https://img.shields.io/badge/built_with-Rust-2a1f18?style=flat-square" alt="Rust" />
1616
<img src="https://img.shields.io/github/license/open-gitagent/gitagent?style=flat-square&color=2a1f18" alt="license" />
@@ -29,7 +29,7 @@
2929
<img src="./docs/media/console.gif" alt="A gitagent session in the terminal" width="820" />
3030
</p>
3131

32-
**Terminal-Bench 2.1: 93.0%** with Claude Opus 5.5, all 89 tasks, five runs each, code frozen at the published commit. The published harnesses on the same benchmark: Terminus 2 with the same model 87.6%, Codex CLI with GPT-6 Astra 87.4%, the top entry 91.4%. The numbers are under [Results](#results); the reason is under [How gitagent works](#how-gitagent-works).
32+
**Terminal-Bench 2.1: 93.03%** with Claude Opus 5.5, all 89 tasks, five runs each, code frozen at the published commit. The published harnesses on the same benchmark: Terminus 2 with the same model 87.6%, Codex CLI with GPT-6 Astra 87.4%, the top entry 91.4%. The numbers are under [Results](#results); the reason is under [How gitagent works](#how-gitagent-works).
3333

3434
This is gitagent 2, the Rust binary. Agents, hooks, schedules and client code written for gitagent 1.x run unchanged, and agent folders in the OpenGAP format load too. New in 2: the console (one `$` line per tool call, approvals inline, a task board), parallel tasks with a reconciling step, schedules, workflows, plugins, sub-agents, knowledge, the IPC protocol the Python and TypeScript clients speak, and the benchmark harness.
3535

@@ -134,38 +134,6 @@ Like 1.x's in-process scheduler, jobs fire only while `start` is running;
134134
for anything that must not be missed, have an external scheduler call
135135
`gitagent schedule run <id>`.
136136

137-
## How gitagent works
138-
139-
Most agents are a prompt, a model and a bag of tools, and the interesting part is what happens in between: how the agent is kept on course for an hour of work inside a context window, without wasting the model's attention and without breaking its cache. That in-between is what gitagent is. Here is one run, start to finish.
140-
141-
**The agent is a folder.** Before anything runs, the loader reads the agent directory: `agent.yaml` for the model and the tools, `SOUL.md` for who it is, `RULES.md` for what it must never do, `memory/` for what it remembers, `skills/`, `hooks/`, `schedules/`, `agents/` for the rest. All of it is assembled into one system prompt in a fixed order, and all of it is in git, so the agent that produced a result is a commit you can check out. The same loader runs the benchmark, the console and the SDKs; only the files differ.
142-
143-
**The prompt is a method.** It does not describe a character. It says how to work: note every concrete requirement in the task before touching anything, explore the environment, change things in small steps and check each one, and at the end verify the result by exercising it, running the tests, the program or the request. That last instruction is where most harnesses lose tasks: the model finishes without proof, and the checker disagrees.
144-
145-
**One loop, one shell.** The model is called with the prompt, the task and the history. It answers with text or tool calls. The tools run in one persistent shell, so working directory, environment and background processes carry from turn to turn like a person's terminal. The results go back; the loop repeats until the model calls `task_complete`.
146-
147-
**Output is shaped before the model sees it.** A build log is ten thousand lines; the model needs the head, the tail and the exit code. Every command result is cut to a budget: long output is spilled to a file, runs of similar lines (progress bars, repeated warnings) collapse to their first and last line, and a one-line status carries the exit code, the line count and the path of the spill file, so the model can ask for the rest if it matters. Fewer tokens per turn means more turns before the context is full, and more of each turn spent on the task.
148-
149-
**Reminders are appended, never injected.** The time left is shown on every result, and a reminder fires when the budget runs low. These go after the turn's results, never into earlier turns. Changing an earlier turn would invalidate the provider's prompt cache and the model's thinking blocks, so the whole history stays byte-identical and 92% of the input is served from cache. That is where the cost per run comes from.
150-
151-
**The loop detector.** If the model issues the same tool call with the same arguments and gets the same output twice, it is told so, with a nudge to change approach. Runaway loops are where other harnesses burn a time budget and a bill: a model that returns empty replies can be re-sent the whole growing conversation until the clock runs out. gitagent stops after the second repeat.
152-
153-
**Context is managed, not truncated.** Old tool results are cleared in batches through the provider's own context editing, which does not count as a history edit. Near the end of the window the history is replaced by a structured summary, done, pending, key files, last failure, ruled out, with the original task repeated verbatim by the harness rather than paraphrased by the model, so the goal never drifts.
154-
155-
**Done means verified.** `task_complete` is accepted only when the run shows a verification after the last edit. A completion without evidence is sent back with the task repeated. It is a small rule with a large effect: it catches the case where the model is confident and wrong.
156-
157-
**Services stay up for the checker.** The agent's shells are kept open after it finishes, so a server it started is still running when the tests connect to it.
158-
159-
**Every run is a record.** Each run writes a trajectory in the ATIF format, every prompt, reply, tool call and result, plus counters for every decision the loop made: loops caught, completions rejected, context compacted, cache hits. A failed run can be read step by step, and a change to the harness can be measured task by task against the previous one.
160-
161-
The pieces are ordinary. What is unusual is that each one is a switch in a profile file, measured on its own against the benchmark before it stayed on, and that the whole thing ships as one static binary that runs the same way in a task container, in your terminal and behind the SDK.
162-
163-
<p align="center">
164-
<img src="./docs/media/parallel.gif" alt="Parallel tasks on the task board" width="820" />
165-
</p>
166-
167-
**Parallel work.** When a task has many similar pieces, the agent can write a plan of phases: every task in a phase runs at the same time as its own sub-agent, a later phase sees the earlier results, and one more sub-agent reconciles everything into the answer. The console shows it as a board that redraws as the tasks run. See [Parallel work](#parallel-work).
168-
169137
## Results
170138

171139
<p align="center">
@@ -176,12 +144,12 @@ Every run is in `bench/RESULTS.md` with its commit, profile, model, cost and wha
176144

177145
| Harness | Model | Terminal-Bench 2.1 | Runs per task | Source |
178146
|---|---|---|---|---|
179-
| **gitagent 2** | Claude Opus 5.5 | **93.0%** (414/445; 75 of 89 tasks passed every run) | 5 | `bench/RESULTS.md`, round tb21-final |
147+
| **gitagent 2** | Claude Opus 5.5 | **93.03%** (414/445; 75 of 89 tasks passed every run) | 5 | `bench/RESULTS.md`, round tb21-final |
180148
| Terminus 2 | Claude Opus 5.5 | 87.6% | 1 | Vals.ai |
181149
| Codex CLI | GPT-6 Astra | 87.4% ±0.9 | — | Snorkel |
182150
| top published entry | Fable 5.1, max effort | 91.4% | — | Artificial Analysis |
183151

184-
The same run by the tasks' time limits (Harbor's summary; pass@k is the chance that at least one of k runs passes):
152+
The same run by the tasks' time limits (pass@k is the chance that at least one of k runs passes):
185153

186154
| Time limit | Trials | Pass rate | pass@2 | pass@5 |
187155
|---|---|---|---|---|
@@ -198,8 +166,49 @@ The same run by the tasks' time limits (Harbor's summary; pass@k is the chance t
198166

199167
Two of the 89 tasks start a virtual machine inside the task container, which this host cannot do, and no harness has passed them here; without those two the mean is 95.2%. The 95% interval for the headline run is 88.8–96.9%. It cost $112.85, about $0.25 per run, with 92% of the input tokens served from the prompt cache.
200168

169+
### Why it scores higher than the other harnesses
170+
171+
The model is the same, so the difference is what the harness does between calls. Four things account for most of it, each measured on its own on the benchmark before it stayed on (see [How gitagent works](#how-gitagent-works) and the detail in [docs/HOW-IT-WORKS.md](./docs/HOW-IT-WORKS.md)):
172+
173+
1. **Completions need evidence.** `task_complete` is refused when nothing was verified after the last change, and the task is repeated. Other harnesses accept the model's word; the checker then disagrees on exactly the tasks where the model was confident and wrong.
174+
2. **The context stays small and the cache stays warm.** Every result is shaped to a budget, old results are cleared in batches through the provider's context editing, and reminders are appended rather than inserted, so the history is never rewritten. The model spends its attention on the task, and 92% of input tokens come from the cache.
175+
3. **Loops and time are handled by the harness, not the model.** A repeated call with the same result is called out after the third time; the time left is shown on every result, with a nudge at 70% of the budget and a final call at 90%. A run never ends in a timeout with unverified work, and never re-sends a growing conversation until the clock runs out.
176+
4. **The environment is read once, up front.** A fifteen-second probe puts the directory listing, the tool versions, the CPU and memory into the first message, so the first turns go to the task instead of to looking around.
177+
201178
**The rules behind the numbers** (`docs/INTEGRITY.md`, checked by `scripts/integrity-audit.sh`): the agent never reads a task's tests or verifier output, and a built-in guard refuses writes under `/tests`; the tasks used while developing were kept apart from the ones used to score; benchmark mode uses only the built-in configuration, with a test that fails if the prompt or tool list sent to the model ever changes.
202179

180+
## How gitagent works
181+
182+
Most agents are a prompt, a model and a bag of tools, and the interesting part is what happens in between: how the agent is kept on course for an hour of work inside a context window, without wasting the model's attention and without breaking its cache. That in-between is what gitagent is. Here is one run, start to finish.
183+
184+
**The agent is a folder.** Before anything runs, the loader reads the agent directory: `agent.yaml` for the model and the tools, `SOUL.md` for who it is, `RULES.md` for what it must never do, `memory/` for what it remembers, `skills/`, `hooks/`, `schedules/`, `agents/` for the rest. All of it is assembled into one system prompt in a fixed order, and all of it is in git, so the agent that produced a result is a commit you can check out. The same loader runs the console, the SDKs and a single task; only the files differ.
185+
186+
**The prompt is a method.** It does not describe a character. It says how to work: note every concrete requirement in the task before touching anything, explore the environment, change things in small steps and check each one, and at the end verify the result by exercising it, running the tests, the program or the request. That last instruction is where most agents go wrong: the model finishes without proof, and the result does not hold.
187+
188+
**One loop, one shell.** The model is called with the prompt, the task and the history. It answers with text or tool calls. The tools run in one persistent shell, so working directory, environment and background processes carry from turn to turn like a person's terminal. The results go back; the loop repeats until the model calls `task_complete`.
189+
190+
**Output is shaped before the model sees it.** A build log is ten thousand lines; the model needs the head, the tail and the exit code. Every command result is cut to a budget: long output is spilled to a file, runs of similar lines (progress bars, repeated warnings) collapse to their first and last line, and a one-line status carries the exit code, the line count and the path of the spill file, so the model can ask for the rest if it matters. Fewer tokens per turn means more turns before the context is full, and more of each turn spent on the task.
191+
192+
**Reminders are appended, never injected.** The time left is shown on every result, and a reminder fires when the budget runs low. These go after the turn's results, never into earlier turns. Changing an earlier turn would invalidate the provider's prompt cache and the model's thinking blocks, so the whole history stays byte-identical and 92% of the input is served from cache. That is where the cost per run comes from.
193+
194+
**The loop detector.** If the model issues the same tool call with the same arguments and gets the same output twice, it is told so, with a nudge to change approach. Runaway loops are where other harnesses burn a time budget and a bill: a model that returns empty replies can be re-sent the whole growing conversation until the clock runs out. gitagent stops after the second repeat.
195+
196+
**Context is managed, not truncated.** Old tool results are cleared in batches through the provider's own context editing, which does not count as a history edit. Near the end of the window the history is replaced by a structured summary, done, pending, key files, last failure, ruled out, with the original task repeated verbatim by the harness rather than paraphrased by the model, so the goal never drifts.
197+
198+
**Done means verified.** `task_complete` is accepted only when the run shows a verification after the last edit. A completion without evidence is sent back with the task repeated. It is a small rule with a large effect: it catches the case where the model is confident and wrong.
199+
200+
**Services can stay up.** With `--linger` the agent's shells are kept open after it finishes, so a server it started keeps serving whoever needs it next.
201+
202+
**Every run is a record.** Each run writes a trajectory in the ATIF format, every prompt, reply, tool call and result, plus counters for every decision the loop made: loops caught, completions rejected, context compacted, cache hits. A failed run can be read step by step, and a change to the harness can be measured run by run against the previous one.
203+
204+
The pieces are ordinary. What is unusual is that each one is a switch in a profile file, measured on its own before it stayed on, and that the whole thing ships as one static binary that runs the same way in a container, in your terminal and behind the SDK. The exact mechanics, with the numbers, formats and algorithms, are in [docs/HOW-IT-WORKS.md](./docs/HOW-IT-WORKS.md).
205+
206+
<p align="center">
207+
<img src="./docs/media/parallel.gif" alt="Parallel tasks on the task board" width="820" />
208+
</p>
209+
210+
**Parallel work.** When a task has many similar pieces, the agent can write a plan of phases: every task in a phase runs at the same time as its own sub-agent, a later phase sees the earlier results, and one more sub-agent reconciles everything into the answer. The console shows it as a board that redraws as the tasks run. See [Parallel work](#parallel-work).
211+
203212
## As a library
204213

205214
The `gitagent-sdk` crate offers a library interface over the same loop: `query(prompt, AgentOptions)` streams `system` / `assistant` / `user` / `result` messages, tools appear under the `.claude/` tool names (`Bash`, `Read`, `Edit`, …), and hooks are callbacks that receive `PreToolUse` / `PostToolUse` input and answer with `permissionDecision`, `updatedInput` or `updatedToolOutput`.
@@ -250,7 +259,7 @@ With `learning: online`, gitagent learns from each task it completes. The model
250259

251260
### Output, records and events
252261

253-
- **Records:** every run writes `trajectory.json` (Harbor's ATIF format), `counters.json` and the full output of every command (`out/<n>.log`) to `--out-dir`. They are updated after every turn.
262+
- **Records:** every run writes `trajectory.json` (the ATIF trajectory format), `counters.json` and the full output of every command (`out/<n>.log`) to `--out-dir`. They are updated after every turn.
254263
- **Events:** `--events jsonl` prints one JSON object per line on stdout: `turn_start`, `model_text`, `tool_call`, `tool_result`, `stop_check`, `guard`, `turn_end`, `repo`, `run_end`.
255264
- **Telemetry:** set `OTEL_EXPORTER_OTLP_ENDPOINT` to export traces and metrics (OTLP over HTTP/JSON). `OTEL_EXPORTER_OTLP_HEADERS` and `OTEL_SERVICE_NAME` are honoured.
256265

@@ -279,7 +288,7 @@ The shim (`gitagent_harbor/agent.py`):
279288

280289
### Learning from finished runs
281290

282-
`gitagent learn` turns finished Harbor trials into general lessons for the system prompt. It reads only gitagent's own trajectory and the reward of each trial, asks the model for lesson changes, rejects any that carry task details, and rewrites `prompts/lessons.md`. A lesson is shown to the agent only once attempts at two different tasks support it.
291+
`gitagent learn` turns finished runs into general lessons for the system prompt. It reads only gitagent's own trajectory and the reward of each trial, asks the model for lesson changes, rejects any that carry task details, and rewrites `prompts/lessons.md`. A lesson is shown to the agent only once attempts at two different tasks support it.
283292

284293
```sh
285294
gitagent learn --model anthropic:claude-opus-5-5 --from bench/jobs/<job> [--from …] [--dry-run]

0 commit comments

Comments
 (0)