Repository navigation
Python: fix anthropic dependency bounds via dev dependency group instead of runtime deps - #9255
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The committed uv.lock must be regenerated to include the new dependency edges.
1 open finding
What changed in this PR
Adds missing runtime dependencies to unblock Anthropic dependency-bound validation.
Changes:
- Declares
boto3andgoogle-authdependencies. - Ensures isolated Pyright probes can resolve provider imports.
| File | Description |
|---|---|
python/packages/anthropic/pyproject.toml |
Adds AWS and Google authentication dependencies. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
赵瑞哲 (@zhaoruizhe81) These look like test/dependency-bounds requirements rather than runtime dependencies of |
|
@microsoft-github-policy-service agree |
|
Done — boto3 and google-auth are out of runtime dependencies and now live in a |
Per review feedback, boto3 and google-auth are not runtime dependencies of agent-framework-anthropic: boto3 is an ImportError-fallback optional import in _bedrock_client.py and google-auth only appears in _vertex_client.py type annotations. Shipping them to every agent-framework-anthropic install would burden Anthropic-only users. Move both into a PEP 735 [dependency-groups] dev group (same pattern as packages/core). The dependency-bounds probe installs declared groups, so the isolated pyright pass still resolves both imports and the bounds test passes; the base install stays slim. uv.lock regenerated with the repo-pinned uv 0.12.23 (required-version now enforced on main); validate_dependency_bounds --mode test --package anthropic passes lower and upper scenarios.
ec40703 to
19a2a92
Compare

Motivation & Context
The weekly Python - Dependency Maintenance workflow has failed its bounds test for
packages/anthropicatlowest-directresolution every week since 2026-08-03 (last green run: 2026-07-27, immediately before #7342 merged). Because test mode aborts on the first lower-scenario failure, the upper-bound validation and dependency-range updates are skipped every week — only dev-dependency updates survive. The bot-created tracker is #6661.Root cause: two imports in
agent_framework_anthropicreference packages the package never declares:_vertex_client.py:23importsgoogle.auth.credentialsunderTYPE_CHECKING(used only in parameter annotations at lines 47 and 123). In the dev workspace google-auth arrives transitively (viaagent-framework-gemini→google-genai→google-api-core→google-auth), but the bounds test builds an isolated per-package environment containing only the declared dependencies (--resolution lowest-direct), so the import cannot resolve → 4 pyright errors._bedrock_client.py:36importsboto3inside_resolve_aws_region(optional runtime import with anImportErrorfallback, added by Python: Update Anthropic SDK to 1.11 #9119 on 2026-10-07 — after the last CI run, which is why recent logs show only the 4 vertex errors; the next run shows 8) → 4 more errors.A static
# type: ignoreis not viable here: the root config setsreportUnnecessaryTypeIgnoreComment = "error"(python/pyproject.toml), so in dev environments where these packages are installed the ignores would themselves be flagged.Description & Review Guide
boto3>=1.35.0,<2.0.0andgoogle-auth>=2.0.0,<3.0.0are no longer runtime dependencies. They are declared in a PEP 735[dependency-groups]devgroup ofpython/packages/anthropic/pyproject.toml— the same pattern aspackages/core, whose dev group exists precisely "so isolated source checks can resolve their APIs". The bounds probe installs every declared dependency group (--group dev) alongside the non-allextras, so the isolated pyright pass resolves both imports, while a plainpip install agent-framework-anthropicno longer pulls boto3/google-auth for Anthropic-only users. No source-code changes.uv.lockupdated to match: the anthropic entry's dev group is recorded ([package.dev-dependencies]+[package.metadata.requires-dev]), regenerated with the repo-pinned uv 0.12.23;uv lock --lockedpasses. Branch rebased onto currentmain.Related Issue
Fixes #6661
Context on the tracker: #6661 is the auto-generated tracking issue ("Dependency bounds test failed"); its body describes the June
packages/coreincident, which was fixed by declaringazure-ai-agentserver-core— this PR applies the dev-side equivalent of that pattern to the current failure, which ispackages/anthropic. Note this PR fixes thepackages/anthropicfailure specifically; the gate still has other pre-existing failures documented in #8049 (e.g.packages/azure-contentunderstandingfails at its declared floor), so a full-gate green run needs those addressed separately.How I verified
Environment: macOS arm64, Python 3.13, uv 0.12.23 (the version
required-versionnow pins inpython/pyproject.toml). All commands run frompython/.uv run python -m scripts.dependencies.validate_dependency_bounds --mode test --package anthropic→packages/anthropic: lower passed,packages/anthropic: upper passed,Test mode completed successfully.Exit code 0.uv lock --lockedpasses under the repo-pinned uv 0.12.23 (whichrequired-versioninpython/pyproject.tomlnow enforces).tests/test_anthropic_provider_clients.pypatchesboto3.Session).--mode test(all packages) proceeds pastpackages/anthropic: lower passedand aborts atpackages/azure-contentunderstanding: lower failed(pre-existing, documented in Python: [Bug]: dependency-maintenance upper-bound step has been skipped since Aug 3, freezing every package's dependency bounds #8049) — consistent with this PR not claiming a fully green gate.AI Assistance
AI assistance details: failure diagnosis (CI log + workflow analysis), patch drafting, and local verification runs were performed with an AI coding agent (Claude Code / ZCode CLI); I reviewed the diff and reproduction steps and accept responsibility for the content.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.