graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(lean): advertise load_tool_schemas when MCP is deferred
Cursor Agent48f6ffdbbb45
diff --git a/docs/adr/0024-three-harness-compare-prompt-subagent-rss.md b/docs/adr/0024-three-harness-compare-prompt-subagent-rss.mdindex 26f7a36f..63587782 100644--- a/docs/adr/0024-three-harness-compare-prompt-subagent-rss.md+++ b/docs/adr/0024-three-harness-compare-prompt-subagent-rss.md@@ -267,12 +267,18 @@ A "say OK" one-shot was **3880 in** (13.9kB body): `load_tool_schemas``read_tool_result` overflow paging, long intro/work/closing/gitessays, duplicate `rlm` system_note.-**Take:** hide the meta tool on lean even when home MCP is deferred-(need MCP? `--no-lean`); drop the pager from `lean_tools`; short-`lean_intro` / `lean_work` / `lean_closing` (SPEC clause kept); no-git-safety / root-cause / authoring / rlm system_note on -p.--First-request after that: **2660 in**, 8.7kB body, 7 tools+**Take:** drop the pager from `lean_tools`; short `lean_intro` /+`lean_work` / `lean_closing` (SPEC clause kept); no git-safety /+root-cause / authoring / rlm system_note on -p. Hide+`load_tool_schemas` on lean only when nothing is deferred (empty+MCP / all eager) — SWE sandboxes stay cheap. Do **not** always-hide+on lean: a connected server (Smolify CI) lists public tools in that+description. Home MCP that actually connects pays the 1.4kB tool+again; that is correct (the tool is usable). Need the full catalog?+`--no-lean`.++First-request after that (empty MCP, the SWE sandbox shape): **2660+in**, 8.7kB body, 7 tools(bash/read/edit/write/codedb/attempt_completion/rlm).SWE (`run-20260825-073458.jsonl`, graff-dev):diff --git a/src/mcp_schema_gate.zig b/src/mcp_schema_gate.zigindex c7d56ffa..f7eda7bd 100644--- a/src/mcp_schema_gate.zig+++ b/src/mcp_schema_gate.zig@@ -295,9 +295,9 @@ pub fn hiddenSpec(name: []const u8, all: []const mcp.Tool) bool {std.mem.eql(u8, name, "mcp_search_tools") orstd.mem.eql(u8, name, "mcp_select_tool");if (!progressive) return false;- // -p: home MCP still counts as deferred and kept the 1.4kB meta tool- // on every turn. One-shots that need MCP pass --no-lean.- if (@import("no_local_tools.zig").lean) return true;+ // Lean still consults this: schema.zig skips only when nothing is+ // deferred (empty MCP / all eager). A connected server (Smolify)+ // stays advertised so the listing in the description is reachable.return !anyDeferred(all);}diff --git a/src/mcp_schema_gate_tests.zig b/src/mcp_schema_gate_tests.zigindex 4e7f5d30..cc866143 100644--- a/src/mcp_schema_gate_tests.zig+++ b/src/mcp_schema_gate_tests.zig@@ -357,6 +357,32 @@ test "an eager tool is never blocked, and the load tool is advertised only whentry testing.expect(!gate.blocked(fat, "mcp__fat__ghost"));}+test "lean hides load_tool_schemas only when nothing is deferred" {+ // -p / --lean must not always-hide: Smolify (and any connected MCP)+ // lists public tools in the meta tool's description. Empty MCP still+ // drops the 1.4kB stub (schema.zig's lean-or-!anyFolded skip).+ const schema = @import("schema.zig");+ const no_local = @import("no_local_tools.zig");+ withDefaults();+ defer withDefaults();+ const saved = no_local.lean;+ defer no_local.lean = saved;+ no_local.lean = true;+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);+ defer arena_state.deinit();+ const arena = arena_state.allocator();++ try testing.expect(gate.hiddenSpec(gate.tool_name, &.{}));+ const specs = try schema.effectiveRootSpecs(arena);+ const empty = try schema.renderRootTools(arena, .openai, specs, &.{});+ try testing.expect(std.mem.indexOf(u8, empty, gate.tool_name) == null);++ const fat = try fixture(arena, "fat", 8, 2000);+ try testing.expect(!gate.hiddenSpec(gate.tool_name, fat));+ const with_mcp = try schema.renderRootTools(arena, .openai, specs, fat);+ try testing.expect(std.mem.indexOf(u8, with_mcp, gate.tool_name) != null);+}+test "tool_desc stays JSON-escape-free (it is spliced into a raw schema string)" {for (gate.tool_desc) |c| try testing.expect(c != '"' and c != '\\' and c >= 0x20);try testing.expect(std.mem.indexOf(u8, gate.tool_desc, "CANNOT be called") != null);