Uh oh!
There was an error while loading. Please reload this page.
improvement(providers): align attachment dispatch to vendor SDK types - #4619
Conversation
Post-merge audit of #4610 surfaced three follow-ups: 1. xAI Grok vision was blocked. Grok runs through the OpenAI-compatible chat-completions endpoint, so removing xAI from UNSUPPORTED_FILE_PROVIDERS and routing it through the image-only branch restores image attachments on vision models. 2. Azure OpenAI chat-completions deployments blocked any file attachment. Added a per-message image_url parts path; documents still require the Responses API endpoint and throw a clear, actionable error. 3. Wire shapes were loosely typed (Record<string, unknown> arrays). Replaced with `satisfies` clauses against each vendor SDK union at every push site: OpenAI Responses/Chat, Anthropic ContentBlockParam, Gemini Part, Bedrock ContentBlock members. AnthropicImageMediaType now derives from Base64ImageSource['media_type'] so it tracks SDK updates. Also collapsed the validation cascade into an exhaustive switch with `never` enforcement, and dropped the redundant per-provider formatMessagesForProvider call from xai/index.ts (providers/index.ts already runs the dispatcher centrally).
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Refactors provider MIME-type support validation into an exhaustive switch and updates provider capability messaging, notably restoring xAI Grok vision as image-only and tightening unsupported-provider behavior. Fixes Azure OpenAI chat-completions vision by converting user image attachments into Reviewed by Cursor Bugbot for commit af6f058. Configure here. |
Greptile SummaryThis PR aligns provider attachment dispatch to vendor SDK types by replacing loose
Confidence Score: 5/5Safe to merge — changes are well-scoped type-safety improvements with no regressions in attachment dispatch logic. The refactor is mechanical and verifiable: loose Record shapes become SDK-typed satisfies clauses that would have failed at compile time if shapes were wrong, the exhaustive switch is TypeScript-enforced, and the Azure OpenAI chat-completions vision path is a straightforward per-message translation that mirrors the existing pattern in other providers. All previously flagged issues are confirmed fixed in this HEAD. Tests pass at 182/182. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[ProviderRequest with files] --> B{Provider type?}
B -->|openai / anthropic\ngoogle / bedrock| C[SDK-native path\nformatMessagesForProvider\nearly-returns unchanged]
C --> D[Provider builds own\ncontent blocks\nbuildOpenAIMessageContent\nbuildAnthropicMessageContent etc.]
B -->|xai / mistral / groq\nfireworks / ollama / vllm| E[formatMessagesForProvider\nbuildOpenAICompatibleChatContent]
E --> F[image_url chat\ncompletion parts\nimages only]
B -->|openrouter| G[formatMessagesForProvider\nbuildOpenRouterMessageContent]
G --> H[image_url + file\nparts mixed]
B -->|deepseek / cerebras| I[throw: unsupported]
B -->|azure-openai\nchat-completions path| J{message.role === user\n&& has files?}
J -->|No| K[push message as-is]
J -->|Yes| L[prepareProviderAttachments\nazure-openai]
L --> M{non-image\nattachment?}
M -->|Yes| N[throw: use\nResponses API]
M -->|No| O[image_url parts\nfor chat-completions]
B -->|azure-openai\nResponses API path| P[executeResponsesProviderRequest\nbuildOpenAIMessageContent]
Reviews (2): Last reviewed commit: "fix(providers): restore getProviderAttac..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…message dispatch - Restore `getProviderAttachmentMaxBytes` — still consumed by agent-handler.ts for per-provider attachment size limits in file hydration - Restore `formatMessagesForProvider(allMessages, 'xai')` — providers/index.ts does NOT dispatch centrally on this branch; each OpenAI-compat provider formats its own messages. Without it, xAI Grok vision drops image attachments
waleedlatif1
commented
May 15, 2026
waleedlatif1
commented
May 15, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit af6f058. Configure here.
…seInputContent Build fix: buildOpenAIMessageContent returns ResponseInputContent[] which isn't assignable to Record<string, unknown>[] (ResponseInputText lacks an index signature). Align the type to the SDK shape.
Summary
Record<string, unknown>wire shapes withsatisfiesclauses against each vendor SDK union (OpenAI Responses/Chat, Anthropic ContentBlockParam, Gemini Part, Bedrock ContentBlock)AnthropicImageMediaTypenow derives fromBase64ImageSource['media_type']so it tracks SDK updatesneverenforcementformatMessagesForProvidercall from xai/index.ts (providers/index.ts already dispatches centrally)Type of Change
Testing
Tested manually. Vitest suites for
providers/attachments,providers/openai/utils,providers/google/utils,executor/handlers/agent/agent-handler,executor/handlers/agent/memory, andblocks/blocksall pass (182/182). Biome clean.Checklist