Skip to content

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

Python

fix(prompt,jobs): narrate in-band, ask via ask_user, no wake for an exit already read (ADR 0061)

justrach7cc6eb835382
diff --git a/docs/adr/0061-tool-only-turns-narrate-and-ask-in-band.md b/docs/adr/0061-tool-only-turns-narrate-and-ask-in-band.md
new file mode 100644
index 00000000..2949e76c
--- /dev/null
+++ b/docs/adr/0061-tool-only-turns-narrate-and-ask-in-band.md
@@ -0,0 +1,104 @@
+# 0061. Tool-only turns narrate in-band, and a choice for the user is an `ask_user` call
+
+Status: accepted 2026-09-03
+
+## Context
+
+Two interactive TUI trajectories on the same harness build (0.0.284), the
+same repository, both `--yolo` at effort `high`, read from their
+`.graff/traces` operational traces and saved transcripts. Gemini flash went
+through the Codegraff gateway (chat-completions shape); Grok went through the
+xAI WebSocket transport (Responses shape).
+
+| | gemini-3.8-flash | grok-4.6 |
+|---|---:|---:|
+| user turns | 8 | 5 |
+| model calls | 274 | 82 |
+| tool calls | 251 | 130 |
+| `bash` share of tool calls | 198 (79%) | 27 (21%) |
+| `read_file` / `codedb` calls | 34 / 1 | 47 / 23 |
+| responses carrying text *and* tool calls | 0 of 259 | 9 of 77 |
+| tool errors | 23 | 4 |
+| job-exit wakes for an exit the model had already read | 6 | 0 |
+| ...of which answered with a `bash_output` snapshot that returned nothing | 2 | 0 |
+| peak context (tokens) | 323k | 227k |
+| stream stalls recovered by reconnect | 1 | 2 |
+
+Gemini did the work. It installed and drove a third-party CLI harness, ran
+the same seven eval tasks through three harnesses, plotted the frontier,
+committed, and when the release branch had moved under it, cherry-picked
+onto the remote tip in a scratch worktree and pushed. Three harness-side
+things went wrong around that work, none of them the model's competence:
+
+1. **Silence.** Not one of Gemini's 259 tool-calling responses carried a
+ sentence of text; its narration all went into thinking blocks. Grok
+ narrates at phase boundaries: a one-line "found X, next Y" ahead of the
+ calls, in the same response. The prompt's heads-up note asked for a
+ heads-up but never said *where* it goes, and a model that answers every
+ step with bare function calls satisfies "give a heads-up" by thinking
+ it. The user's only signal was tool chrome, and a multi-minute stretch
+ (a tier-1 run, then a `git push --dry-run` whose pre-push hook ran
+ tier-1 again, promoted to a background job) read as a hang. The user
+ interrupted.
+2. **A menu in prose.** Asked to push, Gemini hit a non-fast-forward, tried
+ a merge that conflicted, and ended the turn with three lettered options
+ and "how would you like to proceed?" as plain text. `ask_user` exists
+ for exactly that: it renders options as a numbered picker, blocks for
+ the reply, and on `--json`/ACP is its own event a client can draw. The
+ tool description said "use for a decision"; the work note said "ask"
+ without naming the tool. The user typed a letter and it worked, but only
+ because a terminal was attached and a human was reading.
+3. **Wake-ups for output already read.** Six times the model learned a
+ job's fate first-hand (four blocking `bash_output` waits that returned
+ the exit status and the full output, two `bash_kill` calls) and was then
+ woken at the next step boundary with "unread output via bash_output; do
+ not poll". Twice it obeyed, called `bash_output` again, and got "(no new
+ output)". On an idle TUI that wake is a whole model turn. And when the
+ user interrupted a blocking wait, the tool result read
+ "running · 36000s elapsed": the Esc path set the elapsed counter to the
+ 10-hour deadline sentinel.
+
+The `bash` share is mostly legitimate (a tool installed outside the cwd,
+`git`, `npm`, the eval runner) and the codedb guard fired once and was
+obeyed. Grok, by contrast, set the guard's opt-out env var on 17 of its 27
+bash calls. Neither is changed here.
+
+## Decision
+
+- **Narration goes in the response with the calls.** The heads-up note now
+ says the text rides in the SAME response as the tool calls it introduces,
+ that a response that is only tool calls shows the user nothing but a
+ spinner, and that a command that can run for minutes (a build, a test
+ suite, a push whose hooks run tests) is announced together with what it
+ waits on.
+- **A choice is an `ask_user` call.** The work note names the tool ("ask
+ with ask_user, the choices in options") and says a menu of options in
+ prose renders no picker and waits for nothing; the tool description says
+ the same. `ask_user` is in every root catalog, and with no human attached
+ it already answers "make a reasonable assumption and continue", so the
+ instruction is safe in `-p` and for subagents.
+- **An exit the model already observed does not wake it.** `bash_output`
+ returning a finished job's status dismisses that job's queued notice, and
+ remembers the id if the pump has not queued it yet (it records right
+ after flipping `done`). `bash_kill` reporting a dead job does the same.
+ The wake line is for a job the model never went back to. The hosted-sink
+ `job_completed` event still fires; that is UI, not a wake.
+- **An interrupted wait reports what it waited.** "running · 36s waited,
+ then interrupted — you are notified on exit" instead of the deadline.
+
+## Consequences
+
+- Two prompt segments changed, so the golden in `prompt_snapshot_tests.zig`
+ changed with them, and the prefix cache invalidates once per session on
+ upgrade as any prompt edit does.
+- A model that still answers with bare calls after this is a model finding,
+ not a prompt one. Measure again before adding harness-side nudging: an
+ injected "say what you are doing" turn would cost what it saves.
+- Prose-menu detection in the harness was considered and rejected. It is a
+ heuristic on free text, and the interactive path already works when the
+ user types the letter. If a `--json` or ACP client shows the same miss,
+ revisit with an unanswered-question bounce in the shape of ADR 0052.
+- Open, not fixed here: the model pasted a user-supplied credential into
+ four shell commands before moving it to a file, and the saved transcript
+ keeps those commands verbatim. A redaction pass for known key shapes is
+ its own decision.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 0fe73988..2f95c5a5 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -71,6 +71,7 @@ record only when you need the evidence or the edge cases.
| [0058](0058-compact-cut-stalls-on-no-progress.md) | Same unresolved `compact_cut` pin that does not shrink stops after two tries. |
| [0059](0059-saved-session-discovery-is-device-scoped.md) | `/resume` and `/sessions` list cwd then `~/.graff/sessions`; resume keeps tools in the current cwd. |
| [0060](0060-named-source-gate-is-per-unanswered-mention.md) | The named-source nudge is per unanswered mention; identical user turns do not replay (#714). |
+| [0061](0061-tool-only-turns-narrate-and-ask-in-band.md) | Heads-up text rides in the same response as the tool calls; a choice for the user is an `ask_user` call; a job exit the model already read never wakes it. |
## When to write one
diff --git a/src/job_notify.zig b/src/job_notify.zig
index 6cf4b988..074b2970 100644
--- a/src/job_notify.zig
+++ b/src/job_notify.zig
@@ -22,6 +22,11 @@ const cap: usize = 16;
var mu: Io.Mutex = .init;
var ring: [cap]Notice = undefined;
var count: usize = 0;
+/// Ids whose exit the model already read through bash_output / bash_kill
+/// before the pump queued the notice (it records right after flipping
+/// `done`, so the read can land in between). Bounded like the ring. ADR 0061.
+var dismissed: [cap]u32 = undefined;
+var dismissed_len: usize = 0;
fn clipCmd(cmd: []const u8) struct { buf: [48]u8, len: u8 } {
const t = std.mem.trim(u8, cmd, " \t\r\n");
@@ -50,23 +55,78 @@ fn wakeLine(buf: []u8, n: Notice) []const u8 {
}
/// Pump thread: the job is done. Queues a reminder and, if a turn is live,
-/// paints a TUI/REPL notice immediately.
+/// paints a TUI/REPL notice immediately. A job whose exit the model already
+/// read (dismiss ran first) still reaches the hosted sink — that event is
+/// UI, not a wake.
pub fn record(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8) void {
const clipped = clipCmd(cmd);
const n = Notice{ .id = id, .exit_code = exit_code, .killed = killed, .preview = clipped.buf, .preview_len = clipped.len };
mu.lockUncancelable(io);
- if (count == cap) {
- std.mem.copyForwards(Notice, ring[0 .. cap - 1], ring[1..cap]);
- count = cap - 1;
+ if (dismissedIndex(id)) |i| {
+ std.mem.copyForwards(u32, dismissed[i .. dismissed_len - 1], dismissed[i + 1 .. dismissed_len]);
+ dismissed_len -= 1;
+ } else {
+ if (count == cap) {
+ std.mem.copyForwards(Notice, ring[0 .. cap - 1], ring[1..cap]);
+ count = cap - 1;
+ }
+ ring[count] = n;
+ count += 1;
}
- ring[count] = n;
- count += 1;
mu.unlock(io);
if (engine_sink.hostedSink()) |sink| {
sink.emit(io, .{ .job_completed = .{ .id = id, .exit_code = exit_code, .killed = killed } });
}
}
+/// Caller holds `mu`.
+fn dismissedIndex(id: u32) ?usize {
+ for (dismissed[0..dismissed_len], 0..) |d, i| if (d == id) return i;
+ return null;
+}
+
+/// bash_output just handed the model this job's exit status and remaining
+/// output (or bash_kill told it the job is dead), so the wake would only
+/// repeat what it has read — and on an idle TUI that wake is a whole model
+/// turn, which the model then spends on a `bash_output` snapshot that says
+/// "(no new output)". Drop the queued notice; if the pump has not queued it
+/// yet, remember the id so `record` skips it. ADR 0061.
+pub fn dismiss(io: Io, id: u32) void {
+ mu.lockUncancelable(io);
+ defer mu.unlock(io);
+ var i: usize = 0;
+ var found = false;
+ while (i < count) {
+ if (ring[i].id != id) {
+ i += 1;
+ continue;
+ }
+ std.mem.copyForwards(Notice, ring[i .. count - 1], ring[i + 1 .. count]);
+ count -= 1;
+ found = true;
+ }
+ if (found or dismissedIndex(id) != null) return;
+ if (dismissed_len == cap) {
+ std.mem.copyForwards(u32, dismissed[0 .. cap - 1], dismissed[1..cap]);
+ dismissed_len = cap - 1;
+ }
+ dismissed[dismissed_len] = id;
+ dismissed_len += 1;
+}
+
+/// The tool result for a bash_output wait that ended before the job did.
+/// An Esc used to be rendered by setting the elapsed counter to the 10-hour
+/// deadline, so the model read "36000s elapsed" for a 36-second wait.
+pub fn printRunning(w: *Io.Writer, id: u32, waited_ms: u64, interrupted: bool) !void {
+ var ebuf: [16]u8 = undefined;
+ const el = tool_pulse.formatElapsed(&ebuf, waited_ms);
+ if (interrupted) {
+ try w.print("[job {d}: running · {s} waited, then interrupted — you are notified on exit; do not call bash_output again]", .{ id, el });
+ } else {
+ try w.print("[job {d}: running · {s} elapsed — you are notified on exit; do not call bash_output again]", .{ id, el });
+ }
+}
+
/// One dim chrome line per tool_pulse threshold while a blocking bash_output
/// wait runs long (#607). ADR 0010 keeps the wait single-hop; this only tells
/// the human it is alive. Presentation pulse: --json drops it, and a session
@@ -125,9 +185,49 @@ test "line names exit, kill, and abnormal end" {
try std.testing.expectEqualStrings("[job 3 ended: sleep 5]", line(&buf, n));
}
+test "dismiss drops a queued notice, or the one the pump has not queued yet (ADR 0061)" {
+ const io = std.testing.io;
+ count = 0;
+ dismissed_len = 0;
+ var buf: [256]u8 = undefined;
+ // Queued, then read through bash_output: no wake.
+ record(io, 7, 0, false, "sleep 1");
+ dismiss(io, 7);
+ try std.testing.expect(takeWake(io, &buf) == null);
+ // Read through bash_output BEFORE the pump queued it: still no wake, and
+ // the remembered id is spent by that one record.
+ dismiss(io, 8);
+ dismiss(io, 8); // a second read of the same finished job is not a second credit
+ record(io, 8, 1, false, "false");
+ try std.testing.expect(takeWake(io, &buf) == null);
+ try std.testing.expectEqual(@as(usize, 0), dismissed_len);
+ record(io, 8, 1, false, "false");
+ try std.testing.expect(std.mem.indexOf(u8, takeWake(io, &buf) orelse "", "[job 8 exited 1: false]") != null);
+ // Only the dismissed id is dropped; a neighbour in the ring survives.
+ record(io, 9, 0, false, "a");
+ record(io, 10, 0, false, "b");
+ record(io, 11, 0, false, "c");
+ dismiss(io, 10);
+ const text = takeWake(io, &buf) orelse return error.Empty;
+ try std.testing.expect(std.mem.indexOf(u8, text, "[job 9 exited 0: a]") != null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "job 10") == null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "[job 11 exited 0: c]") != null);
+}
+
+test "printRunning reports the wait that happened, not the deadline (ADR 0061)" {
+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);
+ defer aw.deinit();
+ try printRunning(&aw.writer, 181, 36_000, true);
+ try std.testing.expectEqualStrings("[job 181: running · 36s waited, then interrupted — you are notified on exit; do not call bash_output again]", aw.written());
+ aw.clearRetainingCapacity();
+ try printRunning(&aw.writer, 5, 125_000, false);
+ try std.testing.expectEqualStrings("[job 5: running · 2m05s elapsed — you are notified on exit; do not call bash_output again]", aw.written());
+}
+
test "takeWake drains and formats the grok-build do-not-poll reminder" {
const io = std.testing.io;
count = 0;
+ dismissed_len = 0;
record(io, 1, 0, false, "true");
record(io, 2, 1, false, "false");
var buf: [256]u8 = undefined;
diff --git a/src/jobs.zig b/src/jobs.zig
index 010918c1..cdaa60d7 100644
--- a/src/jobs.zig
+++ b/src/jobs.zig
@@ -397,9 +397,8 @@ pub fn spawnJobOpts(gpa: Allocator, io: Io, cmd: []const u8, opts: SpawnOpts) !*
pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
const deadline = job_wait.resolveDeadline(wait_ms);
var waited: u64 = 0;
- // #607: one dim chrome line per silence threshold so a long blocking wait
- // never reads as a hang. ADR 0010 keeps the wait itself single-hop.
- var still = tool_pulse.Pulse{};
+ var interrupted = false; // Esc: report what was waited, not the 10h cap (ADR 0061)
+ var still = tool_pulse.Pulse{}; // #607: dim chrome per silence threshold; ADR 0010 keeps the wait single-hop
while (true) {
g_jobs.mutex.lockUncancelable(io);
const job = g_jobs.find(id) orelse {
@@ -407,12 +406,12 @@ pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
return .{ .text = try std.fmt.allocPrint(gpa, "no background job {d} — it may never have started; /jobs lists them", .{id}), .is_error = true };
};
const fresh = job.buf.items[job.cursor..];
- if (job.done or waited >= deadline) {
+ if (job.done or interrupted or waited >= deadline) {
var aw: Io.Writer.Allocating = .init(gpa);
errdefer aw.deinit();
const w = &aw.writer;
if (!job.done) {
- try w.print("[job {d}: running · {d}s elapsed — you are notified on exit; do not call bash_output again]", .{ id, waited / 1000 });
+ try job_notify.printRunning(w, id, waited, interrupted);
} else if (job.killed) {
try w.print("[job {d}: killed]", .{id});
} else if (job.exit_code) |c| {
@@ -431,16 +430,17 @@ pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
try w.writeAll("\n(no new output)");
}
job.cursor = job.buf.items.len;
+ if (job.done) job_notify.dismiss(io, id); // the exit was just read here; no wake for it (ADR 0061)
g_jobs.mutex.unlock(io);
return .{ .text = try aw.toOwnedSlice() };
}
g_jobs.mutex.unlock(io);
if (Agent.esc_cancel.load(.acquire)) {
- waited = deadline; // render current state on the next pass
+ interrupted = true; // render current state on the next pass
continue;
}
io.sleep(.fromMilliseconds(100), .awake) catch {
- waited = deadline;
+ interrupted = true;
continue;
};
waited += 100;
@@ -472,6 +472,7 @@ pub fn jobKill(gpa: Allocator, io: Io, id: u32) !ToolOutput {
g_jobs.mutex.lockUncancelable(io);
defer g_jobs.mutex.unlock(io);
const unread = if (g_jobs.find(id)) |job| job.buf.items.len - job.cursor else 0;
+ job_notify.dismiss(io, id); // the model just learned the job is dead (ADR 0061)
return .{ .text = try std.fmt.allocPrint(gpa, "job {d} killed ({d} unread byte(s) — bash_output reads them)", .{ id, unread }) };
}
io.sleep(.fromMilliseconds(100), .awake) catch break;
diff --git a/src/prompt_lean_tests.zig b/src/prompt_lean_tests.zig
new file mode 100644
index 00000000..3f35aaa0
--- /dev/null
+++ b/src/prompt_lean_tests.zig
@@ -0,0 +1,50 @@
+//! Lean / unattended prompt composition tests, split out of
+//! prompt_snapshot_tests.zig for the 600-line ceiling (ADR 0061 grew the
+//! golden). Reached from prompts.zig's `test {}` block like the snapshots.
+
+const std = @import("std");
+const prompts = @import("prompts.zig");
+const imagegen = @import("imagegen.zig");
+const no_local_tools = @import("no_local_tools.zig");
+
+test "lean drops the todo/constraint capabilities from the prompt, never the local tools" {
+ const saved = no_local_tools.lean;
+ defer no_local_tools.lean = saved;
+ no_local_tools.lean = false;
+ const full = prompts.detectCaps();
+ try std.testing.expect(full.todos and full.constraints and full.local_tools);
+ no_local_tools.lean = true;
+ const lean = prompts.detectCaps();
+ try std.testing.expect(!lean.todos and !lean.constraints);
+ try std.testing.expect(lean.local_tools and !lean.subagents); // one-shot: no fan-out essay
+ // …and the composition carries it: the dropped segments' bytes are gone.
+ var a_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer a_state.deinit();
+ const a = a_state.allocator();
+ const lean_prompt = try prompts.composeBase(a, lean);
+ try std.testing.expect(lean_prompt.len < prompts.main_system_prompt.len);
+ try std.testing.expect(std.mem.indexOf(u8, lean_prompt, "described in prose is not done") != null);
+}
+
+test "unattended one-shots are told the REAL approval map up front; attended sessions hear nothing" {
+ var a_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer a_state.deinit();
+ const a = a_state.allocator();
+ const startup = @import("startup.zig");
+ const saved_img = imagegen.available;
+ defer imagegen.available = saved_img;
+ var env = std.process.Environ.Map.init(std.testing.allocator);
+ defer env.deinit();
+ const Io = std.Io;
+ var aw: Io.Writer.Allocating = .init(a);
+ const attended = try startup.buildSystemPrompt(std.testing.io, a, &aw.writer, null, null, true, false, &.{}, false, null, env);
+ try std.testing.expect(std.mem.indexOf(u8, attended, "AUTO-DENIED") == null);
+ var aw2: Io.Writer.Allocating = .init(a);
+ const unattended = try startup.buildSystemPrompt(std.testing.io, a, &aw2.writer, null, null, true, true, &.{}, false, null, env);
+ try std.testing.expect(std.mem.indexOf(u8, unattended, "AUTO-DENIED") != null);
+ // The map the denial text alone could not teach: the root is gated,
+ // subagents are the ungated path, and --yolo/settings are the user's.
+ try std.testing.expect(std.mem.indexOf(u8, unattended, "Subagents are NOT approval-gated") != null);
+ try std.testing.expect(std.mem.indexOf(u8, unattended, "--yolo") != null);
+ try std.testing.expect(std.mem.indexOf(u8, unattended, ".harness/settings.json") != null);
+}
diff --git a/src/prompt_snapshot_tests.zig b/src/prompt_snapshot_tests.zig
index cdd9ba61..e48fc1ac 100644
--- a/src/prompt_snapshot_tests.zig
+++ b/src/prompt_snapshot_tests.zig
@@ -103,7 +103,10 @@ const golden_full_prompt =
\\a green run anywhere else is not evidence — and the failure you were
\\chasing gone. Never stop at a plan, a half-applied edit, or an untested
\\guess, and never leave the last step for the user. If a real ambiguity
- \\blocks you, ask; otherwise decide and go. When a task names files or
+ \\blocks you, ask with ask_user (the choices in options); otherwise decide
+ \\and go. Never end a turn with a menu of options written in prose: the
+ \\harness renders ask_user options as a numbered picker and blocks for the
+ \\answer, and a menu in prose does neither. When a task names files or
\\failing tests, use the named target directly instead of probing unrelated
\\indexes first; that dice roll makes every run of the same task different.
\\Match the verification to the
@@ -122,6 +125,10 @@ const golden_full_prompt =
\\
\\Before a large chunk of work, give a one- or two-sentence heads-up on what
\\you are about to do; on long tasks, drop a brief note as each phase lands.
+ \\Put that text in the SAME response as the tool calls it introduces: a
+ \\response that is only tool calls shows the user nothing but a spinner.
+ \\Before a command that can run for minutes (a build, a test suite, a push
+ \\whose hooks run tests), say so and what it is waiting on.
\\With todo_write, mark an item in_progress when you start it and completed
\\as it lands, not in a batch at the end.
\\
@@ -555,45 +562,3 @@ test "#391/#445: the prompt funnel never arms the note store in a test build" {
// the pure string function the rest of this suite depends on.
try std.testing.expect(!prompts.compactNotesArmed());
}
-
-test "lean drops the todo/constraint capabilities from the prompt, never the local tools" {
- const saved = no_local_tools.lean;
- defer no_local_tools.lean = saved;
- no_local_tools.lean = false;
- const full = prompts.detectCaps();
- try std.testing.expect(full.todos and full.constraints and full.local_tools);
- no_local_tools.lean = true;
- const lean = prompts.detectCaps();
- try std.testing.expect(!lean.todos and !lean.constraints);
- try std.testing.expect(lean.local_tools and !lean.subagents); // one-shot: no fan-out essay
- // …and the composition carries it: the dropped segments' bytes are gone.
- var a_state = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer a_state.deinit();
- const a = a_state.allocator();
- const lean_prompt = try prompts.composeBase(a, lean);
- try std.testing.expect(lean_prompt.len < prompts.main_system_prompt.len);
- try std.testing.expect(std.mem.indexOf(u8, lean_prompt, "described in prose is not done") != null);
-}
-
-test "unattended one-shots are told the REAL approval map up front; attended sessions hear nothing" {
- var a_state = std.heap.ArenaAllocator.init(std.testing.allocator);
- defer a_state.deinit();
- const a = a_state.allocator();
- const startup = @import("startup.zig");
- const saved_img = imagegen.available;
- defer imagegen.available = saved_img;
- var env = std.process.Environ.Map.init(std.testing.allocator);
- defer env.deinit();
- const Io = std.Io;
- var aw: Io.Writer.Allocating = .init(a);
- const attended = try startup.buildSystemPrompt(std.testing.io, a, &aw.writer, null, null, true, false, &.{}, false, null, env);
- try std.testing.expect(std.mem.indexOf(u8, attended, "AUTO-DENIED") == null);
- var aw2: Io.Writer.Allocating = .init(a);
- const unattended = try startup.buildSystemPrompt(std.testing.io, a, &aw2.writer, null, null, true, true, &.{}, false, null, env);
- try std.testing.expect(std.mem.indexOf(u8, unattended, "AUTO-DENIED") != null);
- // The map the denial text alone could not teach: the root is gated,
- // subagents are the ungated path, and --yolo/settings are the user's.
- try std.testing.expect(std.mem.indexOf(u8, unattended, "Subagents are NOT approval-gated") != null);
- try std.testing.expect(std.mem.indexOf(u8, unattended, "--yolo") != null);
- try std.testing.expect(std.mem.indexOf(u8, unattended, ".harness/settings.json") != null);
-}
diff --git a/src/prompt_text.zig b/src/prompt_text.zig
index 1903da88..1605c737 100644
--- a/src/prompt_text.zig
+++ b/src/prompt_text.zig
@@ -151,7 +151,10 @@ pub const work_note =
\\a green run anywhere else is not evidence — and the failure you were
\\chasing gone. Never stop at a plan, a half-applied edit, or an untested
\\guess, and never leave the last step for the user. If a real ambiguity
- \\blocks you, ask; otherwise decide and go. When a task names files or
+ \\blocks you, ask with ask_user (the choices in options); otherwise decide
+ \\and go. Never end a turn with a menu of options written in prose: the
+ \\harness renders ask_user options as a numbered picker and blocks for the
+ \\answer, and a menu in prose does neither. When a task names files or
\\failing tests, use the named target directly instead of probing unrelated
\\indexes first; that dice roll makes every run of the same task different.
\\Match the verification to the
@@ -169,12 +172,21 @@ pub const work_note =
\\records is empty, not malformed.
;
-/// Always present: narration is a habit, not a capability.
+/// Always present: narration is a habit, not a capability. ADR 0061: the
+/// note used to say only THAT a heads-up is owed; a model that answers every
+/// step with bare function calls (Gemini flash: no text in any of 259
+/// tool-calling responses) satisfied that by thinking it, and a multi-minute
+/// hook run read as a hang. Now it says where the words go and what earns
+/// a warning.
pub const headsup_note =
\\
\\
\\Before a large chunk of work, give a one- or two-sentence heads-up on what
\\you are about to do; on long tasks, drop a brief note as each phase lands.
+ \\Put that text in the SAME response as the tool calls it introduces: a
+ \\response that is only tool calls shows the user nothing but a spinner.
+ \\Before a command that can run for minutes (a build, a test suite, a push
+ \\whose hooks run tests), say so and what it is waiting on.
;
/// Gate: `caps.todos`. Same tool as `todo_note`; separate because it sits in a
diff --git a/src/prompts.zig b/src/prompts.zig
index 548a1072..4142795a 100644
--- a/src/prompts.zig
+++ b/src/prompts.zig
@@ -477,6 +477,7 @@ pub const compact_instruction =
test { // #421/#410: prompt snapshots and goal-prefix behavior must stay reachable.
_ = @import("prompt_snapshot_tests.zig");
+ _ = @import("prompt_lean_tests.zig");
_ = @import("prompt_goal_tests.zig");
}
diff --git a/src/schema.zig b/src/schema.zig
index def811a2..290da00b 100644
--- a/src/schema.zig
+++ b/src/schema.zig
@@ -142,7 +142,7 @@ const meta_specs = [_]ToolSpec{
.{ .name = "note_constraint", .desc = "Record a standing user constraint in this project's playbook (.graff/playbook.jsonl). Call it the moment the user rejects, forbids or vetoes something, passing ONE short imperative line stating what must not happen (e.g. never add scroll hints or progress dots). The recorded line is injected verbatim into every later subagent, workflow and pipeline brief and into your own system context, in this session and in future ones, so it survives compaction and reaches fresh agents that never saw the rejection. Append-only: this tool cannot edit, retire or list items. Only the user can retire one, with /never rm <id-or-text> (REPL or ACP prompt) or by explicitly asking to forget/override that rule in their next message. Recording the same constraint twice is harmless and does nothing.", .schema = "{\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\", \"description\": \"One short imperative line in the user's own terms, stating what must not happen\"}}, \"required\": [\"text\"]}" },
.{
.name = "ask_user",
- .desc = "Ask the human a question and wait for their reply (typed text and/or pasted images). Images reach you as vision blocks on the next request, same as a normal prompt. Use for a decision, clarification, or missing information.",
+ .desc = "Ask the human a question and wait for their reply (typed text and/or pasted images). Images reach you as vision blocks on the next request, same as a normal prompt. Call it whenever the next step depends on the user's choice — a decision between approaches, a clarification, or missing information — and put the choices in options: the harness renders them as a numbered picker and blocks for the answer. Ending the turn with a menu written in prose does neither.",
.schema =
\\{"type": "object", "properties": {"question": {"type": "string", "description": "The question to ask the user"}, "options": {"type": "array", "items": {"type": "string"}, "description": "Optional suggested answers, shown numbered"}}, "required": ["question"]}
,