Skip to content

fix(providers): don't fail construction on an empty OpenAI key with no env var - #50

Merged
zhanghanduo merged 1 commit into
mainfrom
fix/openai-empty-key-no-env
Sep 27, 2026
Merged

zhanghanduo merged 1 commit into
mainfrom
fix/openai-empty-key-no-env

Conversation

@zhanghanduo

Copy link
Copy Markdown
Collaborator

Regression

0.12.0 (#41) maps an empty api_key to None so the SDK reads OPENAI_API_KEY. With the variable unset, AsyncOpenAI raises at construction. ApodexHarness BenchmarkSession._bootstrap always builds a default-provider OpenAI client (unused by Anthropic/Bedrock workflows) with an empty key, so after bumping to 0.12.1 every Harbor/Forge episode without OPENAI_API_KEY died at turn 0 (Forge run r-20260927-211711-baf8). Newer openai SDKs reject "" too, so restoring "" is not enough.

Fix

resolve_openai_api_key(): explicit key → OPENAI_API_KEY → placeholder "EMPTY". Construction never fails; a client that is actually called fails with the endpoint's 401; keyless OpenAI-compatible servers accept it. #41's intent (env beats an empty key) kept.

Tests: empty/None key without env constructs with placeholder; existing env/explicit tests unchanged. Full suite 1610 passed, ruff + pyright clean. Fragment added.

🤖 Generated with Claude Code

0.12.0 (#41) passed `None` for an empty api_key so the SDK would read
OPENAI_API_KEY. With the variable unset the SDK raises at construction,
which breaks hosts that build a default OpenAI client they never call
(ApodexHarness BenchmarkSession beside an Anthropic workflow LLM failed
every episode at turn 0). Newer SDKs reject "" as well, so fall back to a
placeholder key; a client that is really called gets the endpoint's 401.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zhanghanduo
zhanghanduo merged commit 469b5f9 into main Sep 27, 2026
5 checks passed
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