Answer on a plain OpenAI key from the AG2 Bot - #661
Merged
davidmckayv merged 1 commit intoSep 28, 2026
Merged
Conversation
Compose writes OPENAI_BASE_URL empty when the model screen chose a plain OpenAI key, and the OpenAI SDK only defaults an absent URL, so the Bot's client was given "" as its address and every run failed. It now falls back to https://api.openai.com/v1 for an empty value, as its Anthropic branch already does for ANTHROPIC_BASE_URL.
asasemahmed
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 28, 2026 12:50
davidmckayv
approved these changes
Sep 28, 2026
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.
What this changes
Picked with a plain OpenAI key, the AG2 Bot fails every run. Compose passes the picked harness
OPENAI_BASE_URL: ${OPENAI_CONTAINER_BASE_URL:-${OPENAI_BASE_URL:-}}, and for a plain OpenAI keythat is empty.
OpenAIConfig(model=model)leavesbase_urlasNone, so the OpenAI SDK readsOPENAI_BASE_URLitself, and it falls back tohttps://api.openai.com/v1only when that is absent.Given
"", the request has no host.The Anthropic branch just above already handles exactly this: "Compose exports missing overrides as
""; the SDK only defaults an absent URL." The OpenAI branch now does the same, passing
base_url=(OPENAI_BASE_URL or "").strip() or "https://api.openai.com/v1". An OpenAI-compatibleendpoint is passed through as before.
#649 edits the provider and model lines of this file; this change is a separate hunk below them.
Where it runs
Boundary and audit
harness still refuses a request without the server's token.
Changelog
CHANGELOG.mdunderUnreleased.Proof
test_an_openai_key_uses_the_official_endpoint_when_compose_sets_a_blank_url, the twin ofthe Anthropic test above it: the real AG2 and OpenAI clients, with only the
httpx2transportreplaced and routed into this file's fake provider. It asserts the request went to
https://api.openai.com/v1/chat/completionswithBearer test-key, and a finished run.6 passed. Withsrcfrommain:1 failed, 5 passed, the new case, whose request goes to arelative
/chat/completions.ag21.1.0,openai3.19.2,anthropic1.8.0,httpx22.13.1.