Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Aug 11, 2025

Summary

This PR adds support for the codex-mini-latest model in the OpenAI Native provider, which uses OpenAI's v1/responses endpoint.

Key Implementation Details:

  1. Reuses GPT-5 infrastructure: Since both GPT-5 and Codex Mini use the same v1/responses endpoint, we've refactored the code to share the same infrastructure, reducing code duplication and maintenance overhead.

  2. Unified responses API handling: Created a common isResponsesApiModel() method to identify models that use the v1/responses endpoint, making it easy to add more such models in the future.

  3. Token Estimation: Uses the established pattern of length / 4 for token estimation (approximately 4 characters per token), consistent with other parts of the codebase.

  4. Comprehensive Testing: Added 5 new test cases covering streaming, non-streaming, error handling, and edge cases.

Related GitHub Issue

Closes: #5386

Test Procedure

Automated Testing:

  • Added comprehensive unit tests covering streaming, non-streaming, error handling, and model info retrieval
  • All 46 tests pass successfully

Manual Testing Steps:

  1. Configure OpenAI Native provider with API key
  2. Select "codex-mini-latest" from model dropdown
  3. Test basic chat functionality
  4. Verify streaming responses work correctly
  5. Check token usage tracking in the UI

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (Add native OpenAI provider support for Codex Mini model #5386)
  • Scope: Changes are focused on the linked issue
  • Self-Review: Performed a thorough self-review of the code
  • Testing: New tests have been added to cover the changes
  • Documentation Impact: No documentation updates required
  • Contribution Guidelines: Read and agree to the Contributor Guidelines

Additional Notes

  • The v1/responses endpoint is used by both GPT-5 and Codex Mini models
  • Pricing is set to .5/M input tokens and /M output tokens
  • Context window is 200,000 tokens with max output of 16,384 tokens
  • This implementation enables efficient code reuse and maintainability

Important

Adds support for Codex Mini model in OpenAI Native provider, sharing infrastructure with GPT-5 models and introducing comprehensive tests.

  • Behavior:
    • Adds support for codex-mini-latest model in openai-native.ts, using the v1/responses endpoint.
    • Introduces isResponsesApiModel() to identify models using the v1/responses endpoint.
    • completePrompt() throws error for codex-mini-latest, directing to use createMessage().
  • Testing:
    • Adds tests for codex-mini-latest in openai-native.spec.ts, covering streaming, non-streaming, error handling, and multiple user messages.
  • Misc:
    • Refactors handleGpt5Message() to handleResponsesApiMessage() in openai-native.ts for shared use by GPT-5 and Codex Mini.

This description was created by Ellipsis for 7c3fd1f. You can customize this summary. It will automatically update as commits are pushed.

- Add codex-mini-latest model definition with proper pricing (.5/M input, /M output)
- Implement support using existing v1/responses endpoint infrastructure (same as GPT-5)
- Add comprehensive test coverage for streaming and non-streaming modes
- Handle Codex Mini specific request format (instructions + input)
- Reuse GPT-5's SSE parsing logic for efficient implementation

Closes #5386
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners August 11, 2025 13:22
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 11, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and found some issues that need attention. The implementation looks solid overall, with good test coverage and proper integration with the existing responses API infrastructure.

contextWindow: 200_000,
supportsImages: false,
supportsPromptCache: false,
inputPrice: 1.5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pricing values here (1.5 and 6) appear to be correct based on issue #5386, but the PR description mentions '.5/M' and '/M' which could be confusing. Could you clarify if these are the correct values? The issue mentions these are the actual numeric values without dollar signs.

inputPrice: 1.5,
outputPrice: 6,
cacheReadsPrice: 0,
description: "Codex Mini: Optimized coding model using v1/responses endpoint",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description could be more detailed about the model's specific capabilities and limitations. For example, mentioning that it's optimized for code generation tasks, the free tier availability, or any specific use cases it excels at.

delete global.fetch
})

describe("Codex Mini Model", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test coverage! However, it would be valuable to add integration tests that mock at a higher level (e.g., testing the full flow from API handler to response). This would catch issues with the integration between different components.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 11, 2025
- Add codex-mini-latest model definition with pricing (.5/M input, /M output)
- Reuse existing v1/responses endpoint infrastructure (same as GPT-5)
- Add isResponsesApiModel() method to identify models using responses endpoint
- Rename handleGpt5Message to handleResponsesApiMessage for clarity
- Add comprehensive test coverage for Codex Mini
- Fix error handling in GPT-5 stream handler to properly re-throw API errors
- Use generic 'Responses API' error messages since both models share the endpoint

The implementation keeps the GPT-5 path completely unchanged while allowing
Codex Mini to reuse the same infrastructure with minimal code changes.
@daniel-lxs daniel-lxs force-pushed the feat/codex-mini-support-clean branch from 3740319 to 737d70d Compare August 11, 2025 14:07
…ructure

- Removed handleCodexMiniWithResponsesApi method as Codex Mini should behave exactly like GPT-5
- Both models now use the same v1/responses endpoint format
- Updated tests to reflect unified behavior
- Addresses review feedback about including all messages in conversation context
…ort support

- Removed unreachable GPT-5 specific code in completePrompt method
- Updated getModel to apply reasoning effort to all responses API models (GPT-5 and Codex Mini)
- Both models now properly support reasoning effort and verbosity through the responses API
Updated description to reflect that Codex Mini is powered by codex-1, a version of o3 optimized for software engineering tasks with reinforcement learning training
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Aug 11, 2025
@mrubens mrubens merged commit 76e5a72 into main Aug 11, 2025
10 checks passed
@mrubens mrubens deleted the feat/codex-mini-support-clean branch August 11, 2025 15:16
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 11, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Aug 11, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Aug 11, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add native OpenAI provider support for Codex Mini model

4 participants