
A technical walkthrough · August 2026
graff
Created byRach Pradhan·github.com/justrach/codegraff ↗
How one small agent loop becomes an evidence-driven execution-and-evolution system.
one Zig binaryprovider-neutraltools + workers

graff is the local runtime around the model.
It owns the model → tool → result loop, then gives that same loop to workers when the task earns them.
Lightweight describes the runtime, not the learning budget. A default two-arm prompt trial is roughly 180 short model runs.

The loop keeps going until the work is done.
One Agent owns the history. Every provider response is normalized into the same question: finish, or call another tool?
- 01AskSerialize for the selected provider
- 02ActRun requested tools in parallel
- 03ReturnAppend results to the same history
- 04ContinueRepeat until completion
Root responses stream. Long histories compact around the selected model's context limit.

The root and every worker run the same Agent.
A worker gets fresh context and a precise brief, then runs the same model–tool loop to completion.
Find evidence without flooding the root context.
Change the files and report the exact paths.
Check the diff and return grounded results.

CodeDB finds the code. Graff decides what to do with it.
When installed and indexed, Graff redirects supported code searches to CodeDB. The file picker falls back to a local walk.
- 01Indexsymbols + deps
- 02Routeword → prefix → trigram
- 03Verifysource lines
- 04Returnsmall context block
- CodeDB in Graff
- Structural retrieval; Graff owns execution, orchestration, and evolution
- Codex
- OpenAI coding agent across CLI, IDE, desktop, and cloud
- Grok Build
- SpaceXAI terminal agent with file, shell, web, headless, and ACP
Different layers: CodeDB retrieves context. Codex and Grok Build act. Graff uses CodeDB as an optional accelerator.

Provider choice is separate from the control plane.
The agent loop does not care whether a turn uses an API key, a subscription login, or the hosted gateway.
graff route <model>Dry-run the same provider and billing resolution a real session will use, without making a model call.

Buy only the orchestration the task earns.
Ultracode is an admission policy now, not an unconditional order to fan out.
The gate looks at cheap observables before anything spawns: named files, plan width, budget, audit language, and prior failure.

A fleet has to land work, not merely discuss it.
Collapse duplicates. Near-identical briefs with the same worker genome spawn once.
Reserve the landing. Evidence cannot consume the budget needed to implement and verify.
Require a diff. An implement phase that changes nothing becomes an error and gets one retry.
Retry honestly. Workers retry bounded transient failures in place; hard caps fail immediately.

Constraints survive because they live in the project.
Conversation memory compacts. The playbook does not.
/never→.graff/playbook.jsonl→every briefUser-stated, root-visible, never silently widened.
Advisory bullets proposed after successful evals and curated by deterministic code.
The file is read when each brief is assembled, so fresh workers and fresh sessions inherit the same rules.

Evolution is variation under evidence.
Graff proposes a child prompt, then the harness makes parent and child face the same work before either can become active.
- Seeded mutation changes one behavior
- Lineage and prompt fingerprint stay attached
- The candidate starts with no authority
- Critical regressions veto the child
- Correctness ranks before cost
- Only the primary-suite winner sees the holdout
Promotion is separate: verified evidence, every gate, then safe activation with rollback.

Codegraff evolves two things, and keeps their authority separate.
Two local evidence paths feed two governed loops.
- Mutate → paired primary suite
- Sole winner → independent holdout
- Verified promotion + rollback
- Folds landed outcome rows
- Task × budget × model stratum
- Explicit choices never vote
Same machine, separate evidence and authority. Worker retry is reliability, not evolution.

Evolution begins with a lineage you can audit.
Every run records which prompt produced which outcome, so improvement can be compared instead of guessed.
The archive is inspectable and replayable. It records candidates; it never activates them.

Prompt evolution compares parent and child on the same work.
graff learn runs seeded mutations, paired evaluation, and a sole-winner holdout before activation.
- 01Parent
- 02Seeded mutation
- 03Paired evaluation
- 04Verify + holdout
- 05Activate / reject
A normal run only recommends. Automatic promotion needs configured enablement, --auto, every statistical gate, and the holdout.

Every gate blocks a concrete way self-improvement can lie.
Pair the conditions. Parent and child face the same case and seed; repetitions stay inside one statistical unit.
Veto critical loss. One parent-pass / child-fail on a critical case rejects the candidate.
Hide a final test. Only the primary winner sees the independent holdout.
Bind the evidence. Immutable objects must match the exact active parent transaction.
Charge escalation. A higher rung owes +0.05 quality and p90 budget fit; trade-down only has to be no worse.
Correctness gates run before cost. Latency is reported, never promotion evidence.

Orchestration learning changes the route, not the prompt.
A landed turn teaches which rung and model seat can handle a similar phase within budget.
- 01Execute
- 02Outcome
- 03Local archive
- 04Policy cell
- 05Next route
This fold cannot mutate the root prompt. Explicit model or provider choices always win.

The system narrows power at every boundary.
State-changing actions pass an approval gate.
Built-in file tools remain confined to the working tree.
Fresh workers receive a deliberately smaller tool surface.
Local tools can be disabled and supplied by a sandbox MCP server.
terminal · desktop · JSON/SDK · HTTP serve · ACP/MCP

Smaller orchestration produced a better result.
1.22× the single-agent call baseline · zero budget deaths
Codegraff's deterministic five-eval study; project-reported, not an independent benchmark.
The loop stays small. Prompt and route improve through separate gates.