graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Merge stored conversation continuation for v0.302.40
justrach2801bb48387b
diff --cc docs/adr/README.mdindex 1aae9835,f36b0ae3..10aac396--- a/docs/adr/README.md+++ b/docs/adr/README.md@@@ -289,12 -289,8 +289,14 @@@ record only when you need the evidence| [0260](0260-clef-compaction-replaces-client-summary.md) | `GRAFF_CLEF_COMPACT=1` routes client-summary compactions through the gateway's server-side `POST /v1/compact` (Clef decision-model pruning, text verbatim); OpenAI-family server paths are untouched and any failure falls back to the summary. || [0261](0261-client-summary-stays-the-compactor.md) | The client summary stays the compactor: `GRAFF_CLEF_COMPACT` defaults off (Clef rarely pruned and mostly fell back to the summary in measurement); first-party Responses routes use only the provider's own compaction. Supersedes 0260's default. || [0270](0270-a-closed-stdio-mcp-server-restarts-on-its-next-call.md) | A stdio MCP server whose connection closes goes back to dormant with its launch config and restarts on its next call; the failed call is never replayed, and after two restarts in a session its tools are withdrawn as before. |+| [0278](0278-t3-code-acp-profile.md) | An ACP client named `t3-code…` gets a profile: slash commands are the first prompt block, the client's `cwd` is never swapped for an auto-isolated tree, a `model` config option lists reachable models, and `/model` and `/yolo` are not advertised. |+| [0280](0280-mcp-servers-report-state-and-reconnect.md) | Every configured MCP server has one status row (`graff mcp status --json`, `/mcp`); `graff mcp reconnect` / `/mcp reconnect` run a real handshake and refresh its catalog; `graff mcp enable|disable` live in `~/.codegraff/mcp-state.json`; the catalog cache keys on cwd + env, and server `env` overlays graff's own. |+| [0281](0281-anthropic-console-sign-in-reads-the-sdk-profile.md) | Anthropic Console sign-in: graff reads the `user_oauth` profile Anthropic's CLI writes (`ant auth login`), in the SDK's precedence (API key wins), sends it as Bearer, and refreshes through `ant auth print-credentials`; `graff login anthropic` runs `ant auth login`. No claude.ai subscription login. |+| [0282](0282-claude-system-breakpoint-closes-before-the-repo-context.md) | On Claude, the system prompt is two text blocks with the same bytes: the cache breakpoint closes the static instructions, before the project instructions and layout, so every repo shares the tools + instructions prefix. |+| [0283](0283-agents-prepare-and-linked.md) | New task worktrees symlink the gitignored paths `.agents/linked` lists from the main checkout and run `.agents/prepare` when `.graff/workspace.toml` names no setup script. |+| [0284](0284-output-limits-are-recovery-not-completion.md) | Output limits continue with bounded recovery; empty replies back off; one-shots expose a saved-session handle and classified result without claiming unknown costs or exactly-once replay. |+ | [0271](0271-gemini-interactions-continue-the-stored-interaction.md) | Direct Gemini (Interactions) requests are stored and continue the last Interaction with `previous_interaction_id` plus only the new steps while a content hash proves graff's history extends it; any rewrite, model switch or rejected id falls back to a full replay; usage meters the whole prompt from the per-invocation counts. Tool choice is `validated`, `minimal` thinking maps to `low`, thought summaries stream, and Gemini 3.1 Pro with tools uses its custom-tools variant. `GRAFF_INTERACTIONS_STORE=0` keeps it stateless. |+ | [0272](0272-compaction-never-summarizes-unread-tool-results.md) | A compaction never summarizes tool results the model has not read: the cut keeps the newest model turn and its results verbatim, and the pre-send gate sends a batch that dominates the context and compacts after the model reads it. Summaries copy exact values. Interactions `user_input` steps are turn boundaries. Gemini compacts by default at 80% capped at 300k tokens. |## When to write onediff --cc src/agent_request.zigindex 8e40114e,a85a8bf3..ed1dd6c5--- a/src/agent_request.zig+++ b/src/agent_request.zig@@@ -491,8 -498,8 +491,9 @@@ pub fn request(self: *Agent, tools_in:const eo = if (root.get("error")) |ev| (if (ev == .object) ev.object else null) else null;const etype = if (eo) |e| (if (e.get("type")) |tv| (if (tv == .string) tv.string else "error") else "error") else "error";const emsg = if (eo) |e| (if (e.get("message")) |mv| (if (mv == .string) mv.string else "") else "") else "";- const ecode = if (eo) |e| (if (e.get("code")) |cv| (if (cv == .string) cv.string else null) else null) else null;+ const ecode = errorCode(root);+ if (try quota.handle(self, etype, ecode, emsg, &auth_refreshed)) continue;+ if (@import("interactions_chain.zig").dropRejected(self, body)) continue; // stored Interaction gone → full replayif (recoverContextOverflow(self, emsg, ecode, &context_retried)) continue; // #193/#203: streamed error event overflow (by code or phrasing) → trim + retryif (policy.retryWithout(self, emsg, &force, &stream_usage)) continue; // ADR 0219: Anthropic errors take the ladder tooif (try policy.afterServerErrorOrParseReject(self, etype, ecode, emsg, &server_retries, &gw_retry)) continue;@@@ -542,8 -549,8 +543,9 @@@const eo = if (root.get("error")) |ev| (if (ev == .object) ev.object else null) else null;const etype = if (eo) |e| (if (e.get("type")) |tv| (if (tv == .string) tv.string else "error") else "error") else "error";const emsg = if (eo) |e| (if (e.get("message")) |mv| (if (mv == .string) mv.string else "") else "") else "";- const ecode = if (eo) |e| (if (e.get("code")) |cv| (if (cv == .string) cv.string else null) else null) else null;+ const ecode = errorCode(root);+ if (try quota.handle(self, etype, ecode, emsg, &auth_refreshed)) continue;+ if (@import("interactions_chain.zig").dropRejected(self, body)) continue; // stored Interaction gone → full replayif (recoverContextOverflow(self, emsg, ecode, &context_retried)) continue; // #193/#203: {"type":"error"} overflow (by code or phrasing) → trim + retryif (policy.retryWithout(self, emsg, &force, &stream_usage)) continue; // ADR 0219: Anthropic errors take the ladder tooif (try policy.afterServerErrorOrParseReject(self, etype, ecode, emsg, &server_retries, &gw_retry)) continue;@@@ -552,7 -559,7 +554,8 @@@return error.ApiError;};if (apiErrorMessage(root)) |msg| {+ if (try quota.handle(self, "", errorCode(root), msg, &auth_refreshed)) continue;+ if (@import("interactions_chain.zig").dropRejected(self, body)) continue; // stored Interaction gone → full replayif (policy.retryWithout(self, msg, &force, &stream_usage)) continue;// #148: a stale login token 401s here with the provider's "API Key// invalid/expired"; adopt a newer on-disk token or force a refresh