fix: prevent invalid hallucinated tool names from crashing Bedrock conversation replay - #17769
Conversation
Bugfix reviewOutcome: approved Reproduction replayStatus: no-longer-reproduces The exact original reproduction completed successfully and the original bug signal did not appear. Fixes issueStatus: fully-addresses The converter now sanitizes replayed assistant tool-call names at the point that previously forwarded them unchanged, covering both reported invalid-name patterns and fully invalid names. Side effectsRisk: low Valid tool names remain unchanged; only replayed names containing characters Bedrock rejects are rewritten before transmission. PerformanceRisk: low The added work is a linear regular-expression replacement on each replayed tool-call name with negligible allocation and no retained state. Backwards compatibilityRisk: low The conversion does not mutate application messages or stored data; sanitization applies only to the Bedrock request representation. ArchitectureRisk: low The provider-specific constraint is handled by a private helper in the Amazon Bedrock message converter, with no new dependencies, exports, cross-package source access, or boundary violations. Change scopeStatus: minimal The PR changes only the affected converter, focused regression coverage, and the required patch changeset. SecurityRisk: low The strict character allowlist and constant nonempty fallback reduce malformed outbound data without changing authentication, URL handling, parsing, or execution behavior. TestingStatus: appropriate Regression coverage includes both issue-reported names and an all-invalid fallback, while existing tests verify valid names; all 419 Amazon Bedrock tests passed in both Node and Edge configurations. VerificationReviewed every diff hunk and surrounding conversion and tool-repair paths. The full Amazon Bedrock Node and Edge suites, package type checking, focused formatting and lint checks, and diff validation all passed; the authoritative exact replay also succeeded without the original bug signal. Relevant Documentation
|
…rock conversation replay (#17777) ## Background Hallucinated tool names containing unsupported characters caused Amazon Bedrock to reject replayed conversation history with a 400 validation error. ## Root Cause The Bedrock message converter copied `part.toolName` directly into `toolUse.name`; focused and live reproductions confirmed `$READFILE` reached Bedrock unchanged and violated its `[a-zA-Z0-9_-]+` constraint. ## Summary Sanitized replayed tool-call names to Bedrock-compatible characters, added a valid fallback for fully invalid names, removed reproduction-only artifacts, and added a patch changeset. ## Testing Added converter regression coverage for `$READFILE`, names containing `<|channel|>`, and names containing no valid characters. ## End-to-end Validation - `pnpm -C packages/amazon-bedrock build` followed by `pnpm -C examples/ai-functions exec tsx -e '<live reproduction>'`: Claude Sonnet 4.5 completed the request with `$READFILE` in history without Bedrock's tool-name validation error. ## Related Issues Fixes #10202 Closes #17763 Backport of #17769 Co-authored-by: MaxAller <2164925+MaxAller@users.noreply.github.com>
…rock conversation replay (#17781) ## Background Hallucinated tool names containing unsupported characters caused Amazon Bedrock to reject replayed conversation history with a 400 validation error. ## Root Cause The Bedrock message converter copied `part.toolName` directly into `toolUse.name`; focused and live reproductions confirmed `$READFILE` reached Bedrock unchanged and violated its `[a-zA-Z0-9_-]+` constraint. ## Summary Sanitized replayed tool-call names to Bedrock-compatible characters, added a valid fallback for fully invalid names, removed reproduction-only artifacts, and added a patch changeset. ## Testing Added converter regression coverage for `$READFILE`, names containing `<|channel|>`, and names containing no valid characters. ## End-to-end Validation - `pnpm -C packages/amazon-bedrock build` followed by `pnpm -C examples/ai-functions exec tsx -e '<live reproduction>'`: Claude Sonnet 4.5 completed the request with `$READFILE` in history without Bedrock's tool-name validation error. ## Related Issues Fixes #10202 Closes #17763 Backport of #17769 Co-authored-by: MaxAller <2164925+MaxAller@users.noreply.github.com>
|
🚀 Published in:
|
Background
Hallucinated tool names containing unsupported characters caused Amazon Bedrock to reject replayed conversation history with a 400 validation error.
Root Cause
The Bedrock message converter copied
part.toolNamedirectly intotoolUse.name; focused and live reproductions confirmed$READFILEreached Bedrock unchanged and violated its[a-zA-Z0-9_-]+constraint.Summary
Sanitized replayed tool-call names to Bedrock-compatible characters, added a valid fallback for fully invalid names, removed reproduction-only artifacts, and added a patch changeset.
Testing
Added converter regression coverage for
$READFILE, names containing<|channel|>, and names containing no valid characters.End-to-end Validation
pnpm -C packages/amazon-bedrock buildfollowed bypnpm -C examples/ai-functions exec tsx -e '<live reproduction>': Claude Sonnet 4.5 completed the request with$READFILEin history without Bedrock's tool-name validation error.Related Issues
Fixes #10202
Closes #17763
Co-authored-by: MaxAller 2164925+MaxAller@users.noreply.github.com