Skip to content

Improve Cursor compatibility: model alias routing + robust multimodal input flattening - #163

Merged
suhaibbinyounis merged 2 commits into
mainfrom
copilot/support-cursor-compatibility
Sep 12, 2026
Merged

Improve Cursor compatibility: model alias routing + robust multimodal input flattening#163
suhaibbinyounis merged 2 commits into
mainfrom
copilot/support-cursor-compatibility

Conversation

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Cursor can intercept first-party model names (e.g. gpt-4o), bypassing custom gateway routing, and its multimodal payloads can break proxy flows that stringify structured content. This change adds Cursor-safe model aliases and normalizes image-bearing content paths to preserve stable request handling.

  • Model routing: Cursor-safe aliases

    • Expose copilot-* aliases in GET /v1/models (e.g. copilot-gpt-4o) mapped to discovered VS Code LM models.
    • Extend model lookup normalization to resolve prefixed variants (copilot-, cursor-, cursor/, openai/) and normalized family/id forms.
  • Multimodal/vision content handling

    • Add shared compatibility flattening for OpenAI/Cursor-style structured content blocks.
    • Handle image, image_url, and input_image parts explicitly as [image omitted] placeholders instead of unsafe JSON stringification.
    • Apply the same flattening path in both Responses API sync and streaming input parsing.
  • Compatibility utilities + docs

    • Introduce src/compatibility.ts for model-key normalization, alias generation, and content flattening.
    • Update Cursor docs to recommend selecting copilot-* models from /v1/models to avoid model-name interception.
// Cursor/OpenAI-prefixed names now normalize to the same lookup key
normalizeModelLookupKey('cursor/gpt-4o-20241022') // -> "gpt-4o"
normalizeModelLookupKey('copilot-gpt-4o')         // -> "gpt-4o"

// Structured image blocks are safely flattened
flattenOpenAICompatibleMessageContent([
  { type: 'text', text: 'Analyze this' },
  { type: 'image_url', image_url: { url: 'data:image/png;base64,...' } }
])
// -> "Analyze this\n[image omitted]"

Copilot AI linked an issue Aug 17, 2026 that may be closed by this pull request
Co-authored-by: suhaibbinyounis <29532412+suhaibbinyounis@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate support for Cursor compatibility Improve Cursor compatibility: model alias routing + robust multimodal input flattening Aug 17, 2026
Copilot AI requested a review from suhaibbinyounis August 17, 2026 05:27
@suhaibbinyounis
suhaibbinyounis merged commit 23c96b9 into main Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not work in cursor

2 participants