-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Added Codex provider support #8135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Buzzwavemed
wants to merge
10
commits into
RooCodeInc:main
from
Buzzwavemed:fix-codex-duplicate-completion
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
866c5b9
Prevent Codex duplicate completions
4149db7
Add Codex provider integration
2cd7bb9
Update src/api/providers/__tests__/codex.spec.ts
Buzzwavemed e218bdd
Update src/integrations/codex/run.ts
Buzzwavemed c1796b9
Update src/api/providers/codex.ts
Buzzwavemed f78588d
Update src/api/providers/codex.ts
Buzzwavemed 8e53bd8
Update src/integrations/codex/run.ts
Buzzwavemed 09edcf4
Fix Codex test by updating mock session creation
Buzzwavemed 46792be
Refactor create method and logDebug function
Buzzwavemed 032b86b
Refactor exit handling for Codex sessions
Buzzwavemed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| import type { ModelInfo, ReasoningEffortWithMinimal } from "../model.js" | ||
| import { openAiNativeModels } from "./openai.js" | ||
|
|
||
| export type CodexModelId = | ||
| | "gpt-5-codex" | ||
| | "gpt-5-codex-minimal" | ||
| | "gpt-5-codex-low" | ||
| | "gpt-5-codex-medium" | ||
| | "gpt-5-codex-high" | ||
| | "gpt-5" | ||
| | "gpt-5-minimal" | ||
| | "gpt-5-low" | ||
| | "gpt-5-medium" | ||
| | "gpt-5-high" | ||
| | "codex-mini-latest" | ||
|
|
||
| export type CodexCliModelInfo = { | ||
| id: string | ||
| label?: string | ||
| description?: string | ||
| model?: string | ||
| effort?: ReasoningEffortWithMinimal | ||
| } | ||
|
|
||
| export interface CodexCliPreset { | ||
| id: CodexModelId | ||
| label: string | ||
| description: string | ||
| cliModel: string | ||
| effort?: ReasoningEffortWithMinimal | ||
| } | ||
|
|
||
| export const codexDefaultModelId: CodexModelId = "gpt-5-codex" | ||
|
|
||
| const CLI_DEFAULT_MODEL = "gpt-5" | ||
|
|
||
| const codexBaseModelInfo: ModelInfo = { | ||
| ...openAiNativeModels["gpt-5-2025-08-07"], | ||
| supportsReasoningEffort: true, | ||
| } | ||
|
|
||
| export const codexCliPresets: CodexCliPreset[] = [ | ||
| { | ||
| id: "gpt-5-codex", | ||
| label: "gpt-5-codex (auto)", | ||
| description: "— uses your Codex CLI default reasoning effort", | ||
| cliModel: CLI_DEFAULT_MODEL, | ||
| }, | ||
| { | ||
| id: "gpt-5-codex-minimal", | ||
| label: "gpt-5-codex minimal", | ||
| description: "— fastest responses with limited reasoning; ideal for lightweight edits and quick fixes", | ||
| cliModel: CLI_DEFAULT_MODEL, | ||
| effort: "minimal", | ||
| }, | ||
| { | ||
| id: "gpt-5-codex-low", | ||
| label: "gpt-5-codex low", | ||
| description: "— prioritises speed while keeping some reasoning depth for straightforward coding tasks", | ||
| cliModel: CLI_DEFAULT_MODEL, | ||
| effort: "low", | ||
| }, | ||
| { | ||
| id: "gpt-5-codex-medium", | ||
| label: "gpt-5-codex medium", | ||
| description: "— balanced reasoning for everyday development work (Codex CLI default)", | ||
| cliModel: CLI_DEFAULT_MODEL, | ||
| effort: "medium", | ||
| }, | ||
| { | ||
| id: "gpt-5-codex-high", | ||
| label: "gpt-5-codex high", | ||
| description: "— maximum reasoning depth for complex or ambiguous engineering problems", | ||
| cliModel: CLI_DEFAULT_MODEL, | ||
| effort: "high", | ||
| }, | ||
| ] | ||
|
|
||
| const legacyRedirectEntries: ReadonlyArray<[string, CodexModelId]> = [ | ||
| ["gpt-5", "gpt-5-codex"], | ||
| ["gpt-5-minimal", "gpt-5-codex-minimal"], | ||
| ["gpt-5-low", "gpt-5-codex-low"], | ||
| ["gpt-5-medium", "gpt-5-codex-medium"], | ||
| ["gpt-5-high", "gpt-5-codex-high"], | ||
| ["gpt-5-codex", "gpt-5-codex"], | ||
| ["gpt-5-codex-minimal", "gpt-5-codex-minimal"], | ||
| ["gpt-5-codex-low", "gpt-5-codex-low"], | ||
| ["gpt-5-codex-medium", "gpt-5-codex-medium"], | ||
| ["gpt-5-codex-high", "gpt-5-codex-high"], | ||
| ["codex-mini-latest", "codex-mini-latest"], | ||
| ] | ||
|
|
||
| export const codexLegacyModelRedirects: Record<string, CodexModelId> = Object.fromEntries(legacyRedirectEntries) | ||
|
|
||
| const presetMap = new Map<CodexModelId, CodexCliPreset>() | ||
|
|
||
| for (const preset of codexCliPresets) { | ||
| presetMap.set(preset.id, preset) | ||
| } | ||
|
|
||
| for (const [legacyId, targetId] of legacyRedirectEntries) { | ||
| const target = presetMap.get(targetId as CodexModelId) | ||
| if (target && !presetMap.has(legacyId as CodexModelId)) { | ||
| presetMap.set(legacyId as CodexModelId, { | ||
| ...target, | ||
| id: legacyId as CodexModelId, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| const derivedModels: Record<string, ModelInfo> = {} | ||
|
|
||
| for (const preset of presetMap.values()) { | ||
| derivedModels[preset.id] = { | ||
| ...codexBaseModelInfo, | ||
| description: preset.description || codexBaseModelInfo.description, | ||
| } | ||
| } | ||
|
|
||
| if (openAiNativeModels["codex-mini-latest"]) { | ||
| derivedModels["codex-mini-latest"] = { | ||
| ...openAiNativeModels["codex-mini-latest"], | ||
| supportsReasoningEffort: true, | ||
| } | ||
| } | ||
|
|
||
| export const codexModels = derivedModels as Record<CodexModelId, ModelInfo> | ||
|
|
||
| export const fallbackCodexCliModels: CodexCliModelInfo[] = codexCliPresets.map((preset) => ({ | ||
| id: preset.id, | ||
| label: preset.label, | ||
| description: preset.description, | ||
| model: preset.cliModel, | ||
| effort: preset.effort, | ||
| })) | ||
|
|
||
| export const normalizeCodexModelId = (id?: string | null): CodexModelId => { | ||
| const trimmed = (id ?? "").trim() | ||
| if (!trimmed) { | ||
| return codexDefaultModelId | ||
| } | ||
| return (codexLegacyModelRedirects[trimmed] ?? trimmed) as CodexModelId | ||
| } | ||
|
|
||
| export const getCodexPreset = (id: string | undefined) => { | ||
| const normalized = normalizeCodexModelId(id) | ||
| return presetMap.get(normalized) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.