graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
mcp: the load result states how large list results are slimmed
justrach4ba26084e89d
diff --git a/docs/adr/0225-mcp-load-result-states-the-slim-rule.md b/docs/adr/0225-mcp-load-result-states-the-slim-rule.mdnew file mode 100644index 00000000..f1ed600b--- /dev/null+++ b/docs/adr/0225-mcp-load-result-states-the-slim-rule.md@@ -0,0 +1,28 @@+# 0225. The MCP load result states the slim rule++Status: accepted 2026-09-30++## Context++ADR 0029 slims every large MCP list result in `exec.zig`: rows keep only+`id`/`identifier`/`title`/`name`, and a comment list becomes+`{n, latest_author}`. That applies to rlm binds too. The model was only told+once two shapes were stored for the project (the `# muscle:` line), so in a+fresh project it wrote code for the full rows, failed on the first missing+field, and spent calls finding the real shape before it could finish.++A hill-climb round against a reference harness measured stating the rule on+the load result: cost per task fell on the train and the held-out split, wall+time fell, and pass rate held.++## Decision++`mcp_shapes.annotate` appends the slim rule to every `load_tool_schemas`,+`mcp_search_tools` and `mcp_select_tool` result, whether or not shapes are+stored. It never rides the catalog prefix (ADR 0011).++## Consequences++Each MCP load result carries one more sentence. The slim itself is unchanged:+a caller that needs a dropped field still cannot get it, which is a separate+decision about ADR 0029.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 15b3eca8..c44bf839 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -247,6 +247,7 @@ record only when you need the evidence or the edge cases.| [0218](0218-background-jobs-survive-a-crash.md) | A finite root job started in the background writes its output to `.graff/job-output/<id>/` with an exit receipt from its own shell, so it outlives a crashed graff. Loading the session re-attaches this session's unreported jobs under their old ids, reports what ended while graff was down, and sweeps other sessions' stale captures. Foreground commands, servers, subagent jobs and Windows keep pipes. || [0219](0219-claude-5-5-era-request-contract.md) | Claude Opus 5.5, Sonnet 5.5 and Fable 5.1 are never forced to a tool, get `drop_block` thinking binding (with its beta header), take `/effort` as `output_config.effort` (left off at graff's default), and get 64K/128K `max_tokens`. Claude errors take the same retry-without ladder as other providers; a refusal ends the turn outside history. Default model `claude-opus-5-5`, ladder opus-5-5 → sonnet-5-5. || [0220](0220-claude-prompt-cache-forks-and-pricing.md) | On the Anthropic API, compaction's note and summary fork the conversation while its cache is warm. They use the same tools, system prompt and history, with the instruction appended, so they read the history instead of rewriting it. Otherwise the old shape runs without breakpoints. A turn-opening request keeps the TTL of the last gap inside a turn. 1-hour writes bill at 2x. 5.5-era models get graff's effort as shown; titles and recaps run at low. A second breakpoint marks where the previous request wrote. |+| [0225](0225-mcp-load-result-states-the-slim-rule.md) | Every MCP load/search/select result says how large list results are slimmed (identity fields; comment lists become `{n, latest_author}`), so a fresh project does not code against dropped fields. Never on the catalog prefix. |## When to write onediff --git a/src/mcp_shapes.zig b/src/mcp_shapes.zigindex 1589fa83..968ad9af 100644--- a/src/mcp_shapes.zig+++ b/src/mcp_shapes.zig@@ -429,9 +429,10 @@ pub fn annotate(gpa: Allocator, arena: Allocator, io: Io, cwd: ?[]const u8, textstore.mu.lockUncancelable(io);defer store.mu.unlock(io);loadUnlocked(gpa, io, cwd);- if (store.map.count() == 0) return text;var aw: Io.Writer.Allocating = .init(arena);try aw.writer.writeAll(text);+ try aw.writer.writeAll(slim_rule);+ if (store.map.count() == 0) return aw.toOwnedSlice();try aw.writer.writeAll("\nreturn_shapes (field names + broad types, never values):\n");var it = store.map.iterator();while (it.next()) |e| {@@ -445,6 +446,12 @@ pub fn annotate(gpa: Allocator, arena: Allocator, io: Io, cwd: ?[]const u8, textreturn aw.toOwnedSlice();}+/// ADR 0225: what `slim` (exec.zig) does to every large list result, said+/// where the model first meets the tools. Unsaid, the model wrote code for+/// the full rows, failed on the first missing field, and spent calls finding+/// the real shape.+pub const slim_rule = "\nLarge list results from these tools come back slimmed, in rlm binds too: rows keep only id/identifier/title/name, and a comment list becomes {\"n\": count, \"latest_author\": name}. Code against those fields.";+pub fn lookup(io: Io, name: []const u8) ?[]const u8 {store.mu.lockUncancelable(io);defer store.mu.unlock(io);diff --git a/src/mcp_shapes_tests.zig b/src/mcp_shapes_tests.zignew file mode 100644index 00000000..41612b54--- /dev/null+++ b/src/mcp_shapes_tests.zig@@ -0,0 +1,22 @@+//! mcp_shapes tests moved off mcp_shapes.zig for the 600-line cap.++const std = @import("std");+const shapes = @import("mcp_shapes.zig");++test "annotate states the slim rule on every load result, stored shapes or not" {+ const gpa = std.testing.allocator;+ const io = std.testing.io;+ var tmp = std.testing.tmpDir(.{});+ defer tmp.cleanup();+ var path_buf: [std.fs.max_path_bytes]u8 = undefined;+ const dir = path_buf[0..try tmp.dir.realPath(io, &path_buf)];+ shapes.reset(gpa, io);+ defer shapes.reset(gpa, io);+ var arena_state = std.heap.ArenaAllocator.init(gpa);+ defer arena_state.deinit();+ const annotated = try shapes.annotate(gpa, arena_state.allocator(), io, dir, "1 tool schema(s) below");+ try std.testing.expect(std.mem.startsWith(u8, annotated, "1 tool schema(s) below"));+ try std.testing.expect(std.mem.indexOf(u8, annotated, "latest_author") != null);+ try std.testing.expect(std.mem.indexOf(u8, annotated, "return_shapes") == null); // nothing stored yet+ try std.testing.expect(std.mem.indexOf(u8, @import("mcp_schema_gate.zig").tool_desc, "come back slimmed") == null); // never the prefix+}diff --git a/src/test_hooks.zig b/src/test_hooks.zigindex 26919cfb..4ed7552d 100644--- a/src/test_hooks.zig+++ b/src/test_hooks.zig@@ -330,6 +330,7 @@ test {_ = retry_hint;_ = agent_compact_summary_test;_ = side_question_tests;+ _ = @import("mcp_shapes_tests.zig"); // ADR 0225: moved off mcp_shapes.zig (600-line cap)_ = json_controls;_ = effort_route;_ = agent_request_encrypted_tests;