Migrate anthropic provider to use anthropic 1.x SDK - #72094
Merged
Merged
Conversation
eladkal
approved these changes
Aug 26, 2026
vincbeck
approved these changes
Aug 26, 2026
1 task
o-nikolas
approved these changes
Aug 26, 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.
Was generative AI tooling used to co-author this PR?
Closes: #72071
Raises the anthropic provider's SDK floor to
1.0.0and removes the temporary<1.0.0cap added in #72072.anthropic 1.0.0moved the SDK fromhttpxtohttpx2(Pydantic's fork). The cap went in because CI's "MyPy providers checks" started failing on unrelated PRs once the environment upgrade pulled 1.0.0 intouv.lock, and nobody had validated the provider against the new major.I validated it. Every symbol the provider imports still exists in
1.0.0, including the beta managed-agents types, and all 16 client call paths resolve. The existing 204 tests pass against 1.0.0 untouched. Two behaviour changes needed code, andneither was visible to the test suite.
Changes of note:
Bedrock and AWS region resolution.
get_connpassedaws_region=extras.get("aws_region"), which isNonewhen the connection extra is unset. On 0.x the SDK warned and defaulted tous-east-1. On 1.0 it raisesValueError, and omitting the argument entirely behaves the same way, so the call site could not sidestep it._build_aws_clientnow translates that failure into anAnthropicErrornaming theaws_regionextra and the connection id, so a deployment relying on the old default gets told where to fix it. It still passesNonethrough when no extra is set, letting the SDK resolve fromAWS_REGION/AWS_DEFAULT_REGIONor the AWS profile, and it re-raises the originalValueErroruntouched when a region was configured, so an unrelated constructor failure is
not mislabelled.
temperature,top_pandtop_kremoved frommessages.create.create_messageforwards**kwargsstraight to the SDK, so Dags passing these now hit aTypeError. I left that deliberately unhandled. The SDK removed them because newer models reject them, andextra_bodyis documented as an escape hatch for older models only. Rerouting them silently would turn a clearTypeErrorinto a confusing server-side API error.Test helper no longer depends on an HTTP library.
_make_bad_requestbuilt anhttpx.Responseto construct a realBadRequestError, which is what mypy flagged.APIStatusErroronly readsstatus_code,headersandrequestoff the response, so a small stub builds a genuineBadRequestErroron any SDK version. Swapping theimport to
httpx2would have moved the version coupling rather than removed it.Breaking change
Users on the 0.x SDK must upgrade to
anthropic>=1.0.0. Bedrock and AWS deployments that relied on the implicitus-east-1default must now setaws_regionin the connection extra or supply a region through the environment.Testing
207 unit tests pass against the locked
anthropic==1.0.0. Both new region tests fail without the hook change. mypy is clean on the changed files.{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.