You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(runtime): conversation copy leaves parentOperationId at the source identity #3800
parentOperationId falls into ...preserved and is carried over unchanged.
It is always wrong after a copy, not sometimes: toolOperationIdMap (:852) rebuilds every operation id as buildToolOperationId({ invocationId: <target>, providerToolCallId }), and the target invocation id is freshly minted. The write site puts the same namespace in — ai-sdk-backend.ts:3101 sets parentOperationId: context.operationId.
Effect. Copy a session that used Code Mode, and nested tool calls point at the source session's operation while the parent has been renamed in the target. runtime-event-read-model.ts:922-937 projects the field into StoredMessage, so parent/child pairing breaks. tool-ledger-scanner.ts:516 only shape-checks, so nothing errors — silent, like #3775.
Fix. Route it through rewriteOwnedId(..., references.operationIds, 'tool operation') in the same destructure.
Found while sweeping for a second instance of the gap #3776 fixed: isCopiedAgentRunEvent only tests whether the build emits a type, not whether a rewriter exists for it. No second case at the AgentRun payload level; this one is on the RuntimeEvent side of the same file.
Also spotted, not worth its own issue: contextBudget.compactionDecisions[].boundaryIds keeps source checkpoint ids in model_stream_started / send_diagnostics_recorded payloads and in copied token_usage messages. No production consumer reads them back, so the ids just dangle.
I've verified the gap locally: the destructure at conversation-copy.ts:1014 keeps parentOperationId in ...preserved, so it survives the copy unchanged while every operation id is rebuilt by toolOperationIdMap with the fresh target invocation id. The fix is to route it through rewriteOwnedId(..., references.operationIds, 'tool operation') alongside operationId, mirroring the existing strictness.
I'll also add a regression test in conversation-copy.test.ts covering a Code Mode-style nested call (parent dispatch + child event carrying refs.parentOperationId), asserting the copied child points at the parent's new operation id.
Activity
chinawch007 commentedon Aug 25, 2026
Hi, I'd like to take this one.
I've verified the gap locally: the destructure at conversation-copy.ts:1014 keeps parentOperationId in ...preserved, so it survives the copy unchanged while every operation id is rebuilt by toolOperationIdMap with the fresh target invocation id. The fix is to route it through rewriteOwnedId(..., references.operationIds, 'tool operation') alongside operationId, mirroring the existing strictness.
I'll also add a regression test in conversation-copy.test.ts covering a Code Mode-style nested call (parent dispatch + child event carrying refs.parentOperationId), asserting the copied child points at the parent's new operation id.
fix(runtime): rewrite parentOperationId when copying conversations
liuxiaocs7 commentedon Aug 25, 2026
Hi, @Astro-Han, take assign