#7342 · ACP translation drops nested output ownership
Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro
1. TL;DR
Nested ACP updates lose their owning tool-call identity during translation. A deterministic test feeds interleaved main and nested output through the real ACP translator and real delta assembler: the resulting main messages contain child text, and the child command has no parent. Opening the child command also splits the main message. The assembler already supports parent-aware streams; the ACP translator omits the existing ownership key. This report reproduces the event/data defect, not a screenshot or a live authenticated Claude session.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Nested text mixes into main messages and fragments them at child tool calls. | Verified | Both clean-base test runs produce main/child concatenation in two parentless assistant items. |
| Nested reasoning and command calls lack their owner. | Verified | The final baseline run reports separate soft assertion failures for missing reasoning and command parentToolCallId. |
| The existing protocol can express nested streams. | Verified | The assembler keys by parentRef and resolves it to parentToolCallId. The contained translator-only repair passes the regression. |
| A live claude-agent-acp process emits this exact metadata. | Not exercised live | Input metadata is synthetic and supplied at the actual ACP session-update boundary. No external provider package, account, or issue-supplied code was executed. |
3. Environment
- Public repository
get-bb/bb, trustedorigin/maincommit7c1353d80729983b86ea1555d18b42407f320406. - Linux, Node.js
v22.19.0, pnpm9.15.0; repository ACP SDK pin1.9.0. - Two separate temporary detached worktrees were created at the identical base. Frozen dependency installations completed in both.
- No app server, browser, external provider, production data, credentials, ports, or user database were needed.
- The initial full build exposed unbuilt Plugin SDK outputs. Building the existing SDK through Turbo and retrying completed all 73 build tasks; no dependency or source change was needed for that prerequisite.
4. Minimal reproduction
- Start from a clean checkout of the public repository at the recorded base:
git clone https://github.com/get-bb/bb.git bb-7342 cd bb-7342 git checkout 7c1353d80729983b86ea1555d18b42407f320406 pnpm install --frozen-lockfile --prefer-offline
- Copy the complete regression patch below into
/tmp/7342-regression.patchand apply it. It only adds tests and disables timing throttling in the existing test harness:git apply /tmp/7342-regression.patch pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/delta-translation.test.ts -t 'keeps interleaved nested messages'
- The regression opens an owning tool call, starts a root assistant message, interleaves nested thought/text, opens and completes a nested command, completes the owner, then resumes root text.
Expected vs actual
Expected assistant texts (with the first two attached to the owning call):
Child before command. Child finished. Main before. Main after.
Actual baseline assertion diff excerpts, verbatim:
- "parentToolCallId": "acp-test-i1", - "text": "Child before command.", + "id": "acp-test-i2", + "text": "Main before. Child before command.", + "type": "agentMessage", - "text": "Main before. Main after.", + "id": "acp-test-i5", + "text": "Child finished.Main after.", + "type": "agentMessage",
The command result retains its output but lacks the expected owner:
{
"aggregatedOutput": "nested",
- "parentToolCallId": "acp-test-i1",
}
Baseline: process exit 1, one failing regression with four soft assertion failures (messages, reasoning ownership, command ownership, and closing nested text when the owner completes). The repaired translator passes this regression and all 90 tests in the translation test file.
Complete self-contained regression patch
diff --git a/packages/provider-bridge-acp/src/delta-translation.test.ts b/packages/provider-bridge-acp/src/delta-translation.test.ts
index f78b65ea3d..927ff1d3f0 100644
--- a/packages/provider-bridge-acp/src/delta-translation.test.ts
+++ b/packages/provider-bridge-acp/src/delta-translation.test.ts
@@ -8,6 +8,7 @@ import {
ACP_COMPACTION_COMPLETED_METHOD,
ACP_COMPACTION_STARTED_METHOD,
ACP_FS_WRITE_METHOD,
+ ACP_PROMPT_INTERRUPTED_METHOD,
ACP_TURN_COMPLETED_METHOD,
ACP_TURN_STARTED_METHOD,
ACP_UPDATE_METHOD,
@@ -46,6 +47,7 @@ function createHarness(
providerId: "acp",
entropyPrefix: ENTROPY,
textDeltaFlushMs: 0,
+ progressThrottleMs: 0,
});
return {
assembler,
@@ -113,6 +115,217 @@ function completedItems(events: ThreadEvent[]) {
);
}
+describe("ACP nested output ownership", () => {
+ it("keeps interleaved nested messages and commands under their owning call", () => {
+ const harness = createHarness();
+ harness.translate(turnStartedEvent());
+ const events: ThreadEvent[] = [];
+ function send(update: Record<string, unknown>) {
+ const translated = harness.translate(updateEvent(update));
+ events.push(...translated);
+ return translated;
+ }
+ const parentEvents = send({
+ sessionUpdate: "tool_call",
+ toolCallId: "owner-call",
+ title: "Delegate work",
+ kind: "other",
+ status: "in_progress",
+ });
+ const parent = parentEvents.find((event) => event.type === "item/started");
+ if (parent?.type !== "item/started") {
+ throw new Error("Expected the owning call to open");
+ }
+ send({
+ sessionUpdate: "agent_message_chunk",
+ content: { type: "text", text: "Main before. " },
+ });
+ const metadata = { claudeCode: { parentToolUseId: "owner-call" } };
+ send({
+ sessionUpdate: "agent_thought_chunk",
+ content: { type: "text", text: "Child thinking." },
+ _meta: metadata,
+ });
+ send({
+ sessionUpdate: "agent_message_chunk",
+ content: { type: "text", text: "Child before command." },
+ _meta: metadata,
+ });
+ send({
+ sessionUpdate: "tool_call",
+ toolCallId: "nested-command",
+ title: "Run command",
+ kind: "execute",
+ rawInput: { command: "printf nested" },
+ status: "in_progress",
+ _meta: metadata,
+ });
+ send({
+ sessionUpdate: "tool_call_update",
+ toolCallId: "nested-command",
+ status: "completed",
+ rawOutput: "nested",
+ });
+ send({
+ sessionUpdate: "agent_message_chunk",
+ content: { type: "text", text: "Child finished." },
+ _meta: metadata,
+ });
+ const ownerCompleted = send({
+ sessionUpdate: "tool_call_update",
+ toolCallId: "owner-call",
+ status: "completed",
+ });
+ send({
+ sessionUpdate: "agent_message_chunk",
+ content: { type: "text", text: "Main after." },
+ });
+ events.push(...harness.translate(turnCompletedEvent("end_turn")));
+ const items = completedItems(events);
+ expect.soft(items.filter((item) => item.type === "agentMessage")).toEqual([
+ expect.objectContaining({
+ text: "Child before command.",
+ parentToolCallId: parent.item.id,
+ }),
+ expect.objectContaining({
+ text: "Child finished.",
+ parentToolCallId: parent.item.id,
+ }),
+ expect.objectContaining({ text: "Main before. Main after." }),
+ ]);
+ expect.soft(items.find((item) => item.type === "reasoning")).toMatchObject({
+ content: ["Child thinking."],
+ parentToolCallId: parent.item.id,
+ });
+ expect
+ .soft(items.find((item) => item.type === "commandExecution"))
+ .toMatchObject({
+ parentToolCallId: parent.item.id,
+ aggregatedOutput: "nested",
+ });
+ expect
+ .soft(completedItems(ownerCompleted))
+ .toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ text: "Child finished." }),
+ ]),
+ );
+ });
+
+ it.each(["execute", "other"])(
+ "retains the opening parent for %s progress and completion",
+ (kind) => {
+ const harness = createHarness();
+ harness.translate(turnStartedEvent());
+ const opened = harness.translate(
+ updateEvent({
+ sessionUpdate: "tool_call",
+ toolCallId: "nested",
+ kind,
+ title: "Nested work",
+ status: "in_progress",
+ rawInput: kind === "execute" ? { command: "printf nested" } : {},
+ _meta: { claudeCode: { parentToolUseId: "owner" } },
+ }),
+ );
+ const started = opened.find((event) => event.type === "item/started");
+ if (started?.type !== "item/started") {
+ throw new Error("Expected nested work to open");
+ }
+ expect(started.item.parentToolCallId).toBeDefined();
+ const progress = harness.translate(
+ updateEvent({
+ sessionUpdate: "tool_call_update",
+ toolCallId: "nested",
+ status: "in_progress",
+ rawOutput: "working",
+ _meta: { claudeCode: { parentToolUseId: "different-owner" } },
+ }),
+ );
+ expect(progress).toContainEqual(
+ expect.objectContaining({
+ type:
+ kind === "execute"
+ ? "item/commandExecution/outputDelta"
+ : "item/toolCall/progress",
+ itemId: started.item.id,
+ parentToolCallId: started.item.parentToolCallId,
+ }),
+ );
+ const closed = completedItems(
+ harness.translate(
+ updateEvent({
+ sessionUpdate: "tool_call_update",
+ toolCallId: "nested",
+ status: "completed",
+ }),
+ ),
+ );
+ expect(closed).toContainEqual(
+ expect.objectContaining({
+ id: started.item.id,
+ parentToolCallId: started.item.parentToolCallId,
+ }),
+ );
+ },
+ );
+
+ it.each(["completed", "interrupted"])(
+ "flushes every nested stream when %s",
+ (ending) => {
+ const harness = createHarness();
+ harness.translate(turnStartedEvent());
+ for (const owner of ["first", "second"]) {
+ harness.translate(
+ updateEvent({
+ sessionUpdate: "agent_message_chunk",
+ content: { type: "text", text: owner },
+ _meta: { claudeCode: { parentToolUseId: owner } },
+ }),
+ );
+ }
+ const flushed = harness.translate(
+ ending === "completed"
+ ? turnCompletedEvent("end_turn")
+ : {
+ jsonrpc: "2.0",
+ method: ACP_PROMPT_INTERRUPTED_METHOD,
+ params: { threadId: THREAD_ID },
+ },
+ );
+ expect(completedItems(flushed)).toEqual([
+ expect.objectContaining({
+ text: "first",
+ parentToolCallId: expect.any(String),
+ }),
+ expect.objectContaining({
+ text: "second",
+ parentToolCallId: expect.any(String),
+ }),
+ ]);
+ },
+ );
+
+ it.each([null, 42, "", "bad\u001fkey", "self"])(
+ "ignores invalid or self-referential ownership %j",
+ (parentToolUseId) => {
+ const harness = createHarness();
+ harness.translate(turnStartedEvent());
+ const events = harness.translate(
+ updateEvent({
+ sessionUpdate: "tool_call",
+ toolCallId: "self",
+ kind: "other",
+ status: "completed",
+ _meta: { claudeCode: { parentToolUseId } },
+ }),
+ );
+ expect(completedItems(events)).toHaveLength(1);
+ expect(completedItems(events)[0]).not.toHaveProperty("parentToolCallId");
+ },
+ );
+});
+
describe("acp file change kinds", () => {
function fileChangesFor(
updates: Record<string, unknown>[],
5. Root cause
The inbound session-update schemas retain unknown metadata, but the translator never uses the nested owner when constructing delta keys. The following links target the immutable base, not a moving branch:
- Inbound text/tool schemas retain extra fields.
- Assistant and thought updates use only channel keys.
- Every tool opening closes the root streams and opens without a parent.
- Tool updates, output snapshots, and progress also omit ownership.
- Assembler stream identity includes parentRef and Parent references resolve to public item IDs.
Without a parent-aware key, main and child text address the same stream. A child command therefore closes that shared stream and becomes a root item. Merely adding ownership to opening events is insufficient: subsequent snapshots, progress, and close events must reuse the opening identity, including an intentionally absent root parent.
6. Proposed fix
Validate the optional owner metadata against the existing delta-key contract. Preserve the opening owner on each tool call, ignore invalid or self-referential owners, and include it on text, tool, progress, and output keys. Track active nested stream owners per thread, close only the relevant streams during a tool opening, close an owner's nested streams when that call ends, and flush all remaining owners at turn completion or interruption. This uses the existing protocol without changing its schema or meaning.
The local candidate changes only the ACP translator and its existing test file, with no new dependency, stored data, public API, or wire-schema change. Additional tests cover command snapshots, generic progress, conflicting later metadata, multiple owners at completion/interruption, and invalid/self ownership.
7. Verification
The same agent repeated the reproduction in a second clean temporary worktree, initially confirmed clean with git status --short, at 7c1353d80729983b86ea1555d18b42407f320406. Only the agent-authored regression was added; production source stayed untouched. A second frozen install and the identical focused Turbo command failed on the same main/child concatenation. A final run with soft assertions additionally confirmed the missing reasoning/command owner and missing owner-completion text flush. This is a repeat by the same agent, not independent verification.
Recorded ACP Cursor parity was also compared against the unchanged second checkout. The default historical allowlist rejects now-stale exceptions rather than reporting new output differences. Repeating with a temporary empty allowlist verifies identical events and rows; the repository allowlist itself was not changed. The recorded conformance test also passes inside the full ACP suite.
Fixture correction: the initial command-result fixture used an object that the generic dialect serializes verbatim; it was changed to the supported string result nested. This does not change the reproduced ownership failure. No provider-specific parsing claim is based on that discarded object fixture.
Root-cause links were checked against the recorded commit. The repaired ACP package suite passes: 25 test files, 587 tests passed, 4 skipped; the translation file passes all 90 tests. Package lint and typecheck also pass. No linked open pull request was present in the issue timeline or the open-PR search at investigation time. No issue-supplied script, test, patch, branch, or external link was executed.
8. Related issues
Existing ACP classifications were sampled for consistency. No duplicate report of this specific ownership defect was established; related protocol usage/discovery issues were not treated as evidence for this bug.
9. Appendix and limits
The complete test is inline above so no raw transcript, patch file, machine-specific directory, or runtime data needs publication. Local evidence includes the two baseline logs, full build log, focused repaired test log, and full ACP suite log. This is a translator/assembler data regression: visible UI nesting follows the emitted ownership fields, but no live UI screenshot or external-agent version is claimed.
Trust boundary: issue text was used only as a hypothesis. The reproduction and fix were authored from trusted repository source; issue suggestions were not executed as instructions.