Fix Cursor chat-completions compatibility#833
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0f9586077
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Follow-up pushed in
Validation after this follow-up: uv run pytest tests/unit/test_request_policy.py tests/unit/test_chat_request_mapping.py tests/unit/test_openai_requests.py
# 141 passed
uv run ruff check app/modules/proxy/request_policy.py tests/unit/test_request_policy.py
# All checks passed |
|
Addressed the empty
Validation: uv run pytest tests/unit/test_chat_request_mapping.py
# 52 passed
uv run ruff check app/core/openai/chat_requests.py tests/unit/test_chat_request_mapping.py
# All checks passed |
|
Follow-up: fixed the Cursor context-window failure path. Cursor's bundled client has a dedicated ERROR_CONVERSATION_TOO_LONG UI branch, but the OpenAI-compatible provider path was receiving an immediate Responses response.failed event inside a 200 OK chat stream. /v1/chat/completions now treats first-frame response.failed/error as a startup failure and returns the parsed OpenAI error JSON with the correct HTTP status, so context_length_exceeded surfaces as a 400 instead of an empty successful stream. Mid-stream failures after partial output still stay in-stream. Added an integration test for startup context_length_exceeded. |
|
Follow-up after live Cursor validation: Cursor still does not render the provider HTTP error in its chat UI. Added a targeted compatibility fallback for API keys named cursor: immediate context_length_exceeded startup failures are converted into a normal chat-completions assistant message, preserving visible feedback in Cursor. Other API keys and other errors still use the standard error response path. Added unit coverage for cursor vs non-cursor detection. |
|
Still working to get the compaction working. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
Compaction is working now. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0e57a434e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b449e7f094
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd8d905f46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9358529183
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d50632aef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d69bad48c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27baea6d62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48c89e6b1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Hermes owner-review blocker: This PR changes observable behavior/contracts but does not include an OpenSpec change folder. The repo merge gate requires Evidence:
Requested fix: add a normal OpenSpec change folder ( I also noticed one non-blocking follow-up worth considering while touching the policy surface: the Cursor context-limit synthetic-success path is enabled by any |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Fixes compatibility issues seen when Cursor sends OpenAI-compatible requests to
/v1/chat/completionswhile using its GPT-5.5 Extra model option. The failing requests were accepted by the chat-completions surface but rejected later by the ChatGPT/Codex upstream because of model/field mismatches.Changes:
input+ optionalinstructions) on the chat-completions endpoint instead of requiringmessagesin that path.input_text/output_text) when chat messages are being coerced.metadataanduserfrom upstream payload serialization, matching existing unsupported-field handling for fields liketemperatureandtop_p.gpt-5.5-extramodel slug to upstreamgpt-5.5, and apply high reasoning for that alias.gpt-5.5) to also pass access checks for the alias (gpt-5.5-extra).Validation
uv run pytest tests/unit/test_chat_request_mapping.py tests/unit/test_openai_requests.py tests/unit/test_request_policy.pyuv run ruff check app/core/openai/chat_requests.py app/core/openai/message_coercion.py app/core/openai/requests.py app/modules/proxy/request_policy.py tests/unit/test_chat_request_mapping.py tests/unit/test_openai_requests.py tests/unit/test_request_policy.pyNotes
This keeps compatibility normalization in the existing request mapping / serialization / request-policy layers rather than adding client-specific special cases in the proxy endpoint. The model alias is intentionally narrow because it corresponds to a Cursor UI model name that is not accepted by the upstream Codex backend as a literal model slug.