Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

docs: showcase token-efficient RLM releases

Rach Pradhan9e5c8d84d12a
diff --git a/.gitignore b/.gitignore
index f2aa082c..7cc08993 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,9 @@ __pycache__/
.simple-harness-model
.wrangler/
+# local social drafts
+tweet.md
+
# local agent/IDE config (not project source)
.codex/
.devin/
diff --git a/README.md b/README.md
index 3e04975f..bd12d32d 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,12 @@
<img alt="Built in Zig 0.17 dev" src="https://img.shields.io/badge/built%20in-Zig%200.17%20dev-f7a41d?logo=zig&logoColor=white">
</p>
+<p align="center">
+ <strong>One of the most token-efficient coding harnesses we've tested.</strong><br/>
+ Prompt-cache max keeps repeated prefixes hot. RLM + spec-ptc turns wide work
+ into a small streaming program. Learnt slimming keeps fat results out of history.
+</p>
+
```sh
curl -fsSL https://github.com/justrach/codegraff/releases/latest/download/install.sh | sh
```
@@ -45,19 +51,109 @@ It works in your real terminal, on your real files, with the real internet, and
---
-## How it compares
+## Token-efficient by construction
+
+<p align="center">
+ <img src="token-efficient-loop.png" alt="Stable cache layers feed a small programmatic loop that tests parallel tool paths, keeps the useful path, and gathers one slim result" width="960">
+ <br/>
+ <sub>Stable prefix → small program → parallel tools → slim result. Faint branches are measured variants; the proven path continues.</sub>
+</p>
+
+There is no single “token trick.” graff compounds three separate cuts:
+
+- **Keep the reusable prefix stable.** Prompt-cache max holds the system prompt
+ and tool-catalog head byte-identical, keeps provider cache keys sticky, and
+ shows the last hit rate in the UI. A live same-process grok-4.6 `/btw` turn
+ reused **3,712 of 3,721 prior prompt tokens (99.8%)**.
+- **Program over context instead of pasting it back.** The default Recursive
+ Language Model (RLM) loop is a Zig port of
+ [Alex Zhang's RLM](https://github.com/alexzhang13/rlm) and
+ [spec-ptc](https://alexzhang13.github.io/blog/2026/spec-ptc/) (speculative
+ programmatic tool calling): the model writes a tiny program, finished host
+ calls start while the rest of it is still streaming, and useful binds persist
+ across turns.
+- **Return the useful shape, not the payload.** Folded schemas, structural
+ `codedb` reads, 4 KB tool-result handles, and learnt MCP slimming keep bulky
+ tool output out of the model's working set.
+
+The [Darwin Gödel Machine-style evolutionary archive](#an-evolutionary-harness)
+supplies the measuring discipline: record prompt/persona variants, score them,
+and keep what holds up. Prompt-cache max is a separate harness decision built
+with that same measure-and-keep instinct; the archive did not autonomously
+invent the cache layout.
+
+### One stable RLM reuse case
+
+Live grok-4.6, same task, one rep. The model reads a file into a bind and reuses
+it on the next RLM call:
+
+| harness | wall | input tokens | model calls |
+|---|---:|---:|---:|
+| structured-only (`--old`) | 99.6s | 135k | 11 |
+| default RLM | **39.2s** | **25.3k** | **5** |
+| reduction | **61%** | **81%** | **55%** |
+
+The broader five-task RLM suite kept the same **5/5** pass rate while cutting
+input from **203k to 105k**, output from **4,186 to 1,669**, and wall time from
+**161s to 136s**. SuperGrok OAuth is flat-rate; on a metered xAI key, the token
+cut is the bill. Full method and caveats: [v0.0.276 release notes](docs/releases/v0.0.276.md).
+
+### Same grok-4.6, same six coding tasks
+
+<p align="center">
+ <img src="social/graff-vs-grok-build-grok46.png" alt="Same-model comparison on six coding tasks: graff and grok-build both pass 5 of 6; graff uses 198 seconds summed wall time, 106k input tokens, 24 calls, and 8.5 MB RSS versus grok-build at 506 seconds, 194k input tokens, 39 calls, and 177 MB RSS" width="960">
+</p>
+
+At the same **5/6** pass rate, graff used **61% less summed wall time, 45% less
+input, 38% fewer model calls, and 95% less peak RSS**. This is one live rep of
+six DeepSWE-shaped tasks, not a universal leaderboard; `label-sort` failed both
+harnesses. The exact run and the rejected shortcuts are documented in
+[v0.0.276](docs/releases/v0.0.276.md).
+
+Much of this implementation and benchmark work was made possible by
+[Cursor Cloud Agents](https://cursor.com/docs/cloud-agent): parallel agents in
+isolated environments, with measured evidence merged back into the harness.
+
+### What shipped in v0.0.277 and v0.0.278
+
+- **MCP results learn to slim themselves.** On the Linear fixture, the warm
+ learnt path moved from **28.0s to 14.8s**, **112k to 31k input**, and **7 to 5
+ calls**. Return shapes ride the load result, never the stable prefix.
+- **grok-4.6 gets xAI's hosted X search.** The same live prompt moved from a
+ seven-call scrape (**101s, 64k input**) to one hosted call (**37s, 28k**),
+ without adding another catalog tool.
+- **Small turns stay small.** RLM and spec-ptc appear when work gets wide, the
+ context crosses its measured threshold, or you explicitly ask for them; tiny
+ turns do not pay the schema tax.
+- **Removed images really leave.** The v0.0.278 privacy follow-up drops a pasted
+ screenshot if its composer chip is removed, collapses duplicate payloads, and
+ makes `/image clear` clear the whole queue before anything reaches the model.
+
+Read the full [v0.0.277 notes](docs/releases/v0.0.277.md) and the
+[v0.0.278 privacy follow-up](https://github.com/justrach/codegraff/blob/release/v0.0.278/docs/releases/v0.0.278.md).
+
+### Broader comparison: model choice, footprint, and startup
<p align="center">
<img src="comparison.png" alt="graff vs Claude Code vs Codex: ~20x cheaper ($0.022 vs $0.51 vs $0.42 per task), ~25 MB vs ~410 MB vs ~206 MB peak memory, 4.4s vs 8.9s one-shot gpt-5.5 latency" width="860">
</p>
-Run the same job on graff, Claude Code, and Codex (three read-only questions about this repo, plus an 8-trial latency test), and here is what it means for you:
+The older cross-provider comparison answers a different question: what do model
+choice and a tiny native harness cost on three read-only repo tasks plus an
+eight-trial startup test?
-**Your AI bill is a fraction.** graff runs the same task on whatever model fits your budget. On `deepseek-v4-pro` it averaged **$0.022 per task**, against Claude Code's **$0.51** (Opus 4.8) and Codex's **$0.42** (gpt-5.5). That is roughly **20× cheaper**, because Claude Code only runs Claude and Codex only runs GPT, while graff runs deepseek, kimi, glm, grok, minimax, gpt, claude, and more. On the *same* model the token usage is comparable, so the win is the freedom to pick a cheaper one, not a token trick.
+**Model choice.** On `deepseek-v4-pro`, graff averaged **$0.022 per task**,
+against Claude Code's **$0.51** (Opus 4.8) and Codex's **$0.42** (gpt-5.5).
+That roughly 20× result comes from choosing a cheaper model; it is not the
+same-model harness comparison above.
-**It stays out of your way.** graff is one 2.7 MB Zig binary. In these runs it used about **25 MB of memory** for focused work (more when it reads a lot of code), against Claude Code's steady **~410 MB** (Node) and Codex's **~206 MB** (Rust). Leave it running next to everything else and your laptop won't notice.
+**Footprint.** The focused runs used about **25 MB** of memory, against Claude
+Code's steady **~410 MB** and Codex's **~206 MB**.
-**Scripts and CI finish in half the time.** For one-shot runs (`graff -p`, the SDKs, a CI step), graff completed a gpt-5.5 turn in **4.4 s** versus Codex's **8.9 s** on the identical ChatGPT endpoint, on every single trial. That is graff's near-instant startup beating a heavier per-call launch. In a long interactive session the startup amortizes and both settle to model latency, so this is a one-shot and automation win, not a blanket "graff is faster."
+**One-shot startup.** On the identical ChatGPT endpoint, graff completed a
+gpt-5.5 turn in **4.4s** versus Codex's **8.9s** in every paired trial. Long
+interactive sessions settle to model latency; this is a CLI/CI startup result,
+not a blanket speed claim.
<sub><b>Method:</b> macOS, same machine, read-only code questions on this repo. Cost is each tool's own reported usage at <a href="https://codegraff.com/docs/models">codegraff gateway prices</a>; memory is peak RSS via <code>/usr/bin/time -l</code>; latency is 8 concurrent graff/Codex pairs on a tool-free prompt with reasoning effort matched. Your numbers will vary with the task, the model, and the network. Reproduce it yourself: <a href="benchmarks/">benchmarks/</a>.</sub>
@@ -81,6 +177,7 @@ context when the conversation gets long.
**Contents**
+- [Token-efficient by construction](#token-efficient-by-construction)
- [Install](#install) · [give it a key](#give-it-a-key) · [run it](#run-it)
- [Why](#why)
- [Code intelligence](#code-intelligence-token-efficient-by-default)
diff --git a/social/graff-composer-image-privacy.png b/social/graff-composer-image-privacy.png
new file mode 100644
index 00000000..658a4b98
Binary files /dev/null and b/social/graff-composer-image-privacy.png differ
diff --git a/social/graff-rlm-spec-ptc-cost.png b/social/graff-rlm-spec-ptc-cost.png
new file mode 100644
index 00000000..c806d5f6
Binary files /dev/null and b/social/graff-rlm-spec-ptc-cost.png differ
diff --git a/social/graff-rlm-spec-ptc.png b/social/graff-rlm-spec-ptc.png
new file mode 100644
index 00000000..d4eee16a
Binary files /dev/null and b/social/graff-rlm-spec-ptc.png differ
diff --git a/social/graff-vs-grok-build-grok46.png b/social/graff-vs-grok-build-grok46.png
new file mode 100644
index 00000000..b0dcf56a
Binary files /dev/null and b/social/graff-vs-grok-build-grok46.png differ
diff --git a/social/graff-vs-grok-build-grok46.svg b/social/graff-vs-grok-build-grok46.svg
new file mode 100644
index 00000000..da48ab7c
--- /dev/null
+++ b/social/graff-vs-grok-build-grok46.svg
@@ -0,0 +1,67 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900" viewBox="0 0 1600 900" role="img" aria-labelledby="title desc">
+ <title id="title">Graff default RLM versus grok-build on grok-4.6</title>
+ <desc id="desc">Both harnesses passed five of six DeepSWE-shaped tasks. Graff used 198 seconds of summed wall time, 106 thousand input tokens, 24 model calls, and 8.5 megabytes peak RSS. grok-build used 506 seconds, 194 thousand input tokens, 39 model calls, and 177 megabytes peak RSS.</desc>
+ <rect width="1600" height="900" fill="#f7f3ea"/>
+ <path d="M86 93 C295 77 530 101 736 88" fill="none" stroke="#059669" stroke-width="8" stroke-linecap="round" opacity="0.9"/>
+ <text x="88" y="72" font-family="Avenir Next" font-size="24" font-weight="500" letter-spacing="4" fill="#059669">GRAFF · GROK-4.6</text>
+ <text x="88" y="150" font-family="Avenir Next" font-size="66" font-weight="500" fill="#1d2522">same pass rate. much lighter loop.</text>
+ <text x="90" y="198" font-family="Avenir Next" font-size="26" fill="#56615d">Same model · same six DeepSWE-shaped tasks · one live rep</text>
+
+ <g transform="translate(1362 106)" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="65" cy="65" r="62" fill="none" stroke="#1d2522" stroke-width="7" opacity="0.9"/>
+ <circle cx="65" cy="65" r="53" fill="none" stroke="#059669" stroke-width="3" opacity="0.8"/>
+ <path d="M31 65 L49 48 M31 65 L49 82 M99 65 L81 48 M99 65 L81 82 M72 40 L57 90" fill="none" stroke="#1d2522" stroke-width="7"/>
+ </g>
+
+ <g transform="translate(88 250)">
+ <rect x="0" y="74" width="1424" height="126" rx="18" fill="#e3f2eb"/>
+ <rect x="0" y="74" width="10" height="126" rx="5" fill="#059669"/>
+ <line x1="0" y1="58" x2="1424" y2="58" stroke="#aeb7b3" stroke-width="2"/>
+ <line x1="0" y1="216" x2="1424" y2="216" stroke="#c4cbc8" stroke-width="2"/>
+ <line x1="0" y1="342" x2="1424" y2="342" stroke="#aeb7b3" stroke-width="2"/>
+
+ <g font-family="Avenir Next" font-size="19" font-weight="500" letter-spacing="2" fill="#66716c">
+ <text x="28" y="39">HARNESS</text>
+ <text x="625" y="39" text-anchor="middle">PASS</text>
+ <text x="825" y="39" text-anchor="middle">SUMMED WALL</text>
+ <text x="1035" y="39" text-anchor="middle">INPUT</text>
+ <text x="1194" y="39" text-anchor="middle">CALLS</text>
+ <text x="1370" y="39" text-anchor="middle">PEAK RSS</text>
+ </g>
+
+ <g font-family="Avenir Next" fill="#1d2522">
+ <text x="28" y="151" font-size="34" font-weight="500">graff + default RLM</text>
+ <text x="625" y="151" font-size="38" font-weight="500" text-anchor="middle">5/6</text>
+ <text x="825" y="151" font-size="38" font-weight="500" text-anchor="middle">198s</text>
+ <text x="1035" y="151" font-size="38" font-weight="500" text-anchor="middle">106k</text>
+ <text x="1194" y="151" font-size="38" font-weight="500" text-anchor="middle">24</text>
+ <text x="1370" y="151" font-size="38" font-weight="500" text-anchor="middle">8.5 MB</text>
+
+ <text x="28" y="291" font-size="34">grok-build</text>
+ <text x="625" y="291" font-size="38" text-anchor="middle">5/6</text>
+ <text x="825" y="291" font-size="38" text-anchor="middle">506s</text>
+ <text x="1035" y="291" font-size="38" text-anchor="middle">194k</text>
+ <text x="1194" y="291" font-size="38" text-anchor="middle">39</text>
+ <text x="1370" y="291" font-size="38" text-anchor="middle">177 MB</text>
+ </g>
+ </g>
+
+ <g transform="translate(88 650)" font-family="Avenir Next">
+ <g fill="#059669" font-size="38" font-weight="500">
+ <text x="0" y="0">61%</text>
+ <text x="358" y="0">45%</text>
+ <text x="716" y="0">38%</text>
+ <text x="1074" y="0">95%</text>
+ </g>
+ <g fill="#56615d" font-size="19" font-weight="500" letter-spacing="1.5">
+ <text x="0" y="34">LESS SUMMED WALL</text>
+ <text x="358" y="34">LESS INPUT</text>
+ <text x="716" y="34">FEWER CALLS</text>
+ <text x="1074" y="34">LESS PEAK RSS</text>
+ </g>
+ </g>
+
+ <path d="M90 737 C404 752 742 729 1051 742 C1242 750 1379 738 1510 742" fill="none" stroke="#1d2522" stroke-width="3" stroke-linecap="round" opacity="0.6"/>
+ <text x="88" y="806" font-family="Avenir Next" font-size="24" fill="#56615d">ReleaseSafe · -j 6 · grok-4.6 via SuperGrok OAuth · both harnesses missed label-sort</text>
+ <text x="88" y="850" font-family="Andale Mono" font-size="20" fill="#7a837f">run-20260825-091123 · source: codegraff v0.0.276 release notes</text>
+</svg>
diff --git a/token-efficient-loop.png b/token-efficient-loop.png
new file mode 100644
index 00000000..8f156aa9
Binary files /dev/null and b/token-efficient-loop.png differ