Skip to content

Answer on a plain OpenAI key from the Microsoft Agent Framework Bot - #660

Merged
davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/microsoft-bot-blank-openai-url
Sep 28, 2026
Merged

davidmckayv merged 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/microsoft-bot-blank-openai-url

Conversation

@asasemahmed

Copy link
Copy Markdown
Contributor

What this changes

Picked with a plain OpenAI key, the Microsoft Agent Framework Bot fails every run:

openai.APIConnectionError: Connection error.

Compose passes the picked harness OPENAI_BASE_URL: ${OPENAI_CONTAINER_BASE_URL:-${OPENAI_BASE_URL:-}},
and for a plain OpenAI key that is empty. OpenAIChatClient(model) leaves the base URL to the
OpenAI SDK, which reads OPENAI_BASE_URL and falls back to https://api.openai.com/v1 only when it
is absent. Given "", the request has no host.

The Anthropic branch just above already handles exactly this, since #613: "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-compatible
endpoint 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

  • New state that outlives a request? None. The client is chosen once at import.
  • What happens on the second replica? The same, from the same environment.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway: nothing on the server changes, and the
    harness still refuses a request without the server's token.
  • New refusals and new failures each write a row: none added.
  • Nothing new is trusted from the client.

Changelog

  • An entry in CHANGELOG.md under Unreleased.

Proof

  • New test_an_openai_key_uses_the_official_endpoint_when_compose_sets_a_blank_url, the twin of
    the Anthropic test above it: the real framework and OpenAI clients, with only the transport
    replaced. It asserts the request went to https://api.openai.com/v1/responses with
    Bearer test-key, and a finished run. The OpenAI SDK sends through httpx2, not httpx, so this
    test patches httpx2's transport. Patching httpx's would let the request out.
  • Python 3.12, the CI step's commands, run in a container with no network: this branch
    6 passed. With src from main: 1 failed, 5 passed, the new case. With the transport left
    alone, main fails with the APIConnectionError above.
  • Versions pip resolved: agent-framework-core 1.19.0, agent-framework-openai 1.14.4,
    agent-framework-ag-ui 1.4.0, openai 3.19.2, httpx2 2.13.1.
  • Not run: a real OpenAI key, and the published image.

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 with
"Connection error.". It now falls back to https://api.openai.com/v1 for
an empty value, as its Anthropic branch already does for
ANTHROPIC_BASE_URL.
@davidmckayv
davidmckayv merged commit 8e2ecc5 into CopilotKit:main Sep 28, 2026
17 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.

2 participants