Skip to content

fix(provider-openai-codex): improve credential handling and function … - #460

Merged
ytallo merged 1 commit into
mainfrom
fix/openai-codex-auth-fallback
Jul 9, 2026
Merged

fix(provider-openai-codex): improve credential handling and function …#460
ytallo merged 1 commit into
mainfrom
fix/openai-codex-auth-fallback

Conversation

@ytallo

@ytallo ytallo commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

…availability checks

  • Updated README to clarify fallback behavior when the auth-credentials vault is not running.
  • Enhanced identity prompts to support batch function calls for improved efficiency.
  • Refactored authentication functions to check for availability before attempting token operations, preventing unnecessary errors.
  • Added tests for function list parsing to ensure robustness against malformed entries.

Summary by CodeRabbit

  • New Features

    • Improved credential handling to better support environments where the remote auth vault isn’t available.
    • Added safer fallback behavior so local credentials can be used when needed.
  • Bug Fixes

    • Prevented repeated import attempts when the vault service is not running.
    • Made token refresh behavior more resilient by only refreshing when the capability is available.
  • Documentation

    • Updated troubleshooting guidance for auth and credential fallback scenarios.

…availability checks

- Updated README to clarify fallback behavior when the auth-credentials vault is not running.
- Enhanced identity prompts to support batch function calls for improved efficiency.
- Refactored authentication functions to check for availability before attempting token operations, preventing unnecessary errors.
- Added tests for function list parsing to ensure robustness against malformed entries.
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 9, 2026 2:15pm
workers-tech-spec Ready Ready Preview, Comment Jul 9, 2026 2:15pm

Request Review

@ytallo
ytallo merged commit d283140 into main Jul 9, 2026
5 of 7 checks passed
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 41 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 809fd4e8-a631-4197-a3cc-500d12d5214d

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7e783 and 8d6ea82.

📒 Files selected for processing (5)
  • provider-openai-codex/README.md
  • provider-openai-codex/prompts/identity.txt
  • provider-openai-codex/src/auth.rs
  • provider-openai-codex/src/router_client.rs
  • provider-openai-codex/src/stream_fn.rs

📝 Walkthrough

Walkthrough

Router client gains function-availability detection so vault-dependent calls degrade gracefully when target functions aren't registered. Auth import and token refresh flows in auth.rs and stream_fn.rs are updated to use these availability-aware wrappers. README troubleshooting text and identity.txt prompt instructions are also revised.

Changes

Vault availability-aware auth flow

Layer / File(s) Summary
Function-availability helpers and wrappers
provider-openai-codex/src/router_client.rs
Adds internal helpers to check whether engine functions are registered and exposes auth_get_token_available, get_token_if_available, set_token_if_available, refresh_if_available, with unit tests for the parser.
Import guard using availability checks
provider-openai-codex/src/auth.rs
import_codex_home_if_absent returns early when no token is available and writes credentials via set_token_if_available, handling Ok(true)/Ok(false)/Err outcomes.
Conditional refresh in credential fetch
provider-openai-codex/src/stream_fn.rs
fetch_fresh_credential uses availability-aware get/refresh calls, only re-fetching when refresh succeeds, otherwise returning the existing credential.
README troubleshooting update
provider-openai-codex/README.md
Troubleshooting row updated to describe local fallback behavior when the auth-credentials vault is not running.

Identity Prompt Guidance Updates

Layer / File(s) Summary
Batched contract-fetching guidance
provider-openai-codex/prompts/identity.txt
Clarifies missing field causes, adds a batched engine::functions::info example, and requires single-batch contract fetches before installs/renames/moves.
Sub-agent policy and failure handling
provider-openai-codex/prompts/identity.txt
Documents fail-closed sub-agent baseline requiring explicit function allow-listing, and adds FAILED-line/checklist requirements for denied functions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant StreamFn as fetch_fresh_credential
  participant RouterClient
  participant EngineFunctions
  participant Vault

  StreamFn->>RouterClient: get_token_if_available(provider)
  RouterClient->>EngineFunctions: LIST_FUNCTIONS
  EngineFunctions-->>RouterClient: function list
  RouterClient->>Vault: auth::get_token (if registered)
  Vault-->>RouterClient: credential
  RouterClient-->>StreamFn: Ok(Some(credential))

  alt credential near expiry
    StreamFn->>RouterClient: refresh_if_available(provider)
    RouterClient->>EngineFunctions: check refresh function registered
    alt refresh available
      RouterClient->>Vault: trigger OAuth refresh
      Vault-->>RouterClient: Ok(true)
      StreamFn->>RouterClient: get_token_if_available(provider)
      RouterClient-->>StreamFn: Ok(Some(refreshed credential))
    else refresh unavailable
      RouterClient-->>StreamFn: Ok(false)
      StreamFn-->>StreamFn: return existing near-expiry credential
    end
  end
Loading

Poem

A rabbit checks before it hops,
"Is the function there?" before it stops.
No more crashes, no more fright,
Fallback keeps the tokens right. 🥕
Batch your contracts, hop as one—
Vault or not, the work gets done! 🐇

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openai-codex-auth-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

andersonleal added a commit that referenced this pull request Jul 9, 2026
…lippy)

Pre-existing clippy::collapsible_if failure from #460, unrelated to
this PR's change but blocking CI on this branch since it touches
provider-openai-codex/Cargo.lock. No behavior change.
andersonleal added a commit that referenced this pull request Jul 9, 2026
…ult on thinking-capable models (#462)

* (MOT-3929) fix(provider-anthropic): surface adaptive thinking by default on thinking-capable models

With no explicit thinking_level, build_thinking_config always returned
config: None, so thinking-capable models (Sonnet 4.6+, Opus 4.7+,
Fable/Mythos 5) never got adaptive reasoning unless the caller asked
for a level. provider-xai surfaces reasoning by default with no
explicit level; this brings provider-anthropic to parity.

Gated on supports_thinking == Some(true) specifically, so an unknown
or explicitly non-thinking model never gets the implicit default and
can't 400.

Cargo.lock churn across the other providers/approval-gate is from the
harness v1.1.12 bump (iii-sdk/iii-helpers version resolution).

* fix(provider-openai-codex): collapse nested near_expiry/refresh if (clippy)

Pre-existing clippy::collapsible_if failure from #460, unrelated to
this PR's change but blocking CI on this branch since it touches
provider-openai-codex/Cargo.lock. No behavior change.

* ci: pass GITHUB_TOKEN to the iii install script to avoid rate limits

install.iii.dev's install.sh calls the GitHub API to resolve the
release; unauthenticated it's capped at 60/hr and intermittently
fails "interface boot smoke" jobs across workers (hit twice on this
PR alone). The script's own error message points at $GITHUB_TOKEN,
so export the job's token to lift the cap to the authenticated rate.
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.

1 participant