Skip to content

Commit 0dc1611

Browse files
authored
improvement(providers): align attachment dispatch to vendor SDK types (#4619)
* improvement(providers): align attachment dispatch to vendor SDK types 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). * fix(providers): restore getProviderAttachmentMaxBytes export and xAI 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 * fix(providers): tighten ResponsesInputItem content type to SDK ResponseInputContent 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.
1 parent cb9c2d5 commit 0dc1611

5 files changed

Lines changed: 153 additions & 87 deletions

File tree

apps/sim/providers/attachments.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('provider attachments', () => {
6666
{
6767
type: 'input_image',
6868
image_url: 'data:image/png;base64,iVBORw0KGgo=',
69+
detail: 'auto',
6970
},
7071
{
7172
type: 'input_file',

0 commit comments

Comments
 (0)