Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

revert(lean): keep file/shell tools on the one-shot catalog

Cursor Agent6574b9ead2cf
diff --git a/lean-proofs/Graff/ToolCatalog.lean b/lean-proofs/Graff/ToolCatalog.lean
index 51836243..1b7d1a9e 100644
--- a/lean-proofs/Graff/ToolCatalog.lean
+++ b/lean-proofs/Graff/ToolCatalog.lean
@@ -26,7 +26,8 @@ def localTools : List String :=
"write_file", "codedb", "read_tool_result", "imagegen"]
def leanTools : List String :=
- ["attempt_completion", "load_tool_schemas"]
+ ["bash", "read_file", "edit_file", "write_file", "codedb",
+ "subagent", "attempt_completion", "load_tool_schemas"]
def optionalTools : List String :=
["imagegen"]
@@ -126,8 +127,7 @@ theorem cube_unique :
example : mem "webfetch" localTools = false := by native_decide
example : mem "imagegen" localTools = true := by native_decide
example : mem "imagegen" leanTools = false := by native_decide
-example : mem "subagent" leanTools = false := by native_decide
-example : mem "attempt_completion" leanTools = true := by native_decide
+example : mem "subagent" leanTools = true := by native_decide
example : unique (baseTools ++ metaTools ++ rootExtras) = true := by native_decide
example : catalog {} =
diff --git a/spec/kernels/tool_catalog.json b/spec/kernels/tool_catalog.json
index bc196383..7d7726ba 100644
--- a/spec/kernels/tool_catalog.json
+++ b/spec/kernels/tool_catalog.json
@@ -49,6 +49,12 @@
"imagegen"
],
"lean": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
+ "subagent",
"attempt_completion",
"load_tool_schemas"
]
@@ -593,8 +599,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"imagegen"
@@ -637,8 +649,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"imagegen"
@@ -681,8 +699,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"imagegen"
@@ -725,8 +749,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"imagegen"
@@ -769,8 +799,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": []
},
@@ -810,8 +846,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": []
},
@@ -851,8 +893,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": []
},
@@ -892,8 +940,14 @@
"seat": "root"
},
"advertised": [
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": []
},
@@ -1470,7 +1524,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1522,7 +1577,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1574,7 +1630,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1626,7 +1683,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1678,7 +1736,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1730,7 +1789,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1782,7 +1842,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
@@ -1834,7 +1895,8 @@
},
"advertised": [
"attempt_completion",
- "load_tool_schemas"
+ "load_tool_schemas",
+ "subagent"
],
"blocked": [
"bash",
diff --git a/spec/kernels/tool_catalog.md b/spec/kernels/tool_catalog.md
index 2de7bd2f..c734fd9a 100644
--- a/spec/kernels/tool_catalog.md
+++ b/spec/kernels/tool_catalog.md
@@ -11,8 +11,7 @@ always in this order:
two compile-time optional rows).
2. **Add** every `#352` optional whose flag is on (`imagegen` today).
3. **Subtract** `#330` `--no-local-tools` (host-touching built-ins).
-4. **Keep** `--lean` (`attempt_completion` + `load_tool_schemas`;
- `rlm` is a session overlay, not this cube). Description compaction does
+4. **Keep** `--lean` (eight one-shot tools). Description compaction does
not change names.
A subagent starts from `base_specs` only (no meta, no `subagent`), then
@@ -28,7 +27,7 @@ run the keep-list.
| root extras | `subagent` `workflow` `agent_output` `learn_candidate` `peer_message` `workspace` |
| optional | `imagegen` |
| local (`#330`) | `bash` `bash_output` `bash_kill` `read_file` `edit_file` `write_file` `codedb` `read_tool_result` `imagegen` |
-| lean keep | `attempt_completion` `load_tool_schemas` |
+| lean keep | `bash` `read_file` `edit_file` `write_file` `codedb` `subagent` `attempt_completion` `load_tool_schemas` |
`webfetch`, every meta tool except the lean keepers, and every `mcp__*`
name are **not** local. MCP is outside this kernel.
diff --git a/spec/ref/tool_catalog.py b/spec/ref/tool_catalog.py
index 38b000db..4f09fdde 100644
--- a/spec/ref/tool_catalog.py
+++ b/spec/ref/tool_catalog.py
@@ -22,6 +22,12 @@ LOCAL_TOOLS = (
"imagegen",
)
LEAN_TOOLS = (
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
+ "subagent",
"attempt_completion",
"load_tool_schemas",
)
diff --git a/src/cli.zig b/src/cli.zig
index 7bd28085..650b128a 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -251,7 +251,7 @@ pub const usage_text =
\\ --yolo skip all permission prompts for the session
\\ --rlm advertise the rlm REPL (default; persistent binds, subagent(), llm_query, mid-stream spec-ptc; GRAFF_RLM=1)
\\ --old, --no-rlm restore the pre-rlm structured-only catalog (GRAFF_OLD=1 or GRAFF_RLM=0)
- \\ --lean slim tool surface (rlm + attempt_completion) + MCP deferred behind load_tool_schemas — the DEFAULT for -p one-shots (GRAFF_LEAN=1)
+ \\ --lean slim tool surface (8 core tools) + MCP deferred behind load_tool_schemas — the DEFAULT for -p one-shots (GRAFF_LEAN=1)
\\ --no-lean opt a one-shot out of the implied --lean: full tool surface + eager MCP, the pre-default -p behavior
\\ --no-local-tools embedder mode: hard-disable the built-in bash/bash_output/bash_kill/read_file/edit_file/write_file/codedb tools for the whole process (subagents included), so graff can run outside the sandbox and get its coding tools from an MCP server instead; webfetch, orchestration and MCP tools still work (GRAFF_NO_LOCAL_TOOLS=1)
\\ -p, --print one-shot print mode (answer on stdout, progress on stderr)
diff --git a/src/no_local_tools.zig b/src/no_local_tools.zig
index 163dc797..937d1917 100644
--- a/src/no_local_tools.zig
+++ b/src/no_local_tools.zig
@@ -67,21 +67,22 @@ pub fn blocks(name: []const u8) bool {
/// --lean / GRAFF_LEAN=1 tool surface — the token-cost counterpart of the MCP
/// skip (session_start.leanSkipsMcp reads the same flag/env). A one-shot
-/// coding task advertises rlm + attempt_completion; file/shell work is
-/// rlm host functions so the prefix is not re-sent as five native schemas
-/// on every turn. Unlike #330 this is NOT a security boundary, so there
-/// is no dispatch layer: an unadvertised tool is simply unknown to the
-/// model, and a hallucinated call fails like any bad tool name.
+/// coding task keeps the file/shell tools plus attempt_completion; every
+/// other schema is prefix re-sent on EVERY model turn. Unlike #330 this
+/// is NOT a security boundary: an unadvertised tool is simply unknown.
pub var lean: bool = false;
-/// The lean keep-list. Structured file/shell tools stay callable as
-/// `rlm` host functions (maybeAppend adds `rlm`); advertising them as
-/// their own catalog entries made grok-4.6 do N read/edit turns
-/// instead of one script (ADR 0024: 41 calls vs grok's 31).
-/// `load_tool_schemas` stays so a connected MCP server can unfold; it
-/// is hidden on lean (schema.zig / hiddenSpec). Overflow paging
-/// (`read_tool_result`) is interactive — drop it from -p.
+/// The lean keep-list. File/shell tools stay on the wire: an rlm-only
+/// catalog (ADR 0024 follow-up) made grok-4.6 retry scripts for 122
+/// calls / 4/6. `load_tool_schemas` stays so MCP can unfold; it is
+/// hidden on lean. Overflow paging (`read_tool_result`) is interactive.
pub const lean_tools = [_][]const u8{
+ "bash",
+ "read_file",
+ "edit_file",
+ "write_file",
+ "codedb",
+ "subagent",
"attempt_completion",
"load_tool_schemas",
};
@@ -219,15 +220,13 @@ test "lean: the filter keeps exactly the seven one-shot tools, and allocates not
lean = true;
const kept = try filterLeanSpecs(Spec, arena, &specs);
- try std.testing.expectEqual(@as(usize, 1), kept.len);
- try std.testing.expectEqualStrings("attempt_completion", kept[0].name);
- // Keep-list is two names: attempt_completion + load_tool_schemas (MCP
- // unfold). File/shell work is rlm host functions, not catalog rows.
- try std.testing.expectEqual(@as(usize, 2), lean_tools.len);
+ try std.testing.expectEqual(@as(usize, 4), kept.len);
+ try std.testing.expectEqualStrings("bash", kept[0].name);
+ try std.testing.expectEqualStrings("read_file", kept[1].name);
+ try std.testing.expectEqualStrings("subagent", kept[2].name);
+ try std.testing.expectEqualStrings("attempt_completion", kept[3].name);
+ try std.testing.expectEqual(@as(usize, 8), lean_tools.len);
try std.testing.expect(!leanKeeps("read_tool_result"));
- try std.testing.expect(!leanKeeps("bash"));
- try std.testing.expect(!leanKeeps("read_file"));
- try std.testing.expect(!leanKeeps("subagent"));
for (lean_tools) |tool| try std.testing.expect(leanKeeps(tool));
try std.testing.expect(!leanKeeps("workflow"));
try std.testing.expect(!leanKeeps("todo_write"));
@@ -395,7 +394,5 @@ test "lean catalog drops overflow pager and empty load_tool_schemas" {
const json = try schema.renderRootTools(arena, .openai, specs, &.{});
try std.testing.expect(std.mem.indexOf(u8, json, "read_tool_result") == null);
try std.testing.expect(std.mem.indexOf(u8, json, "load_tool_schemas") == null);
- try std.testing.expect(std.mem.indexOf(u8, json, "\"bash\"") == null);
- try std.testing.expect(std.mem.indexOf(u8, json, "\"read_file\"") == null);
try std.testing.expect(std.mem.indexOf(u8, json, "\"rlm\"") != null);
}
diff --git a/src/prompt_text.zig b/src/prompt_text.zig
index e991e715..803f3e13 100644
--- a/src/prompt_text.zig
+++ b/src/prompt_text.zig
@@ -260,14 +260,15 @@ pub const parallel_tools_note = parallel_core_note ++ parallel_examples_note ++
/// covers the !yolo map). Same edit discipline, ~1k fewer prefix bytes.
pub const lean_local_tools_note =
\\
- \\File and shell work is inside rlm: read_file, edit_file, write_file,
- \\codedb, and bash are script functions, not catalog tools. print() is
- \\the answer. Prefer one rlm over a chain of calls.
+ \\read_file before editing; prefer edit_file for existing files and
+ \\write_file only for new files. Navigate with codedb (context, around,
+ \\callpath, list_dir, status) or one rlm script of those functions.
+ \\Prefer one rlm over a chain of calls when the reads are independent.
;
pub const lean_intro_note =
- \\You are a coding agent. Do the work with rlm — a script whose
- \\functions ARE this session's tools. Never invent a catalog tool.
+ \\You are a coding agent. Use the cataloged tools; never invent one.
+ \\Prefer one rlm script when several reads or edits are independent.
;
pub const lean_work_note =
diff --git a/src/rlm.zig b/src/rlm.zig
index 8ecad31e..95440ede 100644
--- a/src/rlm.zig
+++ b/src/rlm.zig
@@ -465,7 +465,7 @@ test "maybeAppend keeps subagent and workflow; rlm is never the only catalog too
try std.testing.expect(!catalogHas(off, tool_name));
}
-test "effectiveRootSpecs: default rlm keeps subagent; --old keeps it; --lean drops structured tools" {
+test "effectiveRootSpecs: default rlm keeps subagent; --old and --lean do not drop it" {
const schema = @import("schema.zig");
const root = @import("main.zig");
const learn_store = @import("learn_store.zig");
@@ -509,11 +509,11 @@ test "effectiveRootSpecs: default rlm keeps subagent; --old keeps it; --lean dro
no_local_tools.lean = true;
sync();
const lean_on = try schema.effectiveRootSpecs(arena);
- try std.testing.expect(!catalogHas(lean_on, "subagent"));
+ try std.testing.expect(catalogHas(lean_on, "subagent"));
try std.testing.expect(catalogHas(lean_on, tool_name));
try std.testing.expect(!catalogHas(lean_on, "workflow"));
- try std.testing.expect(!catalogHas(lean_on, "bash"));
- try std.testing.expect(!no_local_tools.leanKeeps("subagent"));
+ try std.testing.expect(catalogHas(lean_on, "bash"));
+ try std.testing.expect(no_local_tools.leanKeeps("subagent"));
try std.testing.expect(!no_local_tools.leanKeeps(tool_name));
}
diff --git a/src/schema_protocol.zig b/src/schema_protocol.zig
index bed155b2..f350156c 100644
--- a/src/schema_protocol.zig
+++ b/src/schema_protocol.zig
@@ -17,7 +17,7 @@ pub const flags =
\\ {"flag": "--yolo", "arg": null, "description": "skip all permission prompts for the session"},
\\ {"flag": "--rlm", "arg": null, "description": "advertise the rlm REPL (default). Last flag wins vs --old. GRAFF_RLM=1 is the env form"},
\\ {"flag": "--old", "arg": null, "description": "restore the pre-rlm structured-only catalog. --no-rlm is an alias. GRAFF_OLD=1 or GRAFF_RLM=0"},
- \\ {"flag": "--lean", "arg": null, "description": "slim the tool surface to rlm plus attempt_completion and connect MCP servers DEFERRED behind the load_tool_schemas meta tool (names + one-line descriptions up front, full schemas on demand) instead of paying every server's schemas in every model turn. DEFAULT for -p one-shots; GRAFF_LEAN=1 forces it on anywhere"},
+ \\ {"flag": "--lean", "arg": null, "description": "slim the tool surface to 8 core tools and connect MCP servers DEFERRED behind the load_tool_schemas meta tool (names + one-line descriptions up front, full schemas on demand) instead of paying every server's schemas in every model turn. DEFAULT for -p one-shots; GRAFF_LEAN=1 forces it on anywhere"},
\\ {"flag": "--no-lean", "arg": null, "description": "opt a one-shot out of the implied --lean: full tool surface and eager MCP schemas, the pre-default -p behavior"},
\\ {"flag": "--add-dir", "arg": "path", "description": "extra workspace root file tools may touch (repeatable, max 16). Complementary to workspace switch; extra roots do not contribute skills or sessions"},
\\ {"flag": "--context-limit", "arg": "name=N", "description": "named prefix byte cap: skill_catalog_bytes, mcp_schema_bytes, or agents_md_bytes (repeatable). GRAFF_CONTEXT_LIMIT is the env form"},