#7314 · Delegated timeline detail request ownership
Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro
1. TL;DR
Expanding a subagent can load its activity successfully while a second expansion, for a command inside it, requests details using the wrong owner. The command keeps its child turn identity and narrow event range, but the server detail endpoint projects enclosing top-level turns. The client therefore needs the enclosing delegation's turn and source range while retaining the child's item ID. A component regression demonstrates the incorrect request, and a real migrated SQLite fixture reproduces the server rejection and the successful enclosing-scope request. Both reproductions were repeated by the same agent in a second clean checkout.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| A child command uses its own turn and event range for deferred details. | Verified | Four component cases fail before the fix: inline/deferred delegation children, each with deferred content or retained output. |
| The child-scope request is rejected; using the parent turn and delegation range resolves output. | Verified | The real server detail service throws its 400 invalid_request error for child scope and returns the command's full output for parent scope. |
| The failure necessarily means no child turn/started event exists. | Not necessary | The reproduction explicitly persists child turn/started. It still fails because the requested child is not a top-level projected turn entry. |
| Every row in the reporter's particular session fails, including file changes. | Unverified | No private session was accessed. Command detail routing is reproduced directly; other deferred row kinds use the same identity path. |
| Retries cannot repair the ownership mismatch. | Verified mechanism | Retry reuses the same query identity; no transient network condition is involved. |
3. Environment
- Public repository: get-bb/bb; trusted origin/main base recorded above.
- Linux x86_64; Node 22.19.0; pnpm 9.15.0; Vitest 4.1.12.
- Two separate temporary git worktrees at the same recorded commit, with fresh frozen installs. Production source stayed unchanged during reproduction.
- No real provider, desktop app, production database, account, or network-facing development instance was used. The server fixture creates a fresh migrated SQLite database and removes it afterward. No application ports are required.
- Initial full build required the repository's SDK type-build prerequisite; after that, all 73 build tasks passed.
4. Minimal reproduction
- Clone the trusted repository and select the recorded main commit:
git clone https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout --detach cb43c6c5f52dfbbce62771fc075424ce0a0c3bf3 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build
- Save this complete test as
apps/server/test/services/threads/issue-7314-repro.test.ts. It uses the repository's existing real SQLite fixture, not a database mock:import { expect, it } from "vitest"; import { buildTimelineTurnSummaryDetails } from "../../../src/services/threads/timeline.js"; import { appendRows, withTestThread } from "../../helpers/timeline-cache-fixture.js"; it("reproduces invalid child scope and resolves output through the delegation scope", () => { withTestThread((testThread) => { const delegation = { type: "delegation", id: "agent-call", childRef: "provider-child", label: "Inspect", background: false, }; const command = { type: "commandExecution", id: "child-command", command: "inspect-child", cwd: "/tmp/repro", approvalStatus: null, parentToolCallId: "agent-call", }; appendRows(testThread, [ { type: "turn/started", turnId: "parent-turn" }, { type: "item/started", turnId: "parent-turn", itemId: "agent-call", itemKind: "delegation", data: { item: { ...delegation, status: "pending" } }, }, { type: "turn/started", turnId: "child-turn", providerThreadId: "provider-child", parentToolCallId: "agent-call", }, { type: "item/started", turnId: "child-turn", providerThreadId: "provider-child", parentToolCallId: "agent-call", itemId: "child-command", itemKind: "commandExecution", data: { item: { ...command, status: "pending" } }, }, { type: "item/completed", turnId: "child-turn", providerThreadId: "provider-child", parentToolCallId: "agent-call", itemId: "child-command", itemKind: "commandExecution", data: { item: { ...command, status: "completed", exitCode: 0, aggregatedOutput: "SUBAGENT COMMAND OUTPUT" } }, }, { type: "turn/completed", turnId: "child-turn", providerThreadId: "provider-child", parentToolCallId: "agent-call", data: { status: "completed" }, }, { type: "item/completed", turnId: "parent-turn", itemId: "agent-call", itemKind: "delegation", data: { item: { ...delegation, status: "completed" } }, }, { type: "turn/completed", turnId: "parent-turn", data: { status: "completed" } }, ]); const request = { completedTurnDisplay: "collapse" as const, deferContent: true, includeDiagnosticOperations: false, itemId: "child-command", sourceSeqStart: 4, sourceSeqEnd: 5, summarizeShellCommands: false, turnId: "child-turn", }; expect(() => buildTimelineTurnSummaryDetails(testThread.db, testThread.thread, request)) .toThrow("does not include turn child-turn"); const result = buildTimelineTurnSummaryDetails(testThread.db, testThread.thread, { ...request, sourceSeqStart: 2, sourceSeqEnd: 7, turnId: "parent-turn", }); expect(result.rows).toEqual([ expect.objectContaining({ callId: "child-command", output: "SUBAGENT COMMAND OUTPUT" }), ]); }); }); - Run the reproduction:
pnpm exec turbo run test --filter=@bb/server -- issue-7314-repro.test.ts
Expected healthy behavior: the command's details are addressed using its enclosing delegation scope. Observed behavior on unchanged main when using the child identity:
Timeline turn summary details range 4-5 does not include turn child-turn status: 400 code: invalid_request
The test passes because it asserts this failure and then verifies that
turnId=parent-turn,sourceSeqStart=2,sourceSeqEnd=7, and the same child item ID returnSUBAGENT COMMAND OUTPUT. - To reproduce the client-side regression, insert the following case in the existing
describe("deferred timeline details", ...)block ofapps/app/src/components/thread/timeline/ThreadTimelineRows.deferred-details.test.tsx. All its imports, fixtures, and render helpers already exist in that file:it.each([ { deferredChildren: false, retainedOutput: false }, { deferredChildren: true, retainedOutput: false }, { deferredChildren: false, retainedOutput: true }, { deferredChildren: true, retainedOutput: true }, ])( "loads subagent command details in the enclosing delegation scope: %j", async ({ deferredChildren, retainedOutput }) => { const loaded = commandRow({ callId: "child-command", command: "inspect-child", output: "SUBAGENT COMMAND OUTPUT", sourceSeqStart: 20, sourceSeqEnd: 22, threadId: "thr_main", turnId: "child-turn", }); const child: TimelineRow = retainedOutput ? { ...loaded, output: "preview", outputPreview: { experimental_fullOutputAvailability: "available", totalChars: loaded.output.length, }, } : { ...loaded, output: "", contentDeferred: true }; const delegation = delegationRow({ callId: "agent-call", childRows: [child], sourceSeqStart: 12, sourceSeqEnd: 30, threadId: "thr_main", turnId: "parent-turn", }); timelineTurnSummaryDetails.mockImplementation(async (input) => ({ olderCursor: null, rows: input.itemId === "agent-call" ? [delegation] : [loaded], })); renderExpandedRow( deferredChildren ? { ...delegation, childRows: null } : delegation, ); const header = await screen.findByText(/inspect-child/); fireEvent.pointerDown(header); await vi.waitFor(() => { expect(timelineTurnSummaryDetails).toHaveBeenCalledWith( expect.objectContaining({ itemId: loaded.callId, sourceSeqEnd: "30", sourceSeqStart: "12", threadId: "thr_main", turnId: "parent-turn", }), ); }); fireEvent.click(header); expect(await screen.findByText(/SUBAGENT COMMAND OUTPUT/)).toBeTruthy(); expect( timelineTurnSummaryDetails.mock.calls.filter( ([input]) => input.itemId === loaded.callId, ), ).toHaveLength(1); }, );pnpm exec turbo run test --filter=@bb/app -- ThreadTimelineRows.deferred-details.test.tsx
The SDK mock supplies response data, but does not validate or manufacture the asserted request identity. The failing assertion checks the real component's outgoing query against the server's independently exercised scope contract.
Expected: sourceSeqStart "12", sourceSeqEnd "30", turnId "parent-turn" Received: sourceSeqStart "20", sourceSeqEnd "22", turnId "child-turn" Test Files 1 failed (1) Tests 4 failed | 6 passed (10)
This is a functional request-routing reproduction, not a visual rendering reproduction; no screenshots or live desktop verification are claimed.
5. Root cause
The client builds deferred request identity directly from the child row. Its turnId is a subagent turn and its source window covers the command, not the enclosing delegation. The same mistake occurs in both the preload path and the eventual content request; retained-output hydration also reconstructs identity directly from the child.
- Client identity construction and preloading
- Expanded deferred content request
- Retained full-output request
- Projection requires a matching top-level turn entry
- Server turns projection mismatch into a 400 error
- Server locates the child item recursively after projecting the correct enclosing scope
const includesRequestedTurn = projection.entries.some(
(entry) =>
entry.kind === "turn" &&
entry.turn.turnId === args.options.turnId &&
entry.turn.sourceSeqEnd >= args.options.sourceSeqStart,
);
if (!includesRequestedTurn) {
return { kind: "missing-match" };
}
Persisted child lifecycle events are insufficient: delegation projection nests their work rather than exposing the subagent as a top-level turn match. Retrying the identical identity repeats the same deterministic error. Changing only the turn ID is also insufficient to preserve the enclosing materialization context; retain the delegation range too.
6. Proposed fix and tested candidate
Carry an enclosing detail source through delegation rendering and resolve child detail identities against that source when the thread matches. Keep the child item ID unchanged. Use the same helper for preload, expanded deferred content, nested delegation loading, and retained full output. Normal top-level rows continue to use their own source. Nested delegations inherit the already-resolved enclosing source; different-thread rows do not adopt another thread's source.
The tested candidate changes five files within the existing app timeline subsystem, totaling 226 text lines (150 additions + 76 deletions). It adds no dependency, generated file, stored-data change, public API, schema, protocol, or security-boundary change.
Focused regression after fix: 10 passed Timeline suite after fix: 39 files, 470 tests passed App typecheck and lint: passed (existing lint warnings, zero errors) App production build: passed git diff --check: passed
Live web/desktop journeys were not run. The verification inventory helper is independently blocked by an existing unmapped diagnostics CLI family; that unrelated inventory drift was not changed.
7. Verification: second clean checkout
The same agent created a second detached worktree at cb43c6c5f52dfbbce62771fc075424ce0a0c3bf3, installed frozen dependencies, and copied only the newly authored reproduction tests. No production fix was present. This is a repeat run, not independent verification.
git worktree add --detach "$VERIFY" cb43c6c5f52dfbbce62771fc075424ce0a0c3bf3 cd "$VERIFY" pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run test --filter=@bb/app -- ThreadTimelineRows.deferred-details.test.tsx pnpm exec turbo run test --filter=@bb/server -- issue-7314-repro.test.ts Client regression: 4 failed | 6 passed (same wrong child scope) Server reproduction: 1 passed (same rejection and successful parent-scope output)
The server fixture used a newly created temporary SQLite database on the second run. No ports or shared runtime data were involved. The second run supported the report; no verdict correction was required. The fix branch was subsequently rebased onto trusted main 9f8a71c1b643ed9afddfe0a63892c2ff5029241b, whose intervening changes do not touch the affected timeline paths.
8. Related issues and pull requests
No open pull request linked to #7314 was found in GitHub cross-reference metadata or the open-PR search before the fix was prepared. A narrow search found no separate matching issue. No linked pull-request code was checked out or run.
9. Appendix and limits
Initial trusted build passed 73 tasks after pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk supplied missing SDK dist prerequisites. The two baseline client runs observed the same four failures. The two real server runs each passed their one rejection/success assertion. The fixed component test then passed all ten cases, and the adjacent timeline suite passed 470 tests.
The issue description was treated solely as untrusted claims. No instruction, script, patch, branch, external attachment, or private session data from it was executed or accessed. Reproduction code was authored from trusted repository fixtures and call paths. This report does not establish the exact number of failing rows in the reporter's session, live Codex behavior, or platform-specific desktop rendering.
Raw logs and reproduction source remain outside the public reports repository. Complete repeatable source is embedded above rather than publishing test files or runtime data.
> AGENT GENERATED