fix(llm): route http_client to the matching sync/async Anthropic client#565
Open
matteomedioli wants to merge 5 commits into
Open
fix(llm): route http_client to the matching sync/async Anthropic client#565matteomedioli wants to merge 5 commits into
matteomedioli wants to merge 5 commits into
Conversation
This was referenced Jul 16, 2026
…ync Anthropic clients Route httpx.Client only to the sync anthropic.Anthropic constructor and httpx.AsyncClient only to the async anthropic.AsyncAnthropic constructor, mirroring BaseOpenAILLM's existing param-splitting pattern, so passing a sync-only or async-only http_client no longer collides across both clients.
… type Mirror BaseOpenAILLM's existing behavior: when http_client is provided but is neither an httpx.Client nor an httpx.AsyncClient instance, emit a warning and construct both clients with the default (no custom) http_client instead of raising.
…tests Add unit tests verifying httpx.Client reaches only the sync Anthropic client, httpx.AsyncClient reaches only the async client, and an invalid http_client type warns and falls back to defaults for both clients. Also note the stale-venv anthropic version gotcha in AGENTS.md.
Documents the AnthropicLLM sync/async http_client kwargs collision bug fixed in tasks 001-002, matching the repo's existing changelog style.
Keep the PR scoped to the http_client routing fix.
matteomedioli
force-pushed
the
matteo/anthropic-kwargs-bugfix
branch
2 times, most recently
from
July 17, 2026 15:21
e487f99 to
4300d09
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.
Stack
Merge order: #565 → #567 → #566 → #571 / #572 (last two in either order). Each PR builds on the previous one. Until its base merges, GitHub may show parent commits in the diff — review only the commits unique to this branch.
Description
AnthropicLLMbuilds two SDK clients — one sync, one async — from the same**kwargs. Most settings are safe to share between them, buthttp_clientis not: the sync client needs anhttpx.Clientand the async client needs anhttpx.AsyncClient. Today whichever one you pass is forwarded to both clients, so one of them always receives the wrong type. In practice there is no way to inject a custom HTTP client intoAnthropicLLMat all.This PR fixes that:
http_clientnow goes only to the client whose type it matches.OpenAILLMalready has.No new parameters, no signature changes. If you never pass
http_client, nothing changes for you.Type of Change
Complexity
Complexity: Low
How Has This Been Tested?
Checklist