t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: GPT evals start without credentials when the provider requires OpenAI auth and no key is found

Open Lenoridev opened this issue 1 week ago • 0 comments

Area

Build, CI, or release tooling

Steps to reproduce

  1. Use a ~/.codex/config.toml whose eval provider requires OpenAI auth, with no ~/.codex/auth.json (or one from a ChatGPT login, which has tokens but no OPENAI_API_KEY):

    model_provider = "cliproxy"
    
    [model_providers.cliproxy]
    base_url = "https://<box>.<tailnet>.ts.net:8317/v1"
    requires_openai_auth = true
    
  2. From evals/, run pnpm mcp-tool-use --model gpt-6.1-sol --case NODEV-02 --samples 1 --out runs/check, or pnpm test-signal --out runs/check.

Expected behavior

The eval stops at startup with a setup message that says the provider requires OpenAI auth and no OPENAI_API_KEY was found, like the messages #38573 added for a missing config, base_url or env_key.

Actual behavior

The eval starts and sends every request without an Authorization header. An authenticated proxy rejects each one, so every sample is recorded as an error and left out of pass rates. The run finishes with nothing graded.

The cause is evals/shared/proxy.ts:42:

if not key and p.get('requires_openai_auth') and (home / 'auth.json').is_file(): key = json.loads((home / 'auth.json').read_text()).get('OPENAI_API_KEY')

When auth.json is missing, or has no OPENAI_API_KEY, key stays empty and nothing reports it. Before #38573, a missing auth.json crashed at startup with FileNotFoundError, so that case is a regression from #38573. The ChatGPT-login case already behaved this way before #38573.

I reproduced this by running the helper's Python from main (56b0777774) against the config above, with and without a ChatGPT-style auth.json. In both cases it returned the provider URL with no Authorization header. I did not run a live model call. This was raised in the review of #38573 (https://github.com/pingdotgg/t3code/pull/38573#discussion_r4613884188) and by CodeRabbit, and the PR listed it as out of scope.

Impact

Minor bug or occasional failure (maintainer and contributor eval tooling only; no product impact).

Version or commit

main @ 56b0777774

Environment

Any OS, Python 3.11+.

Workaround

Set the key in the provider table with experimental_bearer_token, or name an environment variable with env_key.

Possible fix

After the key is resolved, fail when auth is required and no Authorization header was found:

if p.get('requires_openai_auth') and not key and not any(k.lower() == 'authorization' for k in h):
  fail(f'[model_providers.{name}] in {path} sets requires_openai_auth, but {home / "auth.json"} has no OPENAI_API_KEY.')

A test could cover this together with #39371. Since proxyConfig() reads CODEX_HOME, a test can write configs to a temp dir and call it with no network.

Lenoridev avatar Nov 19 '26 21:11 Lenoridev