Skip to content

Conversation

@themavik
Copy link

Summary

Fixes #2215

When using multiple model backends (e.g. vLLM + OpenAI) within the same agent, tool_call IDs generated by one backend can exceed the maximum length accepted by another. OpenAI rejects IDs longer than 40 characters with:

Invalid 'messages[2].tool_calls[0].id': string too long

Root Cause

vLLM and other backends may generate tool_call IDs longer than 40 characters (e.g. UUIDs). When these are stored in chat history and later replayed against OpenAI, the request is rejected.

Changes

Added _normalize_tool_call_ids() to BaseModelBackend that truncates oversized tool_call IDs in preprocess_messages(). This ensures:

  • Assistant message tool_calls[].id fields are truncated to 40 chars
  • Tool response tool_call_id fields are truncated consistently
  • Truncation is deterministic (same input always gives same prefix)
  • Only activates when IDs exceed the limit — no-op for conforming IDs

The normalization runs in preprocess_messages() which all model backends use, so cross-provider compatibility is handled transparently.

Test Plan

  • Verify OpenAI model accepts messages with previously-vLLM-generated tool_call IDs
  • Verify truncation is consistent between assistant and tool response messages
  • Verify no regression when all IDs are already under 40 characters

Made with Cursor

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Invalid 'messages[2].tool_calls[0].id': string too long

1 participant