Skip to content

feat(codex): persist managed reasoning effort overrides - #789

Merged
pancacake merged 6 commits into
HKUDS:devfrom
NoxsMedia:feat/codex-reasoning-effort-override
Aug 12, 2026
Merged

pancacake merged 6 commits into
HKUDS:devfrom
NoxsMedia:feat/codex-reasoning-effort-override

Conversation

@NoxsMedia

@NoxsMedia NoxsMedia commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • expose a reasoning-effort selector for OAuth-managed Codex models while keeping their provider, model ID, and context metadata read-only
  • derive selector values from each model's codex_supported_reasoning_levels, preserve valid overrides by stable model slug, and fall back to provider defaults when support changes
  • preserve managed Codex profiles and valid reasoning choices across refreshes, repeated logins, settings catalog saves, and stale Settings-page submissions
  • let ordinary users configure defaults only for models in their own owner-bound Codex OAuth profile through a narrow endpoint; partner accounts remain forbidden
  • bind each managed profile to a one-way hash of the OAuth account ID and retire stale profiles before an account switch waits on catalog I/O
  • validate the token generation, account binding, model slug, and effective reasoning override immediately before each Codex request; stale personal profiles are excluded from model options
  • keep per-conversation reasoning selection out of scope ([Feature Request]:Add a per-conversation reasoning-effort selector to the chat composer #641)

Authorization boundary

The ordinary-user endpoint accepts only a model slug and a reasoning-effort value. Server-owned profile metadata, model IDs, context windows, provider configuration, and OAuth credentials remain authoritative and cannot be changed through this path.

Managed profiles persist only a SHA-256 account binding, not the raw OAuth account ID. Status responses expose neither value. A profile with a missing or mismatched binding is hidden from reasoning controls, excluded from personal model options, and rejected at the outbound provider boundary.

On an OAuth account change, the old managed profile and active selection are retired synchronously with the credential commit, before catalog invalidation or fetch can yield. A failed account-B catalog fetch therefore cannot leave account A's model or reasoning override paired with account B's token. Same-account reauthentication preserves valid overrides.

The extension does not broaden credential ownership or cross-user access. It reuses the existing owner-scoped Codex service, continues to reject partner callers, and leaves the admin-only catalog APIs unchanged.

Verification

Rebased onto upstream/dev at 515a754b and verified at head 6e16cb4d:

  • env -u PYTHONPATH .venv/bin/pytest -q --tb=short
    • 3818 passed, 9 skipped
  • focused Codex/settings/multi-user/provider regression suite
    • 159 passed
  • .venv/bin/ruff check .
    • passed
  • .venv/bin/ruff format --check .
    • 1157 files already formatted
  • cd web && npm run test:node
    • 400 passed
  • cd web && npm run build
    • passed
  • cd web && npm run lint
    • 0 errors; 56 pre-existing warnings
  • cd web && npm run i18n:check
    • parity passed; audit completed
  • env -u PYTHONPATH .venv/bin/pip check
    • no broken requirements
  • git diff --check
    • passed
  • focused added-lines security scan
    • no hardcoded secrets, shell/eval/pickle/SQL hazards, raw token fields, or raw account-ID persistence detected

Independent review

  • An earlier fresh-context review found a stale-account lifecycle issue in the original PR history; b74164ed added account-bound managed profiles and stale Settings-write protection.
  • After rebasing to current dev, a separate read-only reviewer inspected frozen commit f151314a and returned BLOCK: account B's credentials could be committed while account A's managed profile remained active during a delayed or failed catalog fetch. The review also found that an incomplete catalog payload could detach the reconciled services.llm structure.
  • Both findings were reproduced with failing regression tests.
  • 6e16cb4d fixes the runtime window, adds outbound and personal-option binding checks, and attaches reconciled catalog containers before preserving provider-owned metadata.
  • The corrected head passed the full deterministic verification matrix above. No automatic corrective agent re-review was dispatched; maintainer review is requested on the updated head.

Design sync

design-sync: not applicable — this repository has no project design or architecture draft to update. The account-switch and outbound-validation invariants are recorded in the service implementation, regression tests, and this PR description.

Expose only owner-scoped managed Codex model metadata and validate updates against provider-supported reasoning levels. Add ordinary-user settings controls without granting model catalog or provider administration access.
Persist only a one-way account binding on managed Codex profiles. Hide and reject stale or legacy-unbound reasoning controls until a successful catalog refresh, and do not carry overrides across account switches.
@NoxsMedia

Copy link
Copy Markdown
Contributor Author

@pancacake Could you please review this updated PR?

It has been rebased onto the current dev (515a754b), and the head is now 6e16cb4d. The update also closes an OAuth account-switch race: the previous account's managed profile is retired before catalog I/O, and outbound Codex requests now validate the current token generation, account binding, model slug, and reasoning override.

Local verification on the updated head:

  • Python: 3818 passed, 9 skipped
  • focused Codex/settings/multi-user/provider suite: 159 passed
  • Web Node tests: 400 passed
  • Ruff/format, i18n, dependency check, and production build: passed
  • ESLint: 0 errors (56 pre-existing warnings)

The PR description contains the security-review findings and full verification details.

@pancacake
pancacake merged commit 104e844 into HKUDS:dev Aug 12, 2026
11 checks passed
pancacake added a commit that referenced this pull request Aug 12, 2026
An adversarial pass over #818 / #789 / #780 after merging.

**Codex sign-ins from before this week stopped working (#789).**
``validate_runtime_profile`` compared the profile's ``codex_account_binding``
for equality, but that key is written only by ``sync_codex_catalog`` — every
managed profile published by #690/#774 has none, so ``None != <hash>`` made
each of them look like another account's and locked its owner out of Codex
until they re-ran "Refresh models". Absent now reads as legacy; a binding
that is present and different is still an account switch and still refused.

**Overriding reasoning effort for one turn returned 409 (#789).** The same
function also required the request's effort to be byte-equal to the value
stored in the catalog. Effort is a per-request knob, not part of the identity
that ties a config to a token — the check now stops at model membership.
Its test asserted the old behaviour and has been rewritten around what the
function is actually for.

**The reasoning-effort endpoint left the runtime caches stale (#789).** It
writes the catalog the runtime resolves against, like every other catalog
write in this router, but skipped ``_invalidate_runtime_caches()``.

**OrcaRouter claimed Anthropic prompt caching (#818).** ``supports_prompt_caching``
makes ``_build_kwargs`` inject ``cache_control`` blocks into any ``anthropic/*``
or ``claude*`` request — an OpenRouter extension. No other gateway sets it and
nothing established the second one accepts it; a strict gateway would 400 every
Claude turn. Also fixed ``anthropic/claude-sonnet-4.6`` in the fallback list,
which the rest of the repo spells with dashes, so a user picking it from our
own menu would have got "model not found".

**OrcaRouter inserted itself into the curated menus (#818).** The featured
lists are hand-picked and rendered as a positional numbered menu, so adding an
entry shifted Ollama from [10] to [11]. The registry entry alone already makes
a provider reachable via "Show all" and the Settings dropdown; which providers
are featured is a maintainer decision. The README paragraph goes with it — no
other provider has per-provider prose there, and it would have been translated
into ten languages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants