Skip to content

Start the Microsoft Agent Framework Bot on an Anthropic key - #613

Merged
davidmckayv merged 2 commits into
CopilotKit:mainfrom
kevin9327:microsoft-agent-framework-anthropic-key
Sep 19, 2026
Merged

davidmckayv merged 2 commits into
CopilotKit:mainfrom
kevin9327:microsoft-agent-framework-anthropic-key

Conversation

@kevin9327

@kevin9327 kevin9327 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What this changes

Picked with an Anthropic key, the Microsoft Agent Framework Bot exits on startup.

The harness built OpenAIChatClient(BOT_MODEL) whatever the setup screen chose, and never read BOT_PROVIDER. The desktop catalogue gives every harness it installs Credential::AnyProvider, and this row's own summary is "Microsoft's, model-agnostic by design", so it can be paired with an Anthropic key. The desktop then writes BOT_PROVIDER=anthropic and BOT_MODEL=claude-sonnet-4-5, and leaves OPENAI_API_KEY empty. The OpenAI client refuses to be built without a key, and it is built at module level, so the import failed and the container never served /health:

openai.OpenAIError: Missing credentials. Please pass an `api_key`, ... or set the `OPENAI_API_KEY` ...

Agent Framework has its own Anthropic client. AnthropicClient is published as agent-framework-anthropic and re-exported from agent_framework.anthropic, the same way agent_framework.openai re-exports the OpenAI one. It reads ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL. The harness now builds that client when the provider is anthropic, and OpenAIChatClient as before otherwise, so the OpenAI key and OpenAI-compatible endpoint choices are unchanged.

One thing to weigh: agent-framework-anthropic has only ever been published as a pre-release. Its newest is 1.0.0b260918, and PyPI lists no final version. pip installs it from a plain requirement because nothing else satisfies it, which is what the Linux run below did. agent-framework-openai and agent-framework-ag-ui are final releases. Google is left out: the setup screen offers no Google key, and Compose passes the harness no GOOGLE_API_KEY.

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. Each harness process picks the same client from the same environment.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No. The CI step added here runs beside the harness suites already in python-harness.

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: no new refusal or failure.
  • Nothing new is trusted from the client.

Changelog

  • A line in CHANGELOG.md under Unreleased.

Proof

  • New agent-microsoft/tests/test_main.py follows agent-llamaindex/tests/test_main.py. It starts a local fake provider, imports the harness under the environment the desktop writes for each of the three choices, and posts an AG-UI run to /. It asserts HTTP 200, RUN_FINISHED, no RUN_ERROR, the provider's answer in the stream, and that the provider got the chosen model on the chosen route. The fake serves /v1/responses because OpenAIChatClient is Agent Framework's Responses API client. It also serves /v1/messages.
  • Linux (ubuntu-latest, Python 3.12, a throwaway workflow on my fork running the same commands as the new CI step). This branch: 3 passed. With agent-microsoft/src from main (2d09a08): 1 failed, 2 passed. [an Anthropic key] fails at import with the OpenAIError above.
  • Windows, Python 3.12: the same results.
  • Versions pip resolved: agent-framework-core 1.19.0, agent-framework-openai 1.14.4, agent-framework-anthropic 1.0.0b260918, agent-framework-ag-ui 1.4.0, anthropic 0.116.0.
  • Not run: a real Anthropic key, and the published image.

This adds a step at the end of python-harness and an entry at the top of Unreleased, which #609 to #612 also touch. Whichever lands later needs a rebase, and I'll do it.

Default endpoint regression

The default Compose environment sets ANTHROPIC_BASE_URL to an empty string. Microsoft Agent Framework's Anthropic client passed that through instead of selecting the official endpoint. The harness now explicitly uses https://api.anthropic.com for a blank override and preserves a nonblank custom URL.

The additional authenticated AG-UI regression uses the real framework and Anthropic SDK, replacing only HTTP transport. It checks the official URL, API-key header, chosen model, answer, and successful run completion. All four tests pass locally, including the original provider cases. This is SDK integration coverage; no live Anthropic account or published image was exercised.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

kevin9327 and others added 2 commits September 18, 2026 18:27
The Microsoft Agent Framework Bot built `OpenAIChatClient(BOT_MODEL)` whatever the setup screen
chose and never read `BOT_PROVIDER`. The catalogue offers every harness it installs with any model
the screen offers, so this one can be picked with an Anthropic key: the desktop then writes
`BOT_PROVIDER=anthropic`, `BOT_MODEL=claude-sonnet-4-5` and an empty `OPENAI_API_KEY`. The OpenAI
client refused to be built without a key, so the module failed at import with
`OpenAIError: Missing credentials` and the container never served a run.

Agent Framework reaches Anthropic through its own `AnthropicClient`, published as
`agent-framework-anthropic` and re-exported from `agent_framework.anthropic`, which reads
`ANTHROPIC_API_KEY` and `ANTHROPIC_BASE_URL`. The harness now builds that client when the provider
is `anthropic` and `OpenAIChatClient` otherwise, so an OpenAI key and an OpenAI-compatible endpoint
behave as they did.

The test follows the LlamaIndex Bot's, with the Responses API faked because that is the route
`OpenAIChatClient` takes. Before this change the Anthropic key choice fails at import and the other
two pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidmckayv
davidmckayv force-pushed the microsoft-agent-framework-anthropic-key branch from b39b621 to fa7175a Compare September 19, 2026 01:27
@davidmckayv
davidmckayv merged commit 0ca8982 into CopilotKit:main Sep 19, 2026
18 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