Skip to content

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

Python

Expose resolved worker identity in ACP subagent updates

justrach4a80b4e02b14
diff --git a/docs/acp-compatibility.md b/docs/acp-compatibility.md
index 7c38ef10..d855b220 100644
--- a/docs/acp-compatibility.md
+++ b/docs/acp-compatibility.md
@@ -36,7 +36,7 @@ optional feature or draft extension is enabled.
| 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 |
| Context meter | Standard `usage_update` (stable in ACP v1): `used` tokens in context and the model's `size`, plus `cost` `{amount, currency: "USD"}` only when every call so far was priced. Sent after tool steps whenever the count moved (so it drops visibly after compaction) and at the end of each prompt turn. | `src/acp_context_meter.zig`, `src/acp_engine_test.zig` |
| 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 | 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 |
+| 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, a tool title containing the resolved worker model, and `_meta["graff/subagent"]` = `{sessionId, name, state, provider, model}`; `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 |
| Session-changing commands | `/resume SOURCE` (and `--branch DEST`) moves the live session onto another save while the connection keeps its session ID. The `session/prompt` result then carries `_meta["graff/durableSessionId"]`: the save the session now writes. A host that restores sessions should keep that ID and pass it to `session/load` after a restart; the old ID may name no save, or a save from before the switch. v1 only. | `scripts/test-acp-resume-identity.py`, `src/acp_engine.zig` (#1529) |
| Resent prompts | `session/prompt` may carry a client message id as `messageId` or `_meta["graff/messageId"]`. Resending a prompt this process already finished for that session answers with the first turn's `stopReason` instead of starting another turn; a failed turn is not recorded, so its resend runs. The last 32 ids are kept in memory. `graff serve` and remote control take the same id as `message_id` on the request body and replay the first request's events. | `src/resend.zig`, `scripts/test-serve-resume.py` |
| Saved views | A completed `tool_call_update` whose result saved a `render_html` page or an MCP Apps result also carries `_meta["graff/view"]` = `{kind: "html" \| "mcp_app", id, path}`. `id` is the 32-hex snapshot name under `.graff/views` or `.graff/mcp-apps`; resolve by id and treat `path` as informational. The `[Rendered view](…)` / `[MCP app](…)` text link stays in the content. Replayed on `session/load`. | `scripts/test-acp-view-meta.py`, `src/acp_view_meta.zig` |
diff --git a/docs/adr/0205-subagent-progress-is-standard-tool-content.md b/docs/adr/0205-subagent-progress-is-standard-tool-content.md
index 636820fc..82650b44 100644
--- a/docs/adr/0205-subagent-progress-is-standard-tool-content.md
+++ b/docs/adr/0205-subagent-progress-is-standard-tool-content.md
@@ -22,8 +22,13 @@ agents report delegated work the same way.
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.
+- `_meta["graff/subagent"]` carries `{sessionId, name, state, provider, model}`
+ for clients that want to link the row to `graff/agents` inspection. The model
+ is the resolved worker model, not an unvalidated spawn argument or the parent
+ model. An initial progress update publishes it before any child activity.
+- The standard tool title includes the worker name and resolved model so clients
+ without metadata badges can show the same identity. Draft and background spawn
+ names include it too, with structured model/provider fields for 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.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index fdfc85ee..63c253c6 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -231,7 +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. |
+| [0205](0205-subagent-progress-is-standard-tool-content.md) | By default a subagent streams its work onto the parent tool call as `tool_call_update` rows (resolved-model title, rolling log + `_meta["graff/subagent"]`); the draft child-session stream only when both sides opt in; `GRAFF_ACP_SUBAGENT_PROGRESS=0` turns it off. |
| [0206](0206-acp-v2-preview-behind-a-gate.md) | ACP v2 draft shapes behind `GRAFF_ACP_V2=1` plus a client `protocolVersion` >= 2; v1 stays the default and unchanged. Prompt is acknowledged with `messageId` on insertion, the outcome travels as `state_update`. |
| [0207](0207-jev-file-retrieval-is-not-economical.md) | Rejected: no Jev file retrieval (`locate` tool, Jev rerank after `codedb context`, or jevgrep). A full Jev scan found answer files best (80% in top 5 vs 38% for `codedb context`) but costs one request per file and grows with repo size; `codedb` stays the retrieval path. |
| [0208](0208-hot-context-keyed-updates-keep-the-prefix.md) | A mid-session instruction-file edit or date rollover is appended before the next prompt as a keyed `<context>` message (developer role on Responses, system on Chat Completions, user elsewhere), and the system prompt is left as is. Compaction drops those messages and folds the latest values into the new system prompt. |
diff --git a/docs/agents-panel.md b/docs/agents-panel.md
index 02d54fcb..82ea2770 100644
--- a/docs/agents-panel.md
+++ b/docs/agents-panel.md
@@ -33,6 +33,15 @@ writes a local report and does not upload it.
Use the session and start identity from a fresh list response. Changed or
ambiguous recipients fail instead of silently targeting another process.
+For a selected peer, `action: "children"` lists its subagents and
+`action: "activity", child: "<id>"` reads one child's snapshot. Both return
+`model` and `provider` from the resolved worker configuration, including an
+inherited/default selection or fallback from an unavailable model request.
+Older activity records omit these fields and read as empty strings; clients
+should show unknown rather than infer the parent model. Live ACP progress also
+includes the resolved model in the tool title and `_meta["graff/subagent"]`;
+draft and background child spawn labels carry it before any child text arrives.
+
The desktop's short-lived observer runs the same vendor extension before model,
credential, MCP and session startup. It remains available during another Graff's
active turn. It accepts only local peer requests and creates no session.
diff --git a/scripts/test-acp-background-subagent.py b/scripts/test-acp-background-subagent.py
index 8b3340fc..926b7fd3 100644
--- a/scripts/test-acp-background-subagent.py
+++ b/scripts/test-acp-background-subagent.py
@@ -122,6 +122,13 @@ def run(binary, capability=True, cancel=False, disconnect=False, switch_session=
spawn = rows[0]
assert spawn['parentSessionId'] == sid and spawn['seq'] == 0, spawn
assert spawn['parentToolCallId'], spawn
+ actual_model = next(body['model'] for body in model.requests
+ if body.get('tools') and not any(
+ item.get('function', item).get('name') == 'subagent'
+ for item in body['tools']))
+ assert spawn['event']['model'] == actual_model, spawn
+ assert spawn['event']['provider'] == 'vercel', spawn
+ assert actual_model in spawn['event']['name'], spawn
assert all(row['subagentSessionId'] == spawn['subagentSessionId'] and
row['parentToolCallId'] == spawn['parentToolCallId'] for row in rows), rows
assert not any(row['event']['type'] == 'terminal' for row in rows), rows
diff --git a/scripts/test-acp-subagent-update.py b/scripts/test-acp-subagent-update.py
index 93f561e3..91524306 100644
--- a/scripts/test-acp-subagent-update.py
+++ b/scripts/test-acp-subagent-update.py
@@ -26,7 +26,7 @@ def run(binary, preview, capability, json_mode=False, progress_on=True):
model = load.ScriptedModel([
{'tool': 'subagent', 'arguments': {'description': 'Inspect example',
'prompt': 'Read example.txt and report its content.', 'isolation': 'shared_cwd',
- 'run_in_background': False}},
+ 'run_in_background': False, 'model': 'unavailable-fixture-model'}},
{'text': 'Child is inspecting.', 'tool': 'read_file',
'arguments': {'path': 'example.txt'}},
{'text': 'Child found SUBAGENT-FIXTURE-CONTENT.'},
@@ -72,6 +72,14 @@ def run(binary, preview, capability, json_mode=False, progress_on=True):
assert not progress, rows
return
assert progress, rows
+ actual_model = model.requests[1]['model']
+ assert actual_model != 'unavailable-fixture-model'
+ for _, update in progress:
+ meta = update['_meta']['graff/subagent']
+ assert meta['model'] == actual_model and meta['provider'] == 'vercel', update
+ assert actual_model in update['title'], update
+ assert progress[0][0] < next(i for i, update in progress
+ if 'read_file: example.txt' in str(update.get('content'))), progress
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]
@@ -88,6 +96,10 @@ def run(binary, preview, capability, json_mode=False, progress_on=True):
assert child_id != sid
assert announced['task'] == 'Read example.txt and report its content.'
assert announced['_meta']['graff/parentToolCallId'] == parent_id
+ actual_model = model.requests[1]['model']
+ meta = announced['_meta']['graff/subagent']
+ assert meta['model'] == actual_model and meta['provider'] == 'vercel', announced
+ assert actual_model in announced['name'], announced
assert finished['subagentSessionId'] == child_id
assert finished['state'] == 'completed'
assert finished['_meta']['graff/parentToolCallId'] == parent_id
diff --git a/src/acp_agent_activity.zig b/src/acp_agent_activity.zig
index e59f3a16..7ce78c55 100644
--- a/src/acp_agent_activity.zig
+++ b/src/acp_agent_activity.zig
@@ -135,12 +135,18 @@ test "child inspection verifies parent identity scope and child without consumin
defer first.deinit();
var second = try activity.Recorder.init(std.testing.allocator, io, registry, "child-b", "Second child", "Review");
defer second.deinit();
+ first.setModel("provider-a", "resolved-model-a");
+ second.setModel("provider-b", "resolved-model-b");
first.finish(true, "First child result");
second.finish(false, "Second child failed");
+ const legacy = "{\"id\":\"child-old\",\"label\":\"Legacy child\",\"task\":\"Inspect\"}";
+ try first.dir.writeFile(io, .{ .sub_path = "child-old.meta", .data = legacy });
+ try first.dir.writeFile(io, .{ .sub_path = "child-old.json", .data = "{\"agent\":" ++ legacy ++ ",\"events\":[],\"response\":\"Legacy result\"}" });
const cases = .{
.{ "children", "device", self.start_id, "", "First child", "Second child" },
.{ "activity", "device", self.start_id, "child-a", "First child result", "!Second child failed" },
.{ "activity", "device", self.start_id, "child-b", "Second child failed", "!First child result" },
+ .{ "activity", "device", self.start_id, "child-old", "Legacy result", "!First child result" },
.{ "activity", "workspace", self.start_id, "child-a", "Parent session changed", "!First child result" },
.{ "activity", "device", @as(u64, 0), "child-a", "Parent session changed", "!First child result" },
.{ "activity", "device", self.start_id, "../child-a", "Invalid sub-agent", "!First child result" },
@@ -156,6 +162,35 @@ test "child inspection verifies parent identity scope and child without consumin
if (case[5][0] == '!') {
try std.testing.expect(std.mem.indexOf(u8, out.writer.buffered(), case[5][1..]) == null);
} else try std.testing.expect(std.mem.indexOf(u8, out.writer.buffered(), case[5]) != null);
+ const reply = try std.json.parseFromSliceLeaky(std.json.Value, a, out.writer.buffered(), .{});
+ if (reply.object.get("result")) |result| {
+ const models = .{
+ .{ "child-a", "provider-a", "resolved-model-a" },
+ .{ "child-b", "provider-b", "resolved-model-b" },
+ .{ "child-old", "", "" },
+ };
+ if (result.object.get("children")) |children| {
+ try std.testing.expectEqual(@as(usize, 3), children.array.items.len);
+ inline for (models) |identity| {
+ var found = false;
+ for (children.array.items) |child_meta| {
+ if (!std.mem.eql(u8, child_meta.object.get("id").?.string, identity[0])) continue;
+ try std.testing.expectEqualStrings(identity[1], child_meta.object.get("provider").?.string);
+ try std.testing.expectEqualStrings(identity[2], child_meta.object.get("model").?.string);
+ found = true;
+ }
+ try std.testing.expect(found);
+ }
+ }
+ if (result.object.get("agent")) |child_meta| {
+ inline for (models) |identity| {
+ if (std.mem.eql(u8, child_meta.object.get("id").?.string, identity[0])) {
+ try std.testing.expectEqualStrings(identity[1], child_meta.object.get("provider").?.string);
+ try std.testing.expectEqualStrings(identity[2], child_meta.object.get("model").?.string);
+ }
+ }
+ }
+ }
}
try std.testing.expectEqual(@as(usize, 0), (try peers.tail(a, io, live, presence.device_room)).len);
}
diff --git a/src/acp_subagent_live.zig b/src/acp_subagent_live.zig
index 27247d0d..659a8507 100644
--- a/src/acp_subagent_live.zig
+++ b/src/acp_subagent_live.zig
@@ -90,7 +90,7 @@ fn backgroundSend(io: Io, handle: BackgroundHandle, id: []const u8, seq: u64, ev
return backgroundSendLocked(io, handle, id, seq, event);
}
-pub fn announceBackground(a: std.mem.Allocator, io: Io, id: []const u8, name: []const u8, task: []const u8, parent_call_id: []const u8) ?BackgroundHandle {
+pub fn announceBackground(a: std.mem.Allocator, io: Io, id: []const u8, name: []const u8, task: []const u8, parent_call_id: []const u8, provider: []const u8, model: []const u8) ?BackgroundHandle {
main.g_gui_mu.lockUncancelable(io);
defer main.g_gui_mu.unlock(io);
const state = background orelse return null;
@@ -100,10 +100,13 @@ pub fn announceBackground(a: std.mem.Allocator, io: Io, id: []const u8, name: []
.generation = state.generation,
.parent_call_id = parent_call_id,
};
+ var title: [768]u8 = undefined;
if (!backgroundSendLocked(io, handle, id, 0, .{
.type = "spawn",
- .name = util.utf8Prefix(name, 256),
+ .name = progress.displayName(&title, name, model),
.task = util.utf8Prefix(task, 2048),
+ .provider = provider,
+ .model = model,
})) return null;
return handle;
}
@@ -128,19 +131,20 @@ pub fn uninstall(io: Io) void {
active = null;
}
-pub fn announce(io: Io, id: []const u8, name: []const u8, task: []const u8, parent_call_id: []const u8) bool {
+pub fn announce(io: Io, id: []const u8, name: []const u8, task: []const u8, parent_call_id: []const u8, provider: []const u8, model: []const u8) bool {
main.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);
+ var title: [768]u8 = undefined;
proto.writeNotification(state.out, "session/update", .{ .sessionId = state.parent, .update = .{
.sessionUpdate = "subagent_update",
.subagentSessionId = id,
- .name = util.utf8Prefix(name, 256),
+ .name = progress.displayName(&title, name, model),
.task = util.utf8Prefix(task, 2048),
- ._meta = .{ .@"graff/parentToolCallId" = parent_call_id },
+ ._meta = .{ .@"graff/parentToolCallId" = parent_call_id, .@"graff/subagent" = .{ .name = name, .provider = provider, .model = model } },
} }) catch return false;
state.out.flush() catch {};
return true;
@@ -262,6 +266,11 @@ pub const ChildSink = struct {
state.out.flush() catch {};
}
+ /// Publish identity before the first text/tool event (reasoning can take time).
+ pub fn startProgress(self: *ChildSink) void {
+ self.publishProgress("running");
+ }
+
/// 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 {
@@ -308,7 +317,7 @@ test "negotiated child stream announces before activity and terminates on parent
var state: State = .{ .out = &out, .parent = "parent", .output_lock = &output_lock };
install(io, &state);
defer uninstall(io);
- try std.testing.expect(announce(io, "child", "Scout", "Inspect the code", "spawn-1"));
+ try std.testing.expect(announce(io, "child", "Scout", "Inspect the code", "spawn-1", "fixture", "reader-model"));
var child: ChildSink = .{ .id = "child", .io = io };
const emit_sink = child.engineSink();
emit_sink.emit(io, .{ .reasoning_delta = .{ .text = "I will inspect it" } });
@@ -325,6 +334,8 @@ test "negotiated child stream announces before activity and terminates on parent
try std.testing.expect(announced < thought and thought < call and call < answer and answer < terminal);
try std.testing.expect(std.mem.indexOf(u8, wire, "\"sessionId\":\"child\"") != null);
try std.testing.expect(std.mem.indexOf(u8, wire, "\"graff/parentToolCallId\":\"spawn-1\"") != null);
+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"name\":\"Scout · reader-model\"") != null);
+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"model\":\"reader-model\"") != null);
}
test "draft child sessions exclude detached and nested workers" {
@@ -343,11 +354,13 @@ test "default progress mode streams the child's work onto the parent tool call"
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(!announce(io, "child", "Scout", "Inspect", "spawn-1", "fixture", "reader-model"));
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" } };
+ var child: ChildSink = .{ .id = "child", .io = io, .progress = .{ .parent_call_id = "spawn-1", .child_id = "child", .name = "Scout", .provider = "fixture", .model = "reader-model" } };
+ child.startProgress();
+ try std.testing.expect(std.mem.indexOf(u8, out.buffered(), "\"title\":\"Scout · reader-model\"") != null);
const emit_sink = child.engineSink();
var input: std.json.ObjectMap = .empty;
defer input.deinit(std.testing.allocator);
@@ -362,6 +375,8 @@ test "default progress mode streams the child's work onto the parent tool call"
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);
+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"model\":\"reader-model\"") != null);
+ try std.testing.expect(std.mem.indexOf(u8, wire, "\"provider\":\"fixture\"") != 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.zig
index 05145d97..e1b74c91 100644
--- a/src/acp_subagent_progress.zig
+++ b/src/acp_subagent_progress.zig
@@ -23,6 +23,8 @@ pub const Progress = struct {
parent_call_id: []const u8,
child_id: []const u8,
name: []const u8,
+ provider: []const u8 = "",
+ model: []const u8 = "",
lines: [max_lines][line_max]u8 = undefined,
lens: [max_lines]usize = @splat(0),
count: usize = 0,
@@ -98,18 +100,26 @@ pub const Progress = struct {
}
};
+/// Keep the resolved model visible even in clients without extension badges.
+pub fn displayName(buf: []u8, name: []const u8, model: []const u8) []const u8 {
+ if (model.len == 0) return name;
+ return std.fmt.bufPrint(buf, "{s} · {s}", .{ util.utf8Prefix(name, 256), util.utf8Prefix(model, 256) }) catch name;
+}
+
/// 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;
+ var title: [768]u8 = undefined;
try proto.writeNotification(w, "session/update", .{
.sessionId = parent_session,
.update = .{
.sessionUpdate = "tool_call_update",
.toolCallId = p.parent_call_id,
+ .title = displayName(&title, p.name, p.model),
.content = .{
.{ .type = "content", .content = .{ .type = "text", .text = p.render(&buf) } },
},
- ._meta = .{ .@"graff/subagent" = .{ .sessionId = p.child_id, .name = p.name, .state = state } },
+ ._meta = .{ .@"graff/subagent" = .{ .sessionId = p.child_id, .name = p.name, .state = state, .provider = p.provider, .model = p.model } },
},
});
}
diff --git a/src/subagent_activity.zig b/src/subagent_activity.zig
index 3bd3522d..18ce6773 100644
--- a/src/subagent_activity.zig
+++ b/src/subagent_activity.zig
@@ -14,6 +14,8 @@ pub const Meta = struct {
id: []const u8,
label: []const u8,
task: []const u8,
+ provider: []const u8 = "",
+ model: []const u8 = "",
status: []const u8 = "working",
updatedAt: i64 = 0,
truncated: bool = false,
@@ -85,6 +87,14 @@ pub const Recorder = struct {
self.events.deinit(self.a);
self.dir.close(self.io);
}
+ /// Identity strings are borrowed for the recorder's run lifetime, like label/task.
+ pub fn setModel(self: *Recorder, provider: []const u8, model: []const u8) void {
+ self.mu.lockUncancelable(self.io);
+ defer self.mu.unlock(self.io);
+ self.meta.provider = util.utf8Prefix(provider, 256);
+ self.meta.model = util.utf8Prefix(model, 256);
+ self.publish(true);
+ }
pub fn engineSink(self: *Recorder) sink.EngineSink {
return .{ .ctx = self, .vt = &vtable };
}
@@ -229,6 +239,16 @@ test "child activity coalesces deltas and bounds retained events and text" {
try std.testing.expect(r.meta.truncated);
try std.testing.expect(!validId("../elsewhere"));
try std.testing.expect(validId("sa-001-abc"));
+ var identity: [257]u8 = undefined;
+ @memset(identity[0..255], 'a');
+ @memcpy(identity[255..], "é");
+ r.setModel(&identity, &identity);
+ try std.testing.expectEqual(@as(usize, 255), r.meta.provider.len);
+ try std.testing.expectEqualStrings(identity[0..255], r.meta.model);
+ const legacy = try std.json.parseFromSlice(Meta, std.testing.allocator, "{\"id\":\"old-child\",\"label\":\"Old\",\"task\":\"Review\"}", .{});
+ defer legacy.deinit();
+ try std.testing.expectEqualStrings("", legacy.value.provider);
+ try std.testing.expectEqualStrings("", legacy.value.model);
}
test "frontendless child SSE reaches its own activity sink and final snapshot" {
@@ -240,6 +260,18 @@ test "frontendless child SSE reaches its own activity sink and final snapshot" {
defer a.free(root);
var recorder = try Recorder.init(a, io, root, "child-one", "Review", "Check the boundary");
defer recorder.deinit();
+ recorder.setModel("provider-a", "resolved-model-a");
+ // Identity is visible before any engine event, despite the publish throttle.
+ inline for (.{ "child-one.meta", "child-one.json" }) |name| {
+ const identity_bytes = try recorder.dir.readFileAlloc(io, name, a, .limited(file_limit));
+ defer a.free(identity_bytes);
+ const T = if (comptime std.mem.endsWith(u8, name, ".meta")) Meta else Snapshot;
+ const identity = try std.json.parseFromSlice(T, a, identity_bytes, .{});
+ defer identity.deinit();
+ const meta = if (T == Meta) identity.value else identity.value.agent;
+ try std.testing.expectEqualStrings("provider-a", meta.provider);
+ try std.testing.expectEqualStrings("resolved-model-a", meta.model);
+ }
var arena = std.heap.ArenaAllocator.init(a);
defer arena.deinit();
var agent: @import("agent.zig").Agent = .{
@@ -266,6 +298,8 @@ test "frontendless child SSE reaches its own activity sink and final snapshot" {
defer a.free(bytes);
const parsed = try std.json.parseFromSlice(Snapshot, a, bytes, .{});
defer parsed.deinit();
+ try std.testing.expectEqualStrings("provider-a", parsed.value.agent.provider);
+ try std.testing.expectEqualStrings("resolved-model-a", parsed.value.agent.model);
try std.testing.expectEqualStrings("completed", parsed.value.agent.status);
try std.testing.expectEqualStrings("Review finished", parsed.value.response);
try std.testing.expectEqual(@as(usize, 4), parsed.value.events.len);
diff --git a/src/subagent_run.zig b/src/subagent_run.zig
index 34206f5a..3bb8f711 100644
--- a/src/subagent_run.zig
+++ b/src/subagent_run.zig
@@ -326,6 +326,7 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const
var activity = @import("subagent_activity.zig").start(gpa, ctx.io, sub_id, label, prompt);
defer if (activity) |*recorder| recorder.deinit();
if (activity) |*recorder| {
+ recorder.setModel(agent.provider.id, agent.provider.model);
if (@import("subagent_activity.zig").interruptRequested(ctx.io, recorder.dir, sub_id)) {
recorder.finish(false, "Interrupted.");
return .{ .output = .{ .text = try gpa.dupe(u8, "Interrupted."), .is_error = true }, .usage = .{} };
@@ -365,9 +366,9 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const
const acp_children = @import("acp_subagent_live.zig");
const detached = ctx.subagent_feedback != null;
const announce_child = acp_children.eligible(kind, ctx.depth, detached);
- const announced = announce_child and acp_children.announce(ctx.io, sub_id, label, prompt, ctx.parent_tool_call_id);
+ const announced = announce_child and acp_children.announce(ctx.io, sub_id, label, prompt, ctx.parent_tool_call_id, agent.provider.id, agent.provider.model);
const background_handle: ?acp_children.BackgroundHandle = if (detached and std.mem.eql(u8, kind, "subagent") and ctx.depth == 0 and ctx.parent_tool_call_id.len > 0)
- acp_children.announceBackground(arena, ctx.io, sub_id, label, prompt, ctx.parent_tool_call_id)
+ acp_children.announceBackground(arena, ctx.io, sub_id, label, prompt, ctx.parent_tool_call_id, agent.provider.id, agent.provider.model)
else
null;
const background_announced = background_handle != null;
@@ -377,9 +378,10 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const
.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,
+ .progress = if (progress_on) .{ .parent_call_id = ctx.parent_tool_call_id, .child_id = sub_id, .name = label, .provider = agent.provider.id, .model = agent.provider.model } else null,
};
if (announced or background_announced or progress_on) agent.sink = child_stream.engineSink();
+ if (progress_on) child_stream.startProgress();
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);