Skip to content

Migrate anthropic provider to use anthropic 1.x SDK - #72094

Merged
amoghrajesh merged 2 commits into
apache:mainfrom
astronomer:bump-anthropic-to-1
Sep 8, 2026
Merged

amoghrajesh merged 2 commits into
apache:mainfrom
astronomer:bump-anthropic-to-1

Conversation

@amoghrajesh

@amoghrajesh amoghrajesh commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Was generative AI tooling used to co-author this PR?
  • Yes claude sonnet

Closes: #72071
Raises the anthropic provider's SDK floor to 1.0.0 and removes the temporary <1.0.0 cap added in #72072.

anthropic 1.0.0 moved the SDK from httpx to httpx2 (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 into uv.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, and
neither was visible to the test suite.

Changes of note:

  1. Bedrock and AWS region resolution. get_conn passed aws_region=extras.get("aws_region"), which is None when the connection extra is unset. On 0.x the SDK warned and defaulted to us-east-1. On 1.0 it raises ValueError, and omitting the argument entirely behaves the same way, so the call site could not sidestep it. _build_aws_client now translates that failure into an AnthropicError naming the aws_region extra and the connection id, so a deployment relying on the old default gets told where to fix it. It still passes None through when no extra is set, letting the SDK resolve from AWS_REGION / AWS_DEFAULT_REGION or the AWS profile, and it re-raises the original ValueError
    untouched when a region was configured, so an unrelated constructor failure is
    not mislabelled.

  2. temperature, top_p and top_k removed from messages.create. create_message forwards **kwargs straight to the SDK, so Dags passing these now hit a TypeError. I left that deliberately unhandled. The SDK removed them because newer models reject them, and extra_body is documented as an escape hatch for older models only. Rerouting them silently would turn a clear TypeError into a confusing server-side API error.

  3. Test helper no longer depends on an HTTP library. _make_bad_request built an httpx.Response to construct a real BadRequestError, which is what mypy flagged. APIStatusError only reads status_code, headers and request off the response, so a small stub builds a genuine BadRequestError on any SDK version. Swapping the
    import to httpx2 would 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 implicit us-east-1 default must now set aws_region in 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.


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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.

@amoghrajesh
amoghrajesh merged commit 5677af3 into apache:main Sep 8, 2026
95 checks passed
@amoghrajesh
amoghrajesh deleted the bump-anthropic-to-1 branch September 8, 2026 08:17
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate anthropic provider to anthropic SDK 1.0 (httpx2) and remove the <1.0.0 cap

4 participants