Loading workspace insights... Statistics interval
7 days30 daysLatest CI Pipeline Executions
e7ad181c fix(ai): preserve tool-call metadata across MESSAGES_SNAPSHOT so addToolResult works (#859) (#867)
* fix(ai): preserve tool-call metadata across MESSAGES_SNAPSHOT so addToolResult works
The AG-UI MESSAGES_SNAPSHOT wire shape cannot reconstruct client-side
tool-call metadata a server may omit: a `role: 'tool'` message only carries
`toolCallId` + `content`, and an assistant snapshot message may drop
`toolCalls` the client already observed via `TOOL_CALL_*` events. After a
snapshot the matching `tool-call` part could vanish, so a later
`addToolResult(toolCallId)` failed to locate the call and silently no-op'd.
`handleMessagesSnapshotEvent` now reconciles the normalized snapshot with the
pre-snapshot state: (a) detached `tool-result`-only assistant messages are
anchored into the preceding assistant message to match the streaming fan-out
shape, and (b) a `tool-call` part is carried forward from the prior state when
the snapshot references its `toolCallId` via a `tool-result` but omits the
corresponding `tool-call` part.
Fixes #859
* style: apply prettier formatting
* Merge branch 'main' into fix/issue-859-snapshot-tool-call-preservation
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Merge branch 'main' into fix/issue-859-snapshot-tool-call-preservation
* fix(ai): anchor snapshot tool-results by matching tool-call and warn on unrecoverable metadata
Review follow-ups on the MESSAGES_SNAPSHOT reconciliation:
- Anchor a detached tool-result into the message that contains its
matching tool-call part, falling back to the nearest anchorable
assistant only when the snapshot omits the call. AG-UI reasoning/
activity messages also normalize to role 'assistant', so the
nearest-assistant heuristic could separate a result from its call and
a later addToolResult would append a duplicate result next to the call.
- console.warn when a snapshot tool-result has no matching tool-call in
the snapshot, the pre-snapshot state, or no assistant to anchor into —
previously these degraded states were silent and left the #859 symptom
with no breadcrumb.
- Copy parts arrays instead of pushing into them: passthrough snapshot
messages share their parts array with the incoming chunk, and the
carried-forward tool-call part was shared by reference with the
previous messages array.
- Fix two comments ("Bump last-write-wins", "silently no-op") and dedupe
the handler comment against the method doc.
- Tests: multi-turn anchoring, reasoning-message interleaving,
consecutive snapshots, unrecoverable-metadata warn, and pin the
detached-message + warn behavior in the existing tool-message test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> e7ad181c fix(ai): preserve tool-call metadata across MESSAGES_SNAPSHOT so addToolResult works (#859) (#867)
* fix(ai): preserve tool-call metadata across MESSAGES_SNAPSHOT so addToolResult works
The AG-UI MESSAGES_SNAPSHOT wire shape cannot reconstruct client-side
tool-call metadata a server may omit: a `role: 'tool'` message only carries
`toolCallId` + `content`, and an assistant snapshot message may drop
`toolCalls` the client already observed via `TOOL_CALL_*` events. After a
snapshot the matching `tool-call` part could vanish, so a later
`addToolResult(toolCallId)` failed to locate the call and silently no-op'd.
`handleMessagesSnapshotEvent` now reconciles the normalized snapshot with the
pre-snapshot state: (a) detached `tool-result`-only assistant messages are
anchored into the preceding assistant message to match the streaming fan-out
shape, and (b) a `tool-call` part is carried forward from the prior state when
the snapshot references its `toolCallId` via a `tool-result` but omits the
corresponding `tool-call` part.
Fixes #859
* style: apply prettier formatting
* Merge branch 'main' into fix/issue-859-snapshot-tool-call-preservation
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Merge branch 'main' into fix/issue-859-snapshot-tool-call-preservation
* fix(ai): anchor snapshot tool-results by matching tool-call and warn on unrecoverable metadata
Review follow-ups on the MESSAGES_SNAPSHOT reconciliation:
- Anchor a detached tool-result into the message that contains its
matching tool-call part, falling back to the nearest anchorable
assistant only when the snapshot omits the call. AG-UI reasoning/
activity messages also normalize to role 'assistant', so the
nearest-assistant heuristic could separate a result from its call and
a later addToolResult would append a duplicate result next to the call.
- console.warn when a snapshot tool-result has no matching tool-call in
the snapshot, the pre-snapshot state, or no assistant to anchor into —
previously these degraded states were silent and left the #859 symptom
with no breadcrumb.
- Copy parts arrays instead of pushing into them: passthrough snapshot
messages share their parts array with the incoming chunk, and the
carried-forward tool-call part was shared by reference with the
previous messages array.
- Fix two comments ("Bump last-write-wins", "silently no-op") and dedupe
the handler comment against the method doc.
- Tests: multi-turn anchoring, reasoning-message interleaving,
consecutive snapshots, unrecoverable-metadata warn, and pin the
detached-message + warn behavior in the existing tool-message test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>