Skip to content

Commit c5afe9a

Browse files
authored
feat: add support for Codex max models
2 parents 4fdc64d + b58f746 commit c5afe9a

File tree

14 files changed

+467
-76
lines changed

14 files changed

+467
-76
lines changed

AGENTS.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides coding guidance for AI agents (including Claude Code, Codex,
44

55
## Overview
66

7-
This is an **opencode plugin** that enables OAuth authentication with OpenAI's ChatGPT Plus/Pro Codex backend. It allows users to access `gpt-5.1-codex`, `gpt-5.1-codex-mini`, `gpt-5-codex`, `gpt-5-codex-mini`, `gpt-5.1`, and `gpt-5` models through their ChatGPT subscription instead of using OpenAI Platform API credits.
7+
This is an **opencode plugin** that enables OAuth authentication with OpenAI's ChatGPT Plus/Pro Codex backend. It allows users to access `gpt-5.1-codex`, `gpt-5.1-codex-max`, `gpt-5.1-codex-mini`, `gpt-5-codex`, `gpt-5-codex-mini`, `gpt-5.1`, and `gpt-5` models through their ChatGPT subscription instead of using OpenAI Platform API credits.
88

99
**Key architecture principle**: 7-step fetch flow that intercepts opencode's OpenAI SDK requests, transforms them for the ChatGPT backend API, and handles OAuth token management.
1010

@@ -41,7 +41,7 @@ The main entry point orchestrates a **7-step fetch flow**:
4141
1. **Token Management**: Check token expiration, refresh if needed
4242
2. **URL Rewriting**: Transform OpenAI Platform API URLs → ChatGPT backend API (`https://chatgpt.com/backend-api/codex/responses`)
4343
3. **Request Transformation**:
44-
- Normalize model names (all variants → `gpt-5.1`, `gpt-5.1-codex`, `gpt-5.1-codex-mini`, `gpt-5`, `gpt-5-codex`, or `codex-mini-latest`)
44+
- Normalize model names (all variants → `gpt-5.1`, `gpt-5.1-codex`, `gpt-5.1-codex-max`, `gpt-5.1-codex-mini`, `gpt-5`, `gpt-5-codex`, or `codex-mini-latest`)
4545
- Inject Codex system instructions from latest GitHub release
4646
- Apply reasoning configuration (effort, summary, verbosity)
4747
- Add CODEX_MODE bridge prompt (default) or tool remap message (legacy)
@@ -98,13 +98,14 @@ The main entry point orchestrates a **7-step fetch flow**:
9898
- Plugin defaults: `reasoningEffort: "medium"`, `reasoningSummary: "auto"`, `textVerbosity: "medium"`
9999

100100
**4. Model Normalization**:
101+
- All `gpt-5.1-codex-max*` variants → `gpt-5.1-codex-max`
101102
- All `gpt-5.1-codex*` variants → `gpt-5.1-codex`
102103
- All `gpt-5.1-codex-mini*` variants → `gpt-5.1-codex-mini`
103104
- All `gpt-5-codex` variants → `gpt-5-codex`
104105
- All `gpt-5-codex-mini*` or `codex-mini-latest` variants → `codex-mini-latest`
105106
- All `gpt-5.1` variants → `gpt-5.1`
106107
- All `gpt-5` variants → `gpt-5`
107-
- `minimal` effort auto-normalized to `low` for gpt-5-codex (API limitation) and clamped to `medium` (or `high` when requested) for Codex Mini
108+
- `minimal` effort auto-normalized to `low` for Codex families and clamped to `medium` (or `high` when requested) for Codex Mini
108109

109110
**5. Codex Instructions Caching**:
110111
- Fetches from latest release tag (not main branch)
@@ -150,7 +151,7 @@ This plugin **intentionally differs from opencode defaults** because it accesses
150151

151152
| Setting | opencode Default | This Plugin Default | Reason |
152153
|---------|-----------------|---------------------|--------|
153-
| `reasoningEffort` | "high" (gpt-5) | "medium" | Matches Codex CLI default |
154+
| `reasoningEffort` | "high" (gpt-5) | "medium" (Codex Max defaults to "high") | Matches Codex CLI default and Codex Max capabilities |
154155
| `textVerbosity` | "low" (gpt-5) | "medium" | Matches Codex CLI default |
155156
| `reasoningSummary` | "detailed" | "auto" | Matches Codex CLI default |
156157
| gpt-5-codex config | (excluded) | Full support | opencode excludes gpt-5-codex from auto-config |

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project are documented here. Dates use the ISO format (YYYY-MM-DD).
44

5+
## [3.3.0] - 2025-11-19
6+
### Added
7+
- GPT 5.1 Codex Max support: normalization, per-model defaults, and new presets (`gpt-5.1-codex-max`, `gpt-5.1-codex-max-xhigh`) with extended reasoning options (including `none`/`xhigh`) while keeping the 272k context / 128k output limits.
8+
- Typing and config support for new reasoning options (`none`/`xhigh`, summary `off`/`on`) plus updated test matrix entries.
9+
10+
### Changed
11+
- Codex Mini clamping now downgrades unsupported `xhigh` to `high` and guards against `none`/`minimal` inputs.
12+
- Documentation, config guides, and validation scripts now reflect 13 verified GPT 5.1 variants (3 codex, 5 codex-max, 2 codex-mini, 3 general), including Codex Max. See README for details on pre-configured variants.
13+
514
## [3.2.0] - 2025-11-14
615
### Added
716
- GPT 5.1 model family support: normalization for `gpt-5.1`, `gpt-5.1-codex`, and `gpt-5.1-codex-mini` plus new GPT 5.1-only presets in the canonical `config/full-opencode.json`.

README.md

Lines changed: 106 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Follow me on [X @nummanthinks](https://x.com/nummanthinks) for future updates an
3333
## Features
3434

3535
-**ChatGPT Plus/Pro OAuth authentication** - Use your existing subscription
36-
-**8 pre-configured GPT 5.1 variants** - GPT 5.1, GPT 5.1 Codex, and GPT 5.1 Codex Mini presets for common reasoning levels
36+
-**13 pre-configured GPT 5.1 variants** - GPT 5.1, GPT 5.1 Codex, GPT 5.1 Codex Max, and GPT 5.1 Codex Mini presets for common reasoning levels (including `gpt-5.1-codex-max` and `gpt-5.1-codex-max-low/medium/high/xhigh`)
3737
- ⚠️ **GPT 5.1 only** - Older GPT 5.0 models are deprecated and may not work reliably
3838
-**Zero external dependencies** - Lightweight with only @openauthjs/openauth
3939
-**Auto-refreshing tokens** - Handles token expiration automatically
@@ -130,6 +130,86 @@ Follow me on [X @nummanthinks](https://x.com/nummanthinks) for future updates an
130130
"store": false
131131
}
132132
},
133+
"gpt-5.1-codex-max": {
134+
"name": "GPT 5.1 Codex Max (OAuth)",
135+
"limit": {
136+
"context": 272000,
137+
"output": 128000
138+
},
139+
"options": {
140+
"reasoningEffort": "high",
141+
"reasoningSummary": "detailed",
142+
"textVerbosity": "medium",
143+
"include": [
144+
"reasoning.encrypted_content"
145+
],
146+
"store": false
147+
}
148+
},
149+
"gpt-5.1-codex-max-low": {
150+
"name": "GPT 5.1 Codex Max Low (OAuth)",
151+
"limit": {
152+
"context": 272000,
153+
"output": 128000
154+
},
155+
"options": {
156+
"reasoningEffort": "low",
157+
"reasoningSummary": "detailed",
158+
"textVerbosity": "medium",
159+
"include": [
160+
"reasoning.encrypted_content"
161+
],
162+
"store": false
163+
}
164+
},
165+
"gpt-5.1-codex-max-medium": {
166+
"name": "GPT 5.1 Codex Max Medium (OAuth)",
167+
"limit": {
168+
"context": 272000,
169+
"output": 128000
170+
},
171+
"options": {
172+
"reasoningEffort": "medium",
173+
"reasoningSummary": "detailed",
174+
"textVerbosity": "medium",
175+
"include": [
176+
"reasoning.encrypted_content"
177+
],
178+
"store": false
179+
}
180+
},
181+
"gpt-5.1-codex-max-high": {
182+
"name": "GPT 5.1 Codex Max High (OAuth)",
183+
"limit": {
184+
"context": 272000,
185+
"output": 128000
186+
},
187+
"options": {
188+
"reasoningEffort": "high",
189+
"reasoningSummary": "detailed",
190+
"textVerbosity": "medium",
191+
"include": [
192+
"reasoning.encrypted_content"
193+
],
194+
"store": false
195+
}
196+
},
197+
"gpt-5.1-codex-max-xhigh": {
198+
"name": "GPT 5.1 Codex Max Extra High (OAuth)",
199+
"limit": {
200+
"context": 272000,
201+
"output": 128000
202+
},
203+
"options": {
204+
"reasoningEffort": "xhigh",
205+
"reasoningSummary": "detailed",
206+
"textVerbosity": "medium",
207+
"include": [
208+
"reasoning.encrypted_content"
209+
],
210+
"store": false
211+
}
212+
},
133213
"gpt-5.1-codex-mini-medium": {
134214
"name": "GPT 5.1 Codex Mini Medium (OAuth)",
135215
"limit": {
@@ -219,8 +299,9 @@ Follow me on [X @nummanthinks](https://x.com/nummanthinks) for future updates an
219299
**Global config**: `~/.config/opencode/opencode.json`
220300
**Project config**: `<project>/.opencode.json`
221301

222-
This gives you 8 GPT 5.1 variants with different reasoning levels:
302+
This gives you 13 GPT 5.1 variants with different reasoning levels:
223303
- **gpt-5.1-codex** (low/medium/high) - Latest Codex model presets
304+
- **gpt-5.1-codex-max** (low/medium/high/xhigh) - Codex Max presets (`gpt-5.1-codex-max-low/medium/high/xhigh`)
224305
- **gpt-5.1-codex-mini** (medium/high) - Latest Codex mini tier presets
225306
- **gpt-5.1** (low/medium/high) - Latest general-purpose reasoning presets
226307

@@ -293,6 +374,8 @@ If using the full configuration, select from the model picker in opencode, or sp
293374
# Use different reasoning levels for gpt-5.1-codex
294375
opencode run "simple task" --model=openai/gpt-5.1-codex-low
295376
opencode run "complex task" --model=openai/gpt-5.1-codex-high
377+
opencode run "large refactor" --model=openai/gpt-5.1-codex-max-high
378+
opencode run "research-grade analysis" --model=openai/gpt-5.1-codex-max-xhigh
296379

297380
# Use different reasoning levels for gpt-5.1
298381
opencode run "quick question" --model=openai/gpt-5.1-low
@@ -312,6 +395,11 @@ When using [`config/full-opencode.json`](./config/full-opencode.json), you get t
312395
| `gpt-5.1-codex-low` | GPT 5.1 Codex Low (OAuth) | Low | Fast code generation |
313396
| `gpt-5.1-codex-medium` | GPT 5.1 Codex Medium (OAuth) | Medium | Balanced code tasks |
314397
| `gpt-5.1-codex-high` | GPT 5.1 Codex High (OAuth) | High | Complex code & tools |
398+
| `gpt-5.1-codex-max` | GPT 5.1 Codex Max (OAuth) | High | Default Codex Max preset with large-context support |
399+
| `gpt-5.1-codex-max-low` | GPT 5.1 Codex Max Low (OAuth) | Low | Fast exploratory large-context work |
400+
| `gpt-5.1-codex-max-medium` | GPT 5.1 Codex Max Medium (OAuth) | Medium | Balanced large-context builds |
401+
| `gpt-5.1-codex-max-high` | GPT 5.1 Codex Max High (OAuth) | High | Long-horizon builds, large refactors |
402+
| `gpt-5.1-codex-max-xhigh` | GPT 5.1 Codex Max Extra High (OAuth) | xHigh | Deep multi-hour agent loops, research/debug marathons |
315403
| `gpt-5.1-codex-mini-medium` | GPT 5.1 Codex Mini Medium (OAuth) | Medium | Latest Codex mini tier |
316404
| `gpt-5.1-codex-mini-high` | GPT 5.1 Codex Mini High (OAuth) | High | Codex Mini with maximum reasoning |
317405
| `gpt-5.1-low` | GPT 5.1 Low (OAuth) | Low | Faster responses with light reasoning |
@@ -322,6 +410,8 @@ When using [`config/full-opencode.json`](./config/full-opencode.json), you get t
322410
**Display**: TUI shows the friendly name (e.g., "GPT 5.1 Codex Low (OAuth)")
323411

324412
> **Note**: All `gpt-5.1-codex-mini*` presets map directly to the `gpt-5.1-codex-mini` slug with standard Codex limits (272k context / 128k output).
413+
>
414+
> **Note**: Codex Max presets use the `gpt-5.1-codex-max` slug with 272k context and 128k output. Use `gpt-5.1-codex-max-low/medium/high/xhigh` to pick reasoning level (only `-xhigh` uses `xhigh` reasoning).
325415
326416
> **⚠️ Important**: GPT 5 models can be temperamental - some variants may work better than others, some may give errors, and behavior may vary. Stick to the presets above configured in `full-opencode.json` for best results.
327417
@@ -357,14 +447,16 @@ When no configuration is specified, the plugin uses these defaults for all GPT-5
357447
- **`reasoningSummary: "auto"`** - Automatically adapts summary verbosity
358448
- **`textVerbosity: "medium"`** - Balanced output length
359449

450+
Codex Max defaults to `reasoningEffort: "high"` when selected, while other families default to `medium`.
451+
360452
These defaults match the official Codex CLI behavior and can be customized (see Configuration below).
361453

362454
## Configuration
363455

364456
### ⚠️ REQUIRED: Use Pre-Configured File
365457

366458
**YOU MUST use [`config/full-opencode.json`](./config/full-opencode.json)** - this is the only officially supported configuration:
367-
- 8 pre-configured GPT 5.1 model variants with verified settings
459+
- 13 pre-configured GPT 5.1 model variants with verified settings
368460
- Optimal configuration for each reasoning level
369461
- All variants visible in the opencode model selector
370462
- Required metadata for OpenCode features to work properly
@@ -379,16 +471,19 @@ If you want to customize settings yourself, you can configure options at provide
379471

380472
#### Available Settings
381473

382-
⚠️ **Important**: The two base models have different supported values.
474+
⚠️ **Important**: Families have different supported values.
383475

384-
| Setting | GPT-5 Values | GPT-5-Codex Values | Plugin Default |
385-
|---------|-------------|-------------------|----------------|
386-
| `reasoningEffort` | `minimal`, `low`, `medium`, `high` | `low`, `medium`, `high` | `medium` |
387-
| `reasoningSummary` | `auto`, `detailed` | `auto`, `detailed` | `auto` |
388-
| `textVerbosity` | `low`, `medium`, `high` | `medium` only | `medium` |
389-
| `include` | Array of strings | Array of strings | `["reasoning.encrypted_content"]` |
476+
| Setting | GPT-5 / GPT-5.1 Values | GPT-5.1-Codex Values | GPT-5.1-Codex-Max Values | Plugin Default |
477+
|---------|-----------------------|----------------------|---------------------------|----------------|
478+
| `reasoningEffort` | `minimal`, `low`, `medium`, `high` | `low`, `medium`, `high` | `none`, `low`, `medium`, `high`, `xhigh` | `medium` (global), `high` default for Codex Max |
479+
| `reasoningSummary` | `auto`, `concise`, `detailed` | `auto`, `concise`, `detailed` | `auto`, `concise`, `detailed`, `off`, `on` | `auto` |
480+
| `textVerbosity` | `low`, `medium`, `high` | `medium` or `high` | `medium` or `high` | `medium` |
481+
| `include` | Array of strings | Array of strings | Array of strings | `["reasoning.encrypted_content"]` |
390482

391-
> **Note**: `minimal` effort is auto-normalized to `low` for gpt-5-codex (not supported by the API).
483+
> **Notes**:
484+
> - `minimal` effort is auto-normalized to `low` for Codex models.
485+
> - Codex Mini clamps to `medium`/`high`; `xhigh` downgrades to `high`.
486+
> - Codex Max supports `none`/`xhigh` plus extended reasoning options while keeping the same 272k context / 128k output limits.
392487
393488
#### Global Configuration Example
394489

config/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ cp config/full-opencode.json ~/.config/opencode/opencode.json
1414

1515
**Why this is required:**
1616
- GPT 5 models can be temperamental and need proper configuration
17-
- Contains 8 verified GPT 5.1 model variants (Codex, Codex Mini, and general GPT 5.1)
17+
- Contains 12+ verified GPT 5.1 model variants (Codex, Codex Max, Codex Mini, and general GPT 5.1 including `gpt-5.1-codex-max-low/medium/high/xhigh`)
1818
- Includes all required metadata for OpenCode features
1919
- Guaranteed to work reliably
2020
- Global options for all models + per-model configuration overrides
2121

2222
**What's included:**
23-
- All supported GPT 5.1 variants: gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-mini
24-
- Proper reasoning effort settings for each variant
25-
- Context limits (272k context / 128k output)
23+
- All supported GPT 5.1 variants: gpt-5.1, gpt-5.1-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini
24+
- Proper reasoning effort settings for each variant (including new `xhigh` for Codex Max)
25+
- Context limits (272k context / 128k output for all Codex families, including Codex Max)
2626
- Required options: `store: false`, `include: ["reasoning.encrypted_content"]`
2727

2828
### ❌ Other Configurations (NOT SUPPORTED)

config/full-opencode.json

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,86 @@
6363
"store": false
6464
}
6565
},
66+
"gpt-5.1-codex-max": {
67+
"name": "GPT 5.1 Codex Max (OAuth)",
68+
"limit": {
69+
"context": 272000,
70+
"output": 128000
71+
},
72+
"options": {
73+
"reasoningEffort": "high",
74+
"reasoningSummary": "detailed",
75+
"textVerbosity": "medium",
76+
"include": [
77+
"reasoning.encrypted_content"
78+
],
79+
"store": false
80+
}
81+
},
82+
"gpt-5.1-codex-max-low": {
83+
"name": "GPT 5.1 Codex Max Low (OAuth)",
84+
"limit": {
85+
"context": 272000,
86+
"output": 128000
87+
},
88+
"options": {
89+
"reasoningEffort": "low",
90+
"reasoningSummary": "detailed",
91+
"textVerbosity": "medium",
92+
"include": [
93+
"reasoning.encrypted_content"
94+
],
95+
"store": false
96+
}
97+
},
98+
"gpt-5.1-codex-max-medium": {
99+
"name": "GPT 5.1 Codex Max Medium (OAuth)",
100+
"limit": {
101+
"context": 272000,
102+
"output": 128000
103+
},
104+
"options": {
105+
"reasoningEffort": "medium",
106+
"reasoningSummary": "detailed",
107+
"textVerbosity": "medium",
108+
"include": [
109+
"reasoning.encrypted_content"
110+
],
111+
"store": false
112+
}
113+
},
114+
"gpt-5.1-codex-max-high": {
115+
"name": "GPT 5.1 Codex Max High (OAuth)",
116+
"limit": {
117+
"context": 272000,
118+
"output": 128000
119+
},
120+
"options": {
121+
"reasoningEffort": "high",
122+
"reasoningSummary": "detailed",
123+
"textVerbosity": "medium",
124+
"include": [
125+
"reasoning.encrypted_content"
126+
],
127+
"store": false
128+
}
129+
},
130+
"gpt-5.1-codex-max-xhigh": {
131+
"name": "GPT 5.1 Codex Max Extra High (OAuth)",
132+
"limit": {
133+
"context": 272000,
134+
"output": 128000
135+
},
136+
"options": {
137+
"reasoningEffort": "xhigh",
138+
"reasoningSummary": "detailed",
139+
"textVerbosity": "medium",
140+
"include": [
141+
"reasoning.encrypted_content"
142+
],
143+
"store": false
144+
}
145+
},
66146
"gpt-5.1-codex-mini-medium": {
67147
"name": "GPT 5.1 Codex Mini Medium (OAuth)",
68148
"limit": {
@@ -146,4 +226,4 @@
146226
}
147227
}
148228
}
149-
}
229+
}

0 commit comments

Comments
 (0)