fix(aws-strands): carry ToolMessage.error onto the TypeScript adapter's tool results - #2365
Open
TheSeydiCharyyev wants to merge 1 commit into
Conversation
…'s tool results The TypeScript adapter never read ToolMessage.error. ag-ui-protocol#2306 listed four conversion sites and ag-ui-protocol#2317 fixed all of them, but aws-strands/typescript was not on that list, so a client-reported frontend tool failure still reached the model as a success. Three sites: _buildStrandsHistory and convertMessagesForStrandsSeed both hardcoded the Bedrock toolResult status to success, and buildSnapshotMessages rebuilt the client's own tool message without its error and encryptedValue fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2362. Completes #2306 for the adapter it did not list.
The gap
#2306 named four AG-UI → framework tool conversions and #2317 fixed all four, but
integrations/aws-strands/typescriptwas not on that list. The TypeScript adapter never readToolMessage.errorat all — everyerrorinagent.tswas an exception message or ahook_errorevent — so on this adapter a client-reported frontend tool failure still reached the model as a success.Three sites, two of them the twins of code already merged on the Python side:
_buildStrandsHistorystatus: "success" as constagent.py, fixed in #2317buildSnapshotMessageserror/encryptedValue_build_snapshot_messages, fixed in #2317convertMessagesForStrandsSeedstatus: "success" as constThe change
Same rule as #2306: derive the framework flag from the presence of
error, no sentinel._buildStrandsHistoryandconvertMessagesForStrandsSeed—statusis"error"when the AG-UI message carrieserror,"success"otherwise.buildSnapshotMessages—errorandencryptedValueare copied onto the echo. They are set only when the client set them, matching howtoolCallsis handled a few lines above, so a snapshot for a message without them keeps exactly the shape it has today.No type change was needed:
ToolMessageSchema.erroris alreadyz.string().optional()in@ag-ui/core.Tests
vitest runonintegrations/aws-strands/typescript: 246 passed — 241 before this branch, plus 5.tsc --noEmitis clean.history-replay.test.ts— an errored tool message reaches Strands asstatus: "error"; a successful one stays"success". Both go throughrun()rather than calling the helper directly.seed-messages.test.ts— two results in one turn, one failed and one not, get independent statuses.messages-snapshot.test.ts— the echo keepserrorandencryptedValue; a message without them is echoed unchanged, with no new keys.Checked that they fail for the right reason: with the three edits reverted, exactly those 3 tests fail and the other 31 in those files stay green.
Notes
src/agent.tsdoes not pass Prettier on this branch, but it already does not onmain— the reported lines (1815, 1848, 2340) are untouched by this PR. I left the file alone rather than mixing a reformat into the diff; the lines added here are Prettier-clean.