Skip to content

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

Python

feat(lean): ask -p to batch independent reads in one turn

Cursor Agent45da6d8a5fe7
diff --git a/src/no_local_tools.zig b/src/no_local_tools.zig
index 937d1917..48f5d1ad 100644
--- a/src/no_local_tools.zig
+++ b/src/no_local_tools.zig
@@ -374,6 +374,7 @@ test "lean prompt diet: no fan-out / trace / issue-filing; short local-tools not
try std.testing.expect(std.mem.indexOf(u8, out, "gh issue create") == null);
try std.testing.expect(std.mem.indexOf(u8, out, "fan out") == null);
try std.testing.expect(std.mem.indexOf(u8, out, "Parallelize") == null);
+ try std.testing.expect(std.mem.indexOf(u8, out, "ONE response") != null);
try std.testing.expect(std.mem.indexOf(u8, out, "not covered by /rewind") == null);
try std.testing.expect(std.mem.indexOf(u8, out, "rlm") != null);
try std.testing.expect(std.mem.indexOf(u8, out, "SPEC.md") != null);
diff --git a/src/prompt_text.zig b/src/prompt_text.zig
index 803f3e13..2d6f51f4 100644
--- a/src/prompt_text.zig
+++ b/src/prompt_text.zig
@@ -263,12 +263,22 @@ pub const lean_local_tools_note =
\\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.
+ \\Independent reads belong in ONE response or one rlm script, not a chain of turns.
+;
+
+/// --lean swap-in for `parallel_core_note`. The long Parallelize / fan-out
+/// essay is dropped; without this clause -p never asks for a batch and the
+/// model spends one API call per read (ADR 0024 leftover vs grok).
+pub const lean_parallel_note =
+ \\
+ \\Independent reads and checks belong in ONE response; they run concurrently.
+ \\A call that needs an earlier result, or two writes to the same file, stays
+ \\in its own turn.
;
pub const lean_intro_note =
\\You are a coding agent. Use the cataloged tools; never invent one.
- \\Prefer one rlm script when several reads or edits are independent.
+ \\Independent reads belong in ONE response (or one rlm script), not one per turn.
;
pub const lean_work_note =
@@ -295,7 +305,9 @@ pub fn leanSegment(name: []const u8, original: []const u8, is_lean: bool) ?[]con
if (!is_lean) return original;
if (std.mem.eql(u8, name, "trace") or std.mem.eql(u8, name, "harness_issue") or
std.mem.eql(u8, name, "headsup") or std.mem.eql(u8, name, "git_safety") or
- std.mem.eql(u8, name, "root_cause") or std.mem.startsWith(u8, name, "parallel_")) return null;
+ std.mem.eql(u8, name, "root_cause") or std.mem.eql(u8, name, "parallel_examples") or
+ std.mem.eql(u8, name, "parallel_tail")) return null;
+ if (std.mem.eql(u8, name, "parallel_core")) return lean_parallel_note;
if (std.mem.eql(u8, name, "intro")) return lean_intro_note;
if (std.mem.eql(u8, name, "local_tools")) return lean_local_tools_note;
if (std.mem.eql(u8, name, "work")) return lean_work_note;
diff --git a/src/rlm.zig b/src/rlm.zig
index 95440ede..a39e5dcd 100644
--- a/src/rlm.zig
+++ b/src/rlm.zig
@@ -24,7 +24,7 @@ pub const tool_name = "rlm";
pub const tool_desc = "Programmatic tool calling (RLM + sPTC). Script whose functions ARE this session's tools. Independent literal read_file/codedb/bash/webfetch/sleep_ms/llm_query/subagent calls start as the script streams. Binds persist across rlm calls. subagent(\"task\") is sidecar-only (keep the critical-path next step local; sync in v1; run_in_background=true returns an id). print() is the answer. Example: a = read_file(\"src/main.zig\"); b = codedb(\"status\"); print(a, b). No imports, no control flow. Prefer one rlm over N tool calls.";
/// --lean catalog desc: same contract, no REPL essay. maybeAppend is after
/// compactLeanSpecs, so this is the one-shot wire text.
-pub const lean_tool_desc = "Script of this session's tools. read_file/edit_file/write_file/codedb/bash/llm_query are functions here, not catalog tools. Literal calls start as it streams. Binds persist. print(...) is the answer. Prefer one rlm over N calls.";
+pub const lean_tool_desc = "Batch independent read_file/edit_file/write_file/codedb/bash here. Those names are also catalog tools — use either a script or several catalog calls in ONE response. Literal calls start as it streams. Binds persist. print(...) is the answer.";
pub const tool_schema =
\\{"type": "object", "properties": {"code": {"type": "string", "description": "Python-like script: name = read_file(\"path\") / codedb(\"command\") / bash(\"cmd\") / sleep_ms(ms) / llm_query(\"prompt\") / subagent(\"task\"); print(...) is the result. Assignments persist across rlm calls. Semicolons or newlines separate statements."}}, "required": ["code"]}
;