Skip to content

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

Python

fix: show a named ask_user row in the line REPL

Cursor Agent312615abdd43
diff --git a/src/agent_tool_label.zig b/src/agent_tool_label.zig
index d1db5144..a3456a95 100644
--- a/src/agent_tool_label.zig
+++ b/src/agent_tool_label.zig
@@ -67,7 +67,7 @@ fn namedDetailField(name: []const u8, input: std.json.Value) ?[]const u8 {
return null;
}
-const fallback_fields = [_][]const u8{ "command", "path", "query", "url", "pattern", "file", "prompt", "uri", "text" };
+const fallback_fields = [_][]const u8{ "command", "path", "query", "url", "pattern", "file", "prompt", "uri", "text", "question" };
fn fallbackDetail(input: std.json.Value) []const u8 {
for (fallback_fields) |field| {
@@ -182,6 +182,7 @@ pub fn verb(name: []const u8, input: std.json.Value, buf: []u8) []const u8 {
if (std.mem.eql(u8, name, "subagent") or std.mem.eql(u8, name, "workflow")) return "scout";
if (std.mem.eql(u8, name, "imagegen")) return "image";
if (std.mem.eql(u8, name, "read_tool_result")) return "inspect";
+ if (std.mem.eql(u8, name, "ask_user")) return "ask";
const leaf = mcpLeaf(name);
if (std.mem.eql(u8, leaf, "batch")) return "inspect";
if (std.mem.startsWith(u8, name, "mcp")) {
diff --git a/src/agent_tool_render.zig b/src/agent_tool_render.zig
index 75a05d6e..d984fc26 100644
--- a/src/agent_tool_render.zig
+++ b/src/agent_tool_render.zig
@@ -55,7 +55,7 @@ fn treePrefix() []const u8 {
/// Default session is result-only — announce lines doubled the visual weight.
pub fn toolUseLine(a: *Agent, t: ToolInvocation) void {
_ = a;
- if (t.arg_streamed) return;
+ if (t.arg_streamed and !t.ask_user) return;
var vbuf: [16]u8 = undefined;
var dbuf: [128]u8 = undefined;
const v = label.verb(t.name, t.input, &vbuf);
@@ -132,7 +132,7 @@ pub fn liveOutput(a: *Agent, text: []const u8) void {
/// writes straight to the writer — it never ended a tick-gate row.
pub fn toolResultLine(a: *Agent, r: ToolOutcome) void {
const w = a.out orelse return;
- if (r.meta) return;
+ if (r.meta and !r.ask_user) return;
if (label.skipLineRepl(r.name)) return;
const all = std.mem.trim(u8, r.text, " \t\r\n");
if (r.is_error) {
@@ -568,3 +568,19 @@ test "blank Enter reveals hidden tool results newest-first and terminal-safe" {
try std.testing.expect(disclosure.handleInput(a.io, &aw.writer, ""));
try std.testing.expectEqualStrings("", aw.writer.buffered());
}
+
+test "ask_user keeps a named row after streamed arguments" {
+ const saved = ansi.style;
+ ansi.style = .{};
+ defer ansi.style = saved;
+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena_state.deinit();
+ var aw: Io.Writer.Allocating = .init(std.testing.allocator);
+ defer aw.deinit();
+ var a = testAgent(&aw.writer);
+ const input = try std.json.parseFromSliceLeaky(std.json.Value, arena_state.allocator(), "{\"question\":\"Which one?\"}", .{});
+ toolUseLine(&a, .{ .name = "ask_user", .input = input, .ask_user = true, .arg_streamed = true });
+ try std.testing.expectEqualStrings("", aw.writer.buffered());
+ toolResultLine(&a, .{ .name = "ask_user", .text = "yes", .is_error = false, .meta = true, .ask_user = true });
+ try std.testing.expectEqualStrings(" ✓ ask Which one? yes\n", aw.writer.buffered());
+}
diff --git a/src/ask_user.zig b/src/ask_user.zig
index f003b799..9b7a727b 100644
--- a/src/ask_user.zig
+++ b/src/ask_user.zig
@@ -22,6 +22,7 @@ const protocol_seq = @import("protocol_seq.zig");
const vision = @import("vision.zig");
const vision_queue = @import("vision_queue.zig");
const acp_ask = @import("acp_ask.zig");
+const style = &@import("ansi.zig").style;
/// Block the root agent for an ask_user reply; subagents have no stdin.
pub fn askUser(self: *Agent, call: ToolCall) !ExecResult {
@@ -60,8 +61,9 @@ pub fn askUser(self: *Agent, call: ToolCall) !ExecResult {
.is_error = true,
};
const w = self.out.?;
- // Skip the re-print only when the question streamed live in full.
- if (!self.argStreamedFully(call)) try w.print("\n❓ {s}\n", .{question});
+ // Named tool row even when the question streamed: announce is silent for
+ // streamed args, and the result line used to skip this meta tool.
+ try w.print(" {s}⚙{s} ask_user {s}\n", .{ style.accent, style.reset, question });
if (tools_mod.json_args.object(call.input)) |o| if (tools_mod.json_args.arrayOf(o, "options")) |opts| {
for (opts, 1..) |opt, n| try w.print(" {d}) {s}\n", .{ n, tools_mod.json_args.text(opt) orelse "(non-text option)" });
};