fix(providers): don't fail construction on an empty OpenAI key with no env var - #50
Merged
Merged
Conversation
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>
Merged
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.
Regression
0.12.0 (#41) maps an empty
api_keytoNoneso the SDK readsOPENAI_API_KEY. With the variable unset,AsyncOpenAIraises at construction. ApodexHarnessBenchmarkSession._bootstrapalways 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 withoutOPENAI_API_KEYdied at turn 0 (Forge runr-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