-
Notifications
You must be signed in to change notification settings - Fork 15.7k
fix(agents): use alphanumeric-only tool call IDs for OpenRouter compatibility #1372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(agents): use alphanumeric-only tool call IDs for OpenRouter compatibility #1372
Conversation
|
Should we make this conditional? Does this even show up in session logs? Makes stuff hard to read. |
…/strict modes
- Add ToolCallIdMode type ('standard' | 'strict') for provider compatibility
- Standard mode (default): allows [a-zA-Z0-9_-] for readable session logs
- Strict mode: only [a-zA-Z0-9] for Mistral via OpenRouter
- Update sanitizeSessionMessagesImages to accept toolCallIdMode option
- Export ToolCallIdMode from pi-embedded-helpers barrel
Addresses review feedback on PR openclaw#1372 about readability.
|
Good call! I've refactored the sanitization to support two modes:
The This preserves readability by default while still fixing the Mistral/OpenRouter compatibility issue when strict mode is used. |
9cab74e to
867b60f
Compare
…/strict modes
- Add ToolCallIdMode type ('standard' | 'strict') for provider compatibility
- Standard mode (default): allows [a-zA-Z0-9_-] for readable session logs
- Strict mode: only [a-zA-Z0-9] for Mistral via OpenRouter
- Update sanitizeSessionMessagesImages to accept toolCallIdMode option
- Export ToolCallIdMode from pi-embedded-helpers barrel
Addresses review feedback on PR openclaw#1372 about readability.
…tibility Some providers like Mistral via OpenRouter require strictly alphanumeric tool call IDs. The error message indicates: "Tool call id was whatsapp_login_1768799841527_1 but must be a-z, A-Z, 0-9, with a length of 9." Changes: - Update sanitizeToolCallId to strip all non-alphanumeric characters (previously allowed underscores and hyphens) - Update makeUniqueToolId to use alphanumeric suffixes (x2, x3, etc.) instead of underscores - Update isValidCloudCodeAssistToolId to validate alphanumeric-only IDs - Update tests to reflect stricter sanitization Fixes openclaw#1359 Co-Authored-By: Claude <[email protected]>
…/strict modes
- Add ToolCallIdMode type ('standard' | 'strict') for provider compatibility
- Standard mode (default): allows [a-zA-Z0-9_-] for readable session logs
- Strict mode: only [a-zA-Z0-9] for Mistral via OpenRouter
- Update sanitizeSessionMessagesImages to accept toolCallIdMode option
- Export ToolCallIdMode from pi-embedded-helpers barrel
Addresses review feedback on PR openclaw#1372 about readability.
867b60f to
f5cec1d
Compare
Summary
Fixes #1359
Some providers like Mistral via OpenRouter require strictly alphanumeric tool call IDs. The error message indicates:
This PR updates the tool call ID sanitization to be more restrictive, using only alphanumeric characters (
[a-zA-Z0-9]) instead of the previous pattern that allowed underscores and hyphens ([a-zA-Z0-9_-]).Changes
sanitizeToolCallIdto strip all non-alphanumeric characters (previously replaced with underscores)makeUniqueToolIdto use alphanumeric suffixes (x2,x3, etc. andt<timestamp>) instead of underscoresisValidCloudCodeAssistToolIdto validate alphanumeric-only IDsTest plan
pnpm exec vitest run src/agents/tool-call-id.test.ts- all 4 tests passpnpm exec vitest run src/agents/pi-embedded-helpers.sanitizetoolcallid.test.ts- all 3 tests pass🤖 Generated with Claude Code