graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
docs(adr): start the ADR log with 0001 — structured outputs are a formatting step
Rach Pradhan06a65bf28da1
diff --git a/AGENTS.md b/AGENTS.mdindex e3465010..d4a9b5e8 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,13 @@# Repository instructions+## Decisions live in docs/adr/++Settled, evidence-backed decisions are recorded as ADRs. Read the one-line+index in [docs/adr/README.md](docs/adr/README.md) before changing behavior a+record covers; what looks like an easy improvement may be a measured+regression (see ADR 0001 on structured outputs). When your change settles a+new load-bearing decision, add a record in the same branch.+## Terminal UI: what's ours to change- **Colors, bold/dim, glyphs, layout are ours.** Styling travels in the output byte stream as SGR escape sequences, so the app controls it per character. The palette lives in `src/ansi.zig` (the accent is codegraff.com's emerald `#059669`; coral/red hues are reserved for errors).diff --git a/docs/adr/0001-structured-outputs-are-a-formatting-step.md b/docs/adr/0001-structured-outputs-are-a-formatting-step.mdnew file mode 100644index 00000000..ff48a13b--- /dev/null+++ b/docs/adr/0001-structured-outputs-are-a-formatting-step.md@@ -0,0 +1,45 @@+# 0001. Structured outputs are a formatting step, not a decoding constraint++Status: accepted 2026-08-15++## Context++`--output-schema` (#502) originally applied the strict schema grammar to+every message in the session. On grok-4.6 the grammar pulled the model into+answering immediately in the required shape instead of using its tools+first: on the graff-evals file-inspection task it guessed a plausible answer+without opening the file, and the schema task passed 1/3. Constrained+decoding during the agentic phase suppresses exactly the tool-use behavior+that makes answers correct. Two related findings from the same work:+grok-4.6 leaks a literal `<|eos|>` after strict-schema JSON (now stripped),+and structured output adds no accuracy on its own; identical answers arrive+with or without it.++## Decision++- The agentic phase always runs unconstrained. No schema grammar, response+ format, or text format is attached to any turn that may use tools.+- When a schema is requested, it is satisfied by one final tools-off,+ low-effort formatting turn in the same conversation that restates the+ answer the agentic phase already produced (the two-phase one-shot in+ `src/session_run.zig`).+- `--output-schema` is not a default and should not be reached for+ reflexively. Use it when a program consumes the result (pipelines, evals,+ SDK callers) and skip it when a human reads the answer.++## Consequences++- Task accuracy is unaffected by requesting a schema: the schema task went+ 3/3 after the split (re-confirmed 3/3 on the v0.0.258 release build), and+ the answer content matches the unconstrained run.+- Machine consumers get guaranteed-parseable output with no prose preamble,+ which is why graff-evals grades by exact value and why this is a+ capability edge over harnesses without schema support.+- Cost when used: one extra cheap turn (tools off, low effort), a few+ seconds and a few hundred tokens.+- Revisit if a provider ships constrained decoding that provably preserves+ tool-use behavior mid-session; until then, any change that attaches a+ grammar to intermediate turns is a regression, not an optimization.++Evidence: #502, `graff-evals/tasks/10-schema-output.json` (the task that+caught both bugs), the two-phase block in `src/session_run.zig`.diff --git a/docs/adr/README.md b/docs/adr/README.mdnew file mode 100644index 00000000..18f8f881--- /dev/null+++ b/docs/adr/README.md@@ -0,0 +1,45 @@+# Architecture Decision Records++Settled decisions with their reasoning, so nobody (human or agent) has to+re-derive or re-litigate them from scratch. Each record is one decision: the+context that forced it, what was decided, and what it costs.++**Start here.** The index below gives you the rule in one line; open the+record only when you need the evidence or the edge cases.++## Index++| ADR | The rule |+|---|---|+| [0001](0001-structured-outputs-are-a-formatting-step.md) | Structured output is a final formatting step. Never constrain the agentic phase with a schema grammar, and do not use `--output-schema` unless a program consumes the result. |++## When to write one++Write an ADR when a decision is load-bearing and non-obvious: it was reached+through measurement, a debate, or a failure, and someone later would+plausibly "fix" it back. Do not write ADRs for conventions the linter or+tier 1 already enforces (those live in [AGENTS.md](../../AGENTS.md)).++## How to add one++1. Copy the template below into `docs/adr/NNNN-short-slug.md` (next free number).+2. Add one row to the index above with the rule stated in one line.+3. Keep it under a page. Evidence beats prose: link the eval, issue, or commit.++```markdown+# NNNN. Title stating the decision++Status: accepted YYYY-MM-DD++## Context++What forced a decision, with the measurements or failures that framed it.++## Decision++What we do now, stated so a reader can comply without reading anything else.++## Consequences++What this costs, what it protects, and what would justify revisiting it.+```