graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Stream subagent progress onto the parent ACP tool call by default
justrach0c5c4a507b81
diff --git a/docs/acp-compatibility.md b/docs/acp-compatibility.mdindex d0cafd8f..10b205c4 100644--- a/docs/acp-compatibility.md+++ b/docs/acp-compatibility.md@@ -32,7 +32,7 @@ optional feature or draft extension is enabled.| Content | Text, resource links and supported embedded text resources are accepted. `image` blocks (`data` + `mimeType`) are accepted and advertised (`promptCapabilities.image`); they reach the next model request when the model accepts images and are skipped otherwise, the same as `@[path]` attachments. Audio is advertised as false. | `src/acp_protocol.zig`, `src/acp_images.zig`, `scripts/test-acp-images.py` || Client filesystem and terminals | These are optional negotiated ACP facilities, not a requirement that local harness tools be replaced by client tools. The local tool implementation does not imply support for every client-side method. | Capability negotiation and the upstream v1 schema || Usage | Connection usage is a namespaced extension. It preserves unknown totals and is not a standard ACP v1 billing contract. | `scripts/test-acp-usage.py`, ADR 0182 |-| Subagents | The proposed child-session update stream is an opt-in live preview: client `subagents` capability plus `GRAFF_ACP_DRAFT_SUBAGENTS=1`. Explicit `run_in_background:false` foreground children stream separately; the default detached workers retain their parent tool row and `graff/agents` inspection. Child history is not yet replayed on `session/load`. | `scripts/test-acp-subagent-update.py`, ADR 0194 |+| Subagents | Default: a top-level subagent streams its work onto the parent tool call as standard `tool_call_update` content (a rolling log of its tool calls, failures and message tail), with no `status` change and `_meta["graff/subagent"]` = `{sessionId, name, state}`; `GRAFF_ACP_SUBAGENT_PROGRESS=0` disables it. Opt-in preview: the proposed child-session stream (client `subagents` capability plus `GRAFF_ACP_DRAFT_SUBAGENTS=1`) replaces it for foreground children. Detached workers also keep `graff/agents` inspection. Child history is not yet replayed on `session/load`. | `scripts/test-acp-subagent-update.py`, ADR 0194, ADR 0205 || Transport | ACP uses JSON-RPC over stdio. HTTP/2 checks exercise the model request transport behind ACP; they do not redefine ACP as an HTTP/2 protocol. | `scripts/test-acp-http2.py`, `scripts/test-acp-http2-retry.py` |## Client acceptance checklistdiff --git a/docs/adr/0205-subagent-progress-is-standard-tool-content.md b/docs/adr/0205-subagent-progress-is-standard-tool-content.mdnew file mode 100644index 00000000..636820fc--- /dev/null+++ b/docs/adr/0205-subagent-progress-is-standard-tool-content.md@@ -0,0 +1,36 @@+# 0205. Subagent progress streams as standard tool call content++Status: accepted 2026-09-26. Extends 0194.++## Context++ACP v1 has no subagent protocol. Its RFDs mention subagents only in passing+(the v2 prompt lifecycle, session fork, proxy chains). Graff's child-session+stream (ADR 0194) follows an unmerged proposal, so it stays behind+`GRAFF_ACP_DRAFT_SUBAGENTS=1` plus a client `subagents` capability. By default+an ACP client saw only the parent's `subagent` tool row and its final result,+while the child's work was reachable only by polling `graff/agents`.++Every ACP client already renders `tool_call_update.content`, and other ACP+agents report delegated work the same way.++## Decision++- By default, a top-level `subagent` child streams onto its parent's tool+ call: `tool_call_update` rows in the parent session whose `content` is a+ rolling log of the child's tool calls, failures, and the tail of the+ message it is writing. Tool events publish immediately; text is throttled.+- These rows carry no `status`. The parent's own tool result still completes+ or fails the call, and a detached child's spawn call stays completed.+- `_meta["graff/subagent"]` carries `{sessionId, name, state}` for clients+ that want to link the row to `graff/agents` inspection.+- The draft child-session stream replaces this when both sides opt in.+ `GRAFF_ACP_SUBAGENT_PROGRESS=0` turns the progress rows off.+- Only while the parent prompt is active, like 0194.++## Consequences++Zed, Harness and any other ACP client show what a subagent is doing with no+client change. The log is bounded (12 steps, a 280-byte message tail), so a+long child cannot flood the transcript. Progress after the parent prompt+ends is not streamed; `graff/agents` still covers detached workers then.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 4794f839..dcc70f36 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -231,6 +231,7 @@ record only when you need the evidence or the edge cases.| [0202](0202-acp-sessions-adopt-client-cwd.md) | ACP sessions adopt the client `cwd`, report the worktree as `_meta["graff/worktree"]` (null in a main checkout), and `graff worktree` exits non-zero when it refuses or does nothing. || [0203](0203-external-agents-join-rooms-through-graff-peer.md) | Other agents join the device rooms with `graff peer list/send/inbox`: same JSONL rooms and records, owned by the agent's process; a DM is held while the recipient's newer message is unread; drains read only new bytes. || [0204](0204-kimi-platform-is-graff.md) | Kimi requests send `X-Msh-Platform: graff` and `graff/<version>` everywhere (OAuth and inference), never `kimi_code_cli`; a Kimi Code console key bills as plan quota. Supersedes 0027. |+| [0205](0205-subagent-progress-is-standard-tool-content.md) | By default a subagent streams its work onto the parent tool call as content-only `tool_call_update` rows (rolling log + `_meta["graff/subagent"]`); the draft child-session stream only when both sides opt in; `GRAFF_ACP_SUBAGENT_PROGRESS=0` turns it off. |## When to write onediff --git a/scripts/test-acp-subagent-update.py b/scripts/test-acp-subagent-update.pyindex 7ae1cdfe..93f561e3 100644--- a/scripts/test-acp-subagent-update.py+++ b/scripts/test-acp-subagent-update.py@@ -17,7 +17,7 @@ def updates(client):if event.get('method') == 'session/update']-def run(binary, preview, capability, json_mode=False):+def run(binary, preview, capability, json_mode=False, progress_on=True):with tempfile.TemporaryDirectory(prefix='graff-acp-child-') as temporary:work = Path(temporary)home = work / 'home'@@ -36,6 +36,8 @@ def run(binary, preview, capability, json_mode=False):env = {'GRAFF_NO_NATIVE_FOLD': '1'}if preview:env['GRAFF_ACP_DRAFT_SUBAGENTS'] = '1'+ if not progress_on:+ env['GRAFF_ACP_SUBAGENT_PROGRESS'] = '0'args = ('--max-model-calls', '6', '--max-run-tool-calls', '8')if json_mode:args += ('--json',)@@ -60,6 +62,24 @@ def run(binary, preview, capability, json_mode=False):if not (preview and capability):assert not child_updates, rowsassert all(session == sid for _, session, _ in rows), rows+ # Standard ACP: the child's work streams onto the parent tool+ # call as content-only tool_call_update rows (ADR 0205).+ progress = [(i, update) for i, session, update in rows+ if update.get('sessionUpdate') == 'tool_call_update'+ and update.get('toolCallId') == parent_id+ and 'graff/subagent' in update.get('_meta', {})]+ if not progress_on:+ assert not progress, rows+ return+ assert progress, rows+ assert all('status' not in update for _, update in progress), progress+ assert any('read_file: example.txt' in str(update.get('content')) for _, update in progress), progress+ last = progress[-1][1]+ assert last['_meta']['graff/subagent']['state'] == 'completed', last+ done = [i for i, session, update in rows+ if update.get('sessionUpdate') == 'tool_call_update'+ and update.get('toolCallId') == parent_id and update.get('status') in ('completed', 'failed')]+ assert done and progress[-1][0] < done[-1], rowsreturnassert len(child_updates) == 2, rowsannounced_at, announced = child_updates[0]@@ -91,4 +111,6 @@ if __name__ == '__main__':for preview, capability in ((False, True), (True, False), (True, True)):run(binary, preview, capability)run(binary, True, True, json_mode=True)- print('ACP child sessions: gated fallback, negotiated announcement, child activity, terminal, --json')+ run(binary, False, False)+ run(binary, False, False, progress_on=False)+ print('ACP subagents: standard progress on the parent tool call by default, opt-out, draft child sessions when negotiated, --json')diff --git a/src/acp_live_turn.zig b/src/acp_live_turn.zigindex 7c56b258..eb769a29 100644--- a/src/acp_live_turn.zig+++ b/src/acp_live_turn.zig@@ -77,11 +77,13 @@ pub const LiveTurn = struct {sink.init(self.root.gpa, self.out, &self.session_id, &self.saw_text);sink.output_lock = &output_lock;sink.output_io = self.root.io;- const subagents = self.dispatch != null and self.dispatch.?.subagents and self.dispatch.?.draft_subagents_enabled;+ // Standard progress on the parent tool call by default; the draft+ // child-session stream only when both sides opted in (ADR 0194/0205).+ const draft = self.dispatch != null and self.dispatch.?.subagents and self.dispatch.?.draft_subagents_enabled;defer sink.deinit();- var child_state: @import("acp_subagent_live.zig").State = .{ .out = self.out, .parent = self.session_id, .output_lock = &output_lock };- if (subagents) @import("acp_subagent_live.zig").install(self.root.io, &child_state);- defer if (subagents) @import("acp_subagent_live.zig").uninstall(self.root.io);+ var child_state: @import("acp_subagent_live.zig").State = .{ .out = self.out, .parent = self.session_id, .output_lock = &output_lock, .mode = if (draft) .draft else .progress };+ @import("acp_subagent_live.zig").install(self.root.io, &child_state);+ defer @import("acp_subagent_live.zig").uninstall(self.root.io);self.root.out = &sink.writer;main_mod.g_out = &sink.writer;defer {diff --git a/src/acp_stream.zig b/src/acp_stream.zigindex caeb4a37..22493180 100644--- a/src/acp_stream.zig+++ b/src/acp_stream.zig@@ -39,7 +39,7 @@ pub fn kindFor(name: []const u8) []const u8 {return "other";}-fn titleFor(name: []const u8, input: Value) []const u8 {+pub fn titleFor(name: []const u8, input: Value) []const u8 {if (input == .object) {if (util.strFieldObj(input.object, "path")) |p| return p;if (util.strFieldObj(input.object, "file")) |f| return f;diff --git a/src/acp_subagent_live.zig b/src/acp_subagent_live.zigindex 3791f2d6..95472b3e 100644--- a/src/acp_subagent_live.zig+++ b/src/acp_subagent_live.zig@@ -1,5 +1,9 @@-//! ACP v1 draft subagent stream. A child is exposed only while its parent-//! prompt is active and only after the client negotiated `subagents`.+//! Subagent activity on ACP. By default (mode `progress`) a child's work is+//! shown as standard `tool_call_update`s on its parent's tool call+//! (acp_subagent_progress.zig). The draft child-session stream (mode `draft`)+//! is used only when the client negotiated `subagents` and graff runs with+//! GRAFF_ACP_DRAFT_SUBAGENTS=1. Either way a child is exposed only while its+//! parent prompt is active.const std = @import("std");const Io = std.Io;const main = @import("main.zig");@@ -7,11 +11,15 @@ const sink = @import("engine_sink.zig");const stream = @import("acp_stream.zig");const proto = @import("acp_protocol.zig");const util = @import("util.zig");+const progress = @import("acp_subagent_progress.zig");++pub const Mode = enum { draft, progress };pub const State = struct {out: *Io.Writer,parent: []const u8,output_lock: *Io.Mutex,+ mode: Mode = .draft,};var active: ?*State = null;@@ -124,6 +132,7 @@ pub fn announce(io: Io, id: []const u8, name: []const u8, task: []const u8, paremain.g_gui_mu.lockUncancelable(io);defer main.g_gui_mu.unlock(io);const state = active orelse return false;+ if (state.mode != .draft) return false;state.output_lock.lockUncancelable(io);defer state.output_lock.unlock(io);proto.writeNotification(state.out, "session/update", .{ .sessionId = state.parent, .update = .{@@ -137,6 +146,18 @@ pub fn announce(io: Io, id: []const u8, name: []const u8, task: []const u8, parereturn true;}+/// Whether this child should stream standard progress onto its parent's tool+/// call: a top-level `subagent` with a known parent call, in a prompt whose+/// client did not choose the draft child-session stream.+pub fn progressFor(io: Io, kind: []const u8, depth: u8, parent_call_id: []const u8) bool {+ if (depth != 0 or parent_call_id.len == 0 or !std.mem.eql(u8, kind, "subagent")) return false;+ if (!progress.enabled()) return false;+ main.g_gui_mu.lockUncancelable(io);+ defer main.g_gui_mu.unlock(io);+ const state = active orelse return false;+ return state.mode == .progress;+}+pub fn finish(io: Io, id: []const u8, outcome: []const u8, parent_call_id: []const u8) void {main.g_gui_mu.lockUncancelable(io);defer main.g_gui_mu.unlock(io);@@ -160,6 +181,7 @@ pub const ChildSink = struct {recorder: ?sink.EngineSink = null,background_handle: ?BackgroundHandle = null,seq: u64 = 1,+ progress: ?progress.Progress = null,pub fn engineSink(self: *ChildSink) sink.EngineSink {return .{ .ctx = self, .vt = &vtable };@@ -174,6 +196,10 @@ pub const ChildSink = struct {self.emitBackground(stamped, handle);return;}+ if (self.progress != null) {+ self.emitProgress(stamped);+ return;+ }main.g_gui_mu.lockUncancelable(self.io);defer main.g_gui_mu.unlock(self.io);const state = active orelse return;@@ -197,6 +223,53 @@ pub const ChildSink = struct {w.flush() catch {};}+ fn emitProgress(self: *ChildSink, stamped: sink.Stamped) void {+ const p = &self.progress.?;+ const tool_event = switch (stamped.event) {+ .text_delta => |v| blk: {+ p.addText(v.text);+ break :blk false;+ },+ .tool_call_announced => |v| blk: {+ if (v.ask_user or std.mem.eql(u8, v.name, "attempt_completion")) return;+ p.toolLine(v.name, v.input);+ break :blk true;+ },+ .tool_result => |v| blk: {+ if (!(v.is_error or v.cancelled)) return;+ var b: [progress.line_max]u8 = undefined;+ p.addLine(std.fmt.bufPrint(&b, "✗ {s} failed", .{v.name}) catch "✗ failed");+ break :blk true;+ },+ .tool_rejected => blk: {+ p.addLine("✗ tool call rejected");+ break :blk true;+ },+ else => return,+ };+ if (!p.due(util.unixMs(self.io), tool_event)) return;+ self.publishProgress("running");+ }++ fn publishProgress(self: *ChildSink, state_label: []const u8) void {+ const p = &(self.progress orelse return);+ main.g_gui_mu.lockUncancelable(self.io);+ defer main.g_gui_mu.unlock(self.io);+ const state = active orelse return;+ state.output_lock.lockUncancelable(self.io);+ defer state.output_lock.unlock(self.io);+ progress.write(state.out, state.parent, p, state_label) catch return;+ state.out.flush() catch {};+ }++ /// The child's last word on its parent's tool call. The parent's own tool+ /// result, when it has one, follows and replaces this.+ pub fn finishProgress(self: *ChildSink, outcome: []const u8) void {+ const p = &(self.progress orelse return);+ p.addLine(if (std.mem.eql(u8, outcome, "completed")) "✓ finished" else if (std.mem.eql(u8, outcome, "cancelled")) "■ cancelled" else "✗ failed");+ self.publishProgress(outcome);+ }+fn emitBackground(self: *ChildSink, stamped: sink.Stamped, handle: BackgroundHandle) void {var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator);defer arena_state.deinit();@@ -260,3 +333,36 @@ test "draft child sessions exclude detached and nested workers" {try std.testing.expect(!eligible("subagent", 1, false));try std.testing.expect(!eligible("workflow_task", 0, false));}++test "default progress mode streams the child's work onto the parent tool call" {+ var buffer: [16384]u8 = undefined;+ var out: Io.Writer = .fixed(&buffer);+ const io = std.testing.io;+ var output_lock: Io.Mutex = .init;+ var state: State = .{ .out = &out, .parent = "parent", .output_lock = &output_lock, .mode = .progress };+ install(io, &state);+ defer uninstall(io);+ // The draft announcement is not used in progress mode.+ try std.testing.expect(!announce(io, "child", "Scout", "Inspect", "spawn-1"));+ try std.testing.expect(progressFor(io, "subagent", 0, "spawn-1"));+ try std.testing.expect(!progressFor(io, "subagent", 1, "spawn-1"));+ try std.testing.expect(!progressFor(io, "subagent", 0, ""));+ var child: ChildSink = .{ .id = "child", .io = io, .progress = .{ .parent_call_id = "spawn-1", .child_id = "child", .name = "Scout" } };+ const emit_sink = child.engineSink();+ var input: std.json.ObjectMap = .empty;+ defer input.deinit(std.testing.allocator);+ try input.put(std.testing.allocator, "path", .{ .string = "src/main.zig" });+ emit_sink.emit(io, .{ .tool_call_announced = .{ .id = "read-1", .name = "read_file", .input = .{ .object = input } } });+ emit_sink.emit(io, .{ .tool_result = .{ .id = "read-1", .name = "bash", .text = "boom", .is_error = true } });+ child.finishProgress("completed");+ const wire = out.buffered();+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"sessionUpdate\":\"tool_call_update\"") != null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"toolCallId\":\"spawn-1\"") != null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "read_file: src/main.zig") != null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "bash failed") != null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "finished") != null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"sessionId\":\"parent\"") != null);+ // No child session, no draft updates, and no status flip on the parent call.+ try std.testing.expect(std.mem.indexOf(u8, wire, "subagent_update") == null);+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"status\"") == null);+}diff --git a/src/acp_subagent_progress.zig b/src/acp_subagent_progress.zignew file mode 100644index 00000000..05145d97--- /dev/null+++ b/src/acp_subagent_progress.zig@@ -0,0 +1,151 @@+//! Standard ACP v1 subagent progress (ADR 0205). While a child works, its+//! parent's `agent` tool call receives `tool_call_update`s whose `content` is+//! a short rolling log of what the child is doing: each tool it calls, any+//! failure, and the tail of the message it is writing. Every ACP client+//! renders tool call content, so this needs no capability or flag. Updates+//! carry no `status`: the parent's own tool result decides that, and a+//! detached child's spawn call stays completed instead of spinning forever.++const std = @import("std");+const Io = std.Io;+const Value = std.json.Value;+const proto = @import("acp_protocol.zig");+const stream = @import("acp_stream.zig");+const util = @import("util.zig");++pub const max_lines = 12;+pub const line_max = 160;+pub const tail_max = 280;+/// Text deltas publish at most this often; tool events publish immediately.+pub const text_interval_ms: i64 = 400;++pub const Progress = struct {+ parent_call_id: []const u8,+ child_id: []const u8,+ name: []const u8,+ lines: [max_lines][line_max]u8 = undefined,+ lens: [max_lines]usize = @splat(0),+ count: usize = 0,+ tail: [tail_max]u8 = undefined,+ tail_len: usize = 0,+ last_ms: i64 = 0,++ pub fn addLine(p: *Progress, text: []const u8) void {+ const slot = p.count % max_lines;+ const cut = util.utf8Prefix(text, line_max);+ var n: usize = 0;+ for (cut) |c| {+ p.lines[slot][n] = if (c == '\n' or c == '\r' or c == '\t') ' ' else c;+ n += 1;+ }+ p.lens[slot] = n;+ p.count += 1;+ // A new step starts a new message; the old tail belongs to the step before.+ p.tail_len = 0;+ }++ /// Keep the last `tail_max` bytes of the message being written, cut on a+ /// UTF-8 boundary.+ pub fn addText(p: *Progress, delta: []const u8) void {+ if (delta.len >= tail_max) {+ var start = delta.len - tail_max;+ while (start < delta.len and (delta[start] & 0xC0) == 0x80) start += 1;+ const rest = delta[start..];+ @memcpy(p.tail[0..rest.len], rest);+ p.tail_len = rest.len;+ return;+ }+ const keep = @min(p.tail_len, tail_max - delta.len);+ var start = p.tail_len - keep;+ while (start < p.tail_len and (p.tail[start] & 0xC0) == 0x80) start += 1;+ std.mem.copyForwards(u8, p.tail[0 .. p.tail_len - start], p.tail[start..p.tail_len]);+ const base = p.tail_len - start;+ @memcpy(p.tail[base..][0..delta.len], delta);+ p.tail_len = base + delta.len;+ }++ pub fn toolLine(p: *Progress, name: []const u8, input: Value) void {+ var buf: [line_max]u8 = undefined;+ const title = stream.titleFor(name, input);+ const line = if (std.mem.eql(u8, title, name))+ std.fmt.bufPrint(&buf, "▸ {s}", .{name}) catch name+ else+ std.fmt.bufPrint(&buf, "▸ {s}: {s}", .{ name, util.utf8Prefix(title, line_max - name.len - 8) }) catch name;+ p.addLine(line);+ }++ /// Oldest to newest, then the message tail.+ pub fn render(p: *const Progress, buf: []u8) []const u8 {+ var w: Io.Writer = .fixed(buf);+ const first = if (p.count > max_lines) p.count - max_lines else 0;+ var i = first;+ while (i < p.count) : (i += 1) {+ const slot = i % max_lines;+ if (i > first) w.writeAll("\n") catch break;+ w.writeAll(p.lines[slot][0..p.lens[slot]]) catch break;+ }+ if (p.tail_len > 0) {+ if (p.count > 0) w.writeAll("\n\n") catch {};+ w.writeAll(std.mem.trim(u8, p.tail[0..p.tail_len], " \n")) catch {};+ }+ return w.buffered();+ }++ pub fn due(p: *Progress, now_ms: i64, tool_event: bool) bool {+ if (!tool_event and now_ms - p.last_ms < text_interval_ms) return false;+ p.last_ms = now_ms;+ return true;+ }+};++/// One progress update on the parent's tool call, in the parent's session.+pub fn write(w: *Io.Writer, parent_session: []const u8, p: *const Progress, state: []const u8) !void {+ var buf: [max_lines * (line_max + 1) + tail_max + 8]u8 = undefined;+ try proto.writeNotification(w, "session/update", .{+ .sessionId = parent_session,+ .update = .{+ .sessionUpdate = "tool_call_update",+ .toolCallId = p.parent_call_id,+ .content = .{+ .{ .type = "content", .content = .{ .type = "text", .text = p.render(&buf) } },+ },+ ._meta = .{ .@"graff/subagent" = .{ .sessionId = p.child_id, .name = p.name, .state = state } },+ },+ });+}++/// GRAFF_ACP_SUBAGENT_PROGRESS=0 turns the stream off.+pub fn enabled() bool {+ const v = std.c.getenv("GRAFF_ACP_SUBAGENT_PROGRESS") orelse return true;+ return !std.mem.eql(u8, std.mem.span(v), "0");+}++test "the log keeps the newest steps and a UTF-8-safe message tail" {+ var p: Progress = .{ .parent_call_id = "spawn-1", .child_id = "sa-1", .name = "Scout" };+ var i: usize = 0;+ while (i < max_lines + 3) : (i += 1) {+ var b: [32]u8 = undefined;+ p.addLine(std.fmt.bufPrint(&b, "step {d}", .{i}) catch unreachable);+ }+ var out: [4096]u8 = undefined;+ const text = p.render(&out);+ try std.testing.expect(std.mem.indexOf(u8, text, "step 0\n") == null);+ try std.testing.expect(std.mem.startsWith(u8, text, "step 3"));+ try std.testing.expect(std.mem.endsWith(u8, text, "step 14"));+ var long: [600]u8 = undefined;+ for (&long, 0..) |*c, k| c.* = if (k % 3 == 0) 0xE2 else if (k % 3 == 1) 0x96 else 0xB8; // "▸" repeated+ p.addText(&long);+ try std.testing.expect(p.tail_len <= tail_max);+ try std.testing.expect(std.unicode.utf8ValidateSlice(p.tail[0..p.tail_len]));+ p.addText("done.");+ try std.testing.expect(std.mem.endsWith(u8, p.tail[0..p.tail_len], "done."));+ try std.testing.expect(std.unicode.utf8ValidateSlice(p.tail[0..p.tail_len]));+}++test "text publishes on an interval, tool events at once" {+ var p: Progress = .{ .parent_call_id = "c", .child_id = "s", .name = "n" };+ try std.testing.expect(p.due(1000, false));+ try std.testing.expect(!p.due(1100, false));+ try std.testing.expect(p.due(1150, true));+ try std.testing.expect(p.due(1600, false));+}diff --git a/src/additional_tests.zig b/src/additional_tests.zigindex a56d7563..367a820b 100644--- a/src/additional_tests.zig+++ b/src/additional_tests.zig@@ -10,6 +10,7 @@ test {_ = @import("provider_codegraff_tests.zig");_ = @import("agent_responses.zig");_ = @import("session_branch.zig");+ _ = @import("acp_subagent_progress.zig");_ = @import("vault_crypto.zig");_ = @import("vault_client.zig");_ = @import("vault_sync.zig");diff --git a/src/subagent_run.zig b/src/subagent_run.zigindex 7f727e56..3178ec17 100644--- a/src/subagent_run.zig+++ b/src/subagent_run.zig@@ -368,16 +368,19 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []constelsenull;const background_announced = background_handle != null;+ const progress_on = !announced and !background_announced and acp_children.progressFor(ctx.io, kind, ctx.depth, ctx.parent_tool_call_id);var child_stream: acp_children.ChildSink = .{.id = sub_id,.io = ctx.io,.recorder = agent.sink,.background_handle = background_handle,+ .progress = if (progress_on) .{ .parent_call_id = ctx.parent_tool_call_id, .child_id = sub_id, .name = label } else null,};- if (announced or background_announced) agent.sink = child_stream.engineSink();+ if (announced or background_announced or progress_on) agent.sink = child_stream.engineSink();var child_state: []const u8 = "failed";defer if (announced) acp_children.finish(ctx.io, sub_id, child_state, ctx.parent_tool_call_id);defer if (background_handle) |handle| acp_children.finishBackground(ctx.io, handle, sub_id, child_stream.seq, child_state);+ defer if (progress_on) child_stream.finishProgress(child_state);const wf_task = std.mem.eql(u8, kind, "workflow_task");if (wf_task) guiEmit(ctx.io, .{ .type = "tool_call", .name = "subagent", .input = .{ .description = label }, .id = sub_id });