-
Notifications
You must be signed in to change notification settings - Fork 2
Claude/fix ai api error s x ee0 #212
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
Conversation
The tool name sanitization (replacing colons with underscores) was only applied when using Google Gemini. However, Azure via OpenRouter also requires tool names to match the pattern ^[a-zA-Z0-9_.-]+$ (no colons). This caused intermittent errors like "Invalid 'tools[24].name'" when MCP tools with names like "mcp:servername:toolname" were sent to Azure. Now sanitization happens for all providers since underscores are universally supported and parseMCPToolName already handles both formats. Fixed in both: - /api/ai/chat (page chat) - /api/ai/global/[id]/messages (global assistant)
The tool name sanitization (replacing colons with underscores) was only applied when using Google Gemini. However, Azure via OpenRouter and other providers also require tool names to match ^[a-zA-Z0-9_.-]+$. This caused errors like "Invalid 'tools[24].name'" when MCP tools with names like "mcp:servername:toolname" were sent to these providers. Changes: - Add sanitizeToolName() and sanitizeToolNamesForProvider() utilities to mcp-tool-converter.ts with full JSDoc documentation - Refactor both chat routes to use the centralized utility - Add comprehensive tests for sanitization and round-trip parsing The colon format is preserved internally (mcp:server:tool) to support nested namespaces in tool names. Sanitization to underscore format (mcp__server__tool) happens at the API boundary before sending to providers. parseMCPToolName() handles both formats for execution.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughThis PR extracts and centralizes tool name sanitization logic into reusable utility functions ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (5)apps/web/src/app/**/route.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx,json}📄 CodeRabbit inference engine (AGENTS.md)
Files:
apps/web/src/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📚 Learning: 2025-12-16T19:03:59.870ZApplied to files:
📚 Learning: 2025-12-14T14:54:45.713ZApplied to files:
🧬 Code graph analysis (3)apps/web/src/app/api/ai/global/[id]/messages/route.ts (1)
apps/web/src/app/api/ai/chat/route.ts (1)
apps/web/src/lib/ai/core/__tests__/mcp-tool-name-validation.test.ts (1)
🔇 Additional comments (10)
✏️ Tip: You can disable this entire section by setting 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. Comment |
Summary by CodeRabbit
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.