-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Description
When switching from Kimi K2 thinking model to Anthropic/Opus and then posting a prompt, an API error occurs.
Error Message
✕ [API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.4.content.0.tool_use.id: String should match pattern '^[a-zA-Z0-9_-]+$'"},"request_id":"req_011CWe1EvaWj2nvLhrxW8LtM"} (Status: 400)]
Steps to Reproduce
- Start a conversation using Kimi K2 thinking model
- Switch to Anthropic/Opus model
- Post a prompt
- Observe the API error
Expected Behavior
The prompt should be processed successfully after switching models.
Actual Behavior
API returns a 400 error indicating the tool_use.id field contains invalid characters (doesn't match pattern ^[a-zA-Z0-9_-]+$).
Root Cause Hypothesis
The tool_use.id generated by Kimi K2 thinking model likely contains characters that are not compatible with Anthropic's API validation (which only allows alphanumeric characters, underscores, and hyphens). When the conversation history is sent to Anthropic after the model switch, these invalid IDs cause the request to fail.
Suggested Fix
Sanitize or regenerate tool_use.id values when switching between providers to ensure compatibility with each provider's validation requirements.