Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 22, 2026

Problem

AWS Bedrock has a 64-character limit on toolUseId fields, but the Bedrock Converse format converter doesn't truncate these IDs. This causes validation errors when using LiteLLM as a proxy to Bedrock, especially when switching modes with long conversation histories.

Error example:

Value at 'messages.2.member.content.1.member.toolUse.toolUseId' failed to satisfy constraint: 
Member must have length less than or equal to 64

The issue manifests when:

  • Using LiteLLM to route to AWS Bedrock
  • Switching between modes (e.g., Ask → Orchestrator) with existing tool calls in history
  • Tool call IDs exceed 64 characters

Solution

Applied the same ID sanitization approach used in OpenAI providers to the Bedrock Converse format converter:

  1. Import sanitizeOpenAiCallId from src/utils/tool-id.ts
  2. Apply sanitization to all toolUseId fields in:
    • tool_use blocks
    • tool_result blocks

This ensures IDs are truncated to 64 characters with hash suffixes to maintain uniqueness.

Changes

  • Updated src/api/transform/bedrock-converse-format.ts
  • Added 7 comprehensive tests in src/api/transform/__tests__/bedrock-converse-format.spec.ts
  • All tests pass (17/17)

Related

Fixes EXT-556
Related to issue #10766 which addresses MCP tool name length, but this is a separate issue about tool call ID length.


Important

Truncates toolUseId to 64 characters in convertToBedrockConverseMessages() to comply with AWS Bedrock limits, adding tests for verification.

  • Behavior:
    • Truncates toolUseId to 64 characters in convertToBedrockConverseMessages() in bedrock-converse-format.ts using sanitizeOpenAiCallId.
    • Handles tool_use and tool_result blocks, ensuring IDs are unique with hash suffixes.
  • Tests:
    • Adds 7 tests in bedrock-converse-format.spec.ts to verify ID truncation and uniqueness.
    • Tests cover cases for long IDs, short IDs, consistent truncation, and matching tool_use and tool_result IDs.
  • Misc:
    • Imports sanitizeOpenAiCallId from tool-id.ts for ID sanitization.

This description was created by Ellipsis for 544cb90. You can customize this summary. It will automatically update as commits are pushed.

- Import sanitizeOpenAiCallId from tool-id utility
- Apply ID sanitization to all toolUseId fields in tool_use and tool_result blocks
- Add 7 comprehensive tests for long ID handling
- Fixes validation error when using LiteLLM to route to Bedrock with long tool IDs
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 22, 2026 20:48
@daniel-lxs daniel-lxs self-assigned this Jan 22, 2026
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jan 22, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 22, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

This PR correctly applies the existing sanitizeOpenAiCallId utility to all toolUseId fields in the Bedrock Converse format converter, ensuring IDs are truncated to 64 characters with hash suffixes for uniqueness. The implementation is consistent across all 6 locations where toolUseId is set, and the tests comprehensively cover the key behaviors.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 23, 2026
@mrubens mrubens merged commit f9a3a17 into main Jan 24, 2026
21 checks passed
@mrubens mrubens deleted the feature/ext-556-fix-aws-bedrock-tooluseid-exceeding-64-character-limit branch January 24, 2026 05:49
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 24, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants