Start the Langroid Bot on an Anthropic key - #611
Merged
Merged
Conversation
kevin9327
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 18, 2026 22:38
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
9 tasks
The Langroid Bot names a model from any provider but OpenAI as `litellm/<provider>/<model>`, which is Langroid's own way of reaching one through litellm. Picked with an Anthropic key it never got that far, for two reasons. Langroid builds an OpenAI client even for a model it hands to litellm, and reads the key for it from `OPENAI_API_KEY` as one of its own settings. Compose writes that variable empty when the choice was not OpenAI, so the client was built with an empty key and refused: the module failed at import with `OpenAIError: Missing credentials`, and the container never served a run. Unset, the setting falls back to Langroid's placeholder, which is also what tells Langroid to leave the key to litellm rather than pass the placeholder on; litellm then reads `ANTHROPIC_API_KEY` itself. So an empty `OPENAI_API_KEY` is now removed before the agent is built. And litellm is an extra of Langroid's rather than a dependency, which the image did not install: with the key fixed alone, the module still fails at import, on `No module named 'litellm'`. The requirement is now `langroid[litellm]`. The test follows the LlamaIndex Bot's. Before this change the Anthropic key choice fails at import and the OpenAI key and compatible endpoint choices pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
davidmckayv
force-pushed
the
langroid-anthropic-key
branch
from
September 19, 2026 01:05
ecf97e0 to
7147a5c
Compare
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 an Anthropic key, the Langroid Bot exits on startup.
The harness already names a non-OpenAI model the way Langroid wants,
litellm/anthropic/claude-sonnet-4-5. Two things stopped it from getting that far:OPENAI_API_KEYas one of its ownOPENAI_*settings. For the Anthropic choice the desktop writes that variable empty (env.rs: "Every model key, every time, and empty unless the choice implies it"), and Compose passes it into the harness as"". The client refuses an empty key, soChatAgent(...)failed at import withopenai.OpenAIError: Missing credentials. Please pass an api_key ... or set the OPENAI_API_KEY ...and the container never served a run. With the variable unset, Langroid falls back to its placeholder key. That placeholder is also Langroid's signal to leave the key to litellm and not pass it on (if self.api_key != DUMMY_API_KEY: kwargs["api_key"] = self.api_keyinopenai_gpt.py). So the harness now removes an emptyOPENAI_API_KEYbefore building the agent, and litellm readsANTHROPIC_API_KEYitself.langroid. With only the key fixed, the module still fails at import, now onNo module named 'litellm'. The requirement is nowlangroid[litellm].The OpenAI key and OpenAI-compatible endpoint choices already worked and are unchanged: both set a non-empty
OPENAI_API_KEY, and their model is named bare, as before.Where it runs
python-harness.Boundary and audit
Changelog
CHANGELOG.mdunderUnreleased.Proof
agent-langroid/tests/test_main.pyisagent-llamaindex/tests/test_main.pywith the run posted to/, wherecreate_langroid_appserves it. It starts a local fake provider serving/v1/chat/completionsand/v1/messages, imports the harness under the environment the desktop writes for each of the three choices, and posts an AG-UI run. It asserts HTTP 200,RUN_FINISHED, noRUN_ERROR, and that the provider got the chosen model on the chosen route.ubuntu-latest, Python 3.12, a throwaway workflow on my fork running the same commands as the new CI step):3 passed.agent-langroid/srcfrommain(2d09a08):1 failed, 2 passed.[an Anthropic key]fails withOpenAIError: Missing credentials.main'srequirements.txt:1 failed, 2 passed.[an Anthropic key]fails withNo module named 'litellm'. So both halves are needed.langroid0.68.0,ag-ui-langroid0.1.1,litellm1.101.0.This adds a step at the end of
python-harnessand an entry at the top ofUnreleased, which #609 and #610 also touch. Whichever lands later needs a rebase, and I'll do it.🤖 Generated with Claude Code