Repository navigation
docs(codex): document Codex through the gateway with a non-enforcing Core - #2687
Merged
Merged
Conversation
…Core oceanbase#2420 was closed as not planned: an unmodified Codex sends no max_output_tokens, so an enforcing Core withholds every request. The supported path is a non-enforcing Core, which the gateway accepts since oceanbase#2457. The "Leave prompt-time context to the gateway" section now covers: - the Core mode and the gateway restart a mode change needs; - the Codex provider for /gateway/v1 (wire_api = "responses"), the gateway key that Codex needs in PC_GATEWAY_KEY, and a per-session profile file; - the plugin settings, and why a thread that already carries the plugin's block keeps failing; - the gateway settings: the Responses upstream URL, the gateway key, the Core token, sediment, and the default Scope. Approving provider-default cache retention is optional under a non-enforcing Core. Checked with a real Codex 0.167.2, the gateway, and the Server from this branch, against a local fake Responses upstream. Part of oceanbase#2250.
16 of 17 tasks
hidb4ai
approved these changes
Nov 17, 2026
hidb4ai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 2e78c65. No blocking findings. The bilingual guide matches the Core/gateway contracts and makes the non-enforcing privacy and single-Scope limitations explicit. No database tables or interfaces are added. Independently verified the documented configuration behavior with Codex 0.167.2 and passed the 33 focused context-check tests. Broader privacy tests could not collect because the local pydantic-ai installation lacks ModelContextWindowExceededError; I did not rerun the full host/gateway/provider workflow. Documentation and website CI are green.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue or RFC does this PR close?
Part of #2250 (plan step 2: Codex through the gateway).
Rationale for this change
Step 2 waited for #2420: an enforcing Core withholds every request from an unmodified Codex, because Codex sends no
max_output_tokens. #2420 was closed as not planned. The supported path for an unmodified Codex is a non-enforcing Core, which the gateway accepts since #2457. The Codex guide's "Leave prompt-time context to the gateway" section, added by #2453, covered only the two plugin settings and the gateway's Scope. It did not say which Core mode works, how to point Codex at the gateway, or what happens to a thread that already carries the plugin's context.What changes are included in this PR?
The section in
docs/en/docs/integrations/codex.mdanddocs/zh/docs/integrations/codex.mdnow has four parts, with the same structure in both languages:Run Core in a non-enforcing mode. Use
disabled,shadow, oradvisory, with a target for the profile named byPC_GATEWAY_UPSTREAM_PROFILE. The guide explains why an enforcing Core fails every turn: it withholds the request, for example withoutput_limit_required, and the gateway returns HTTP 400. It says that none of these modes stops delivery for a privacy rule, and that the gateway must be restarted after a mode change because it discovers the mode at startup. It links to the context-protection and inference-protection pages instead of repeating them. Approvingprovider-defaultcache retention is optional: a non-enforcing Core does not withhold a request forprompt_cache_key.Point Codex at the gateway. A
config.tomlprovider for/gateway/v1withwire_api = "responses", which is the only value Codex 0.167 accepts for a custom provider, andenv_key = "PC_GATEWAY_KEY". The guide covers three more points:PC_GATEWAY_API_KEYon the gateway and export the same value asPC_GATEWAY_KEYwhere Codex starts. Codex 0.167.2 stops withMissing environment variablebefore any request whilePC_GATEWAY_KEYis unset, even for a loopback gateway that checks no key.~/.codex/powercontext-gateway.config.toml, used withcodex --profile powercontext-gateway. Codex 0.167.2 rejects a[profiles.<name>]table inconfig.tomlas legacy.Turn the plugin's prompt recall and capture off. The existing settings. New: start a new thread after changing them. Codex resends the thread's history, so a thread that already carries the plugin's block keeps failing after recall is turned off.
Configure the gateway. Use the combined deployment, with these settings:
PC_GATEWAY_UPSTREAM_URL_RESPONSESand its API key: without the URL, the Responses route returns 501;PC_GATEWAY_API_KEY, the key Codex sends;PC_GATEWAY_CORE_TOKENwhen Core enforces authentication;PC_GATEWAY_SEDIMENT=on;PC_GATEWAY_DEFAULT_SCOPE, with a pointer toscope_binding.pyfor printing the workspace's Scope.The part links to the 1 MiB request limit in Deploy the Server, and keeps the existing two differences from plugin recall.
The section's opening now says what happens once the plugin's recall adds context to a thread: Core rejects the check for that request and every later one in the thread with HTTP 422, and the gateway returns HTTP 503
gate_paused. The run reproduced this under a non-enforcing Core.#2641 edits other sections of the same two files; the hunks do not overlap.
Are there any user-facing changes?
Documentation only. No code, settings, or API changes.
How was this change tested?
Real Codex 0.167.2 (
codex exec --json, thencodex exec --json resume <thread>), in an isolatedHOMEandCODEX_HOME:powercontext setup codexfrom this branch.codex-hostE2E job does.PC_GATEWAY_SEDIMENT=on.Each setup sent two messages in one thread:
advisory,shadow, anddisabled, each with the documented settingsadvisory, the guide's example target (endpoint, model, protocol only; no cache approval)advisory, plugin defaults (recall and capture on)context-binding-required), gateway 503gate_pausedadvisory, documented settings, resuming the previous threadenforcing, documented settings,provider-defaultapprovedoutput_limit_required, gateway 400allowwithcoverage.complete=false.wire_api = "chat"at config load.PC_GATEWAY_KEYunset it exits withMissing environment variablebefore any request. A[profiles.<name>]table is rejected as legacy. The same keys in<name>.config.tomlwith--profile <name>select the gateway provider.Checks:
make check: passed,ty checkincluded.make docs-test, run locally: lint, the website tests, compilation, and static generation of all 1,408 pages passed. The last step ofnext buildthen stopped locally withSecurityFatalError, a Next.js security-advisory check for the pinned Next.js 16.4.1. CI'scheck-websitejob runs the same target and passed on master fd16583; this PR's own CI run shows the result there.Self-review and a separate review: every key, path, default, and behavior that the section states was checked against
upstream/masterfd16583, either in the code or in the run above. Before any change, the gateway and Core code paths were read for each failure mode the section describes.AI usage statement
Claude Code (Claude Opus 5.5) ran the real Codex host, gateway, and Server, and wrote the docs change and this description. A separate Claude Code subagent and the coordinating Claude Code session reviewed the diff.