-
Notifications
You must be signed in to change notification settings - Fork 2k
Codex API Support: Feature Parity & UI Overhaul #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a80fc10
feat: complete Codex API feature parity with UI updates
bubblu2264326 87a3807
Codex Support
bubblu2264326 0c3f07e
feat: add JSDoc documentation to improve docstring coverage
paoloanzn c3e5419
feat: add OpenAI Codex API support with new models
paoloanzn 457de17
fix: improve OpenAI Codex authentication detection and UI updating
paoloanzn 973aa99
fix: set GPT-5.3 Codex as default model for Codex subscribers
paoloanzn 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ node_modules/ | |
| dist/ | ||
| cli | ||
| cli-dev | ||
| openclaw/ | ||
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,47 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Common commands | ||
|
|
||
| ```bash | ||
| # Install dependencies | ||
| bun install | ||
|
|
||
| # Standard build (./cli) | ||
| bun run build | ||
|
|
||
| # Dev build (./cli-dev) | ||
| bun run build:dev | ||
|
|
||
| # Dev build with all experimental features (./cli-dev) | ||
| bun run build:dev:full | ||
|
|
||
| # Compiled build (./dist/cli) | ||
| bun run compile | ||
|
|
||
| # Run from source without compiling | ||
| bun run dev | ||
| ``` | ||
|
|
||
| Run the built binary with `./cli` or `./cli-dev`. Set `ANTHROPIC_API_KEY` in the environment or use OAuth via `./cli /login`. | ||
|
|
||
| ## High-level architecture | ||
|
|
||
| - **Entry point/UI loop**: src/entrypoints/cli.tsx bootstraps the CLI, with the main interactive UI in src/screens/REPL.tsx (Ink/React). | ||
| - **Command/tool registries**: src/commands.ts registers slash commands; src/tools.ts registers tool implementations. Implementations live in src/commands/ and src/tools/. | ||
| - **LLM query pipeline**: src/QueryEngine.ts coordinates message flow, tool use, and model invocation. | ||
| - **Core subsystems**: | ||
| - src/services/: API clients, OAuth/MCP integration, analytics stubs | ||
| - src/state/: app state store | ||
| - src/hooks/: React hooks used by UI/flows | ||
| - src/components/: terminal UI components (Ink) | ||
| - src/skills/: skill system | ||
| - src/plugins/: plugin system | ||
| - src/bridge/: IDE bridge | ||
| - src/voice/: voice input | ||
| - src/tasks/: background task management | ||
|
|
||
| ## Build system | ||
|
|
||
| - scripts/build.ts is the build script and feature-flag bundler. Feature flags are set via build arguments (e.g., `--feature=ULTRAPLAN`) or presets like `--feature-set=dev-full` (see README for details). |
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,24 @@ | ||
| # Codex API Support: Feature Parity & UI Overhaul | ||
|
|
||
| ## Summary | ||
| This pull request introduces full feature parity and explicit UI support for the OpenAI Codex backend (`chatgpt.com/backend-api/codex/responses`). The codebase is now entirely backend-agnostic and smoothly transitions between Anthropic Claude and OpenAI Codex schemas based on current authentication, without losing features like reasoning animations, token billing, or multi-modal visual inputs. | ||
|
|
||
| ## Key Changes | ||
|
|
||
| ### 1. Codex API Gateway Adapter (`codex-fetch-adapter.ts`) | ||
| - **Native Vision Translation**: Anthropic `base64` image schemas now map precisely to the Codex expected `input_image` payloads. | ||
| - **Strict Payload Mapping**: Refactored the internal mapping logic to translate `msg.content` items precisely into `input_text`, sidestepping OpenAI's strict `v1/responses` validation rules (`Invalid value: 'text'`). | ||
| - **Tool Logic Fixes**: Properly routed `tool_result` items into top-level `function_call_output` objects to guarantee that local CLI tool executions (File Reads, Bash loops) cleanly feed back into Codex logic without throwing "No tool output found" errors. | ||
| - **Cache Stripping**: Cleanly stripped Anthropic-only `cache_control` annotations from tool bindings and prompts prior to transmission so the Codex API doesn't reject malformed JSON. | ||
|
|
||
| ### 2. Deep UI & Routing Integration | ||
| - **Model Cleanups (`model.ts`)**: Updated `getPublicModelDisplayName` and `getClaudeAiUserDefaultModelDescription` to recognize Codex GPT strings. Models like `gpt-5.1-codex-max` now beautifully map to `Codex 5.1 Max` in the CLI visual outputs instead of passing the raw proxy IDs. | ||
| - **Default Reroutes**: Made `getDefaultMainLoopModelSetting` aware of `isCodexSubscriber()`, automatically defaulting to `gpt-5.2-codex` instead of `sonnet46`. | ||
| - **Billing Visuals (`logoV2Utils.ts`)**: Refactored `formatModelAndBilling` logic to render `Codex API Billing` proudly inside the terminal header when authenticated. | ||
|
|
||
| ### 3. Reasoning & Metrics Support | ||
| - **Thinking Animations**: `codex-fetch-adapter` now intentionally intercepts the proprietary `response.reasoning.delta` SSE frames emitted by `codex-max` models. It wraps them into Anthropic `<thinking>` events, ensuring the standard CLI "Thinking..." spinner continues to function flawlessly for OpenAI reasoning. | ||
| - **Token Accuracy**: Bound logic to track `response.completed` completion events, fetching `usage.input_tokens` and `output_tokens`. These are injected natively into the final `message_stop` token handler, meaning Codex queries correctly trigger the terminal's Token/Price tracker summary logic. | ||
|
|
||
| ### 4. Git Housekeeping | ||
| - Configured `.gitignore` to securely and durably exclude the `openclaw/` gateway directory from staging commits. |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose Codex sessions through
authStatus().This branch persists a successful Codex login, but
authStatus()below still computesloggedInandauthMethodonly from Anthropic token/API-key sources. A Codex-only user will immediately get “Not logged in” and exit code1after a successful login.🤖 Prompt for AI Agents