fix(anthropic): constrain SDK below v1 - #1371
Conversation
Anthropic SDK 1.x removes the direct Messages sampling arguments that the current provider forwards and switches its transport to httpx2. Bound the supported SDK range until the 1.x provider migration lands.\n\nRestore the Anthropic transport tests to httpx and exercise completion, native Messages, and streaming sampling parameters through the real SDK client.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. WalkthroughChangesThe Anthropic dependency now has an upper version bound below 1. Messages API tests add parameter-forwarding coverage and migrate HTTP test clients and handlers from Anthropic Messages API
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change prevents incompatible Anthropic SDK 1.x installations while retaining existing Messages sampling behavior, with coverage for normal and streaming requests. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 10.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 1 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The dependency constraint matches the stated incompatibility, and the updated unit tests provide direct coverage that the SDK 0.x transport path serializes the affected parameters correctly.
Pull request overview
Constrains the Anthropic Python SDK dependency to >=0.119.0,<1 across core and related extras to prevent runtime request failures caused by SDK 1.x signature changes, while keeping the 0.119+ features relied on by the current provider implementation.
Changes:
- Pin
anthropicto>=0.119.0,<1in core deps and thevertexaianthropicandazureanthropicoptional dependency sets. - Update Anthropic Messages unit tests to use
httpxtransport (SDK 0.x) instead ofhttpx2. - Add unit tests that exercise real SDK request serialization for completion, native Messages, and streaming, including sampling and related parameters.
File summaries
| File | Description |
|---|---|
| tests/unit/providers/test_anthropic_messages.py | Switches mocked transport to httpx and adds concrete SDK transport assertions for sampling and related request fields. |
| pyproject.toml | Adds an upper bound <1 to Anthropic SDK dependencies (core, Vertex Anthropic, Azure Anthropic) to avoid SDK 1.x incompatibilities. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
## Description Add native structured-output support to Otari's Anthropic-compatible Messages path. - Route Pydantic and dataclass output types through Otari's native `message()` API using Anthropic-compatible transformed JSON schemas. - Normalize raw `output_config` dictionaries before forwarding them to Otari. - Preserve `context_management`, `betas`, and `cache_control` when structured output is requested. - Support structured-output streaming for providers that opt into the capability. - Add the same native streaming capability to the Anthropic provider path. - Update Messages API documentation and add streaming and non-streaming coverage. Previously, Otari structured-output requests fell back through the Messages-to-Completions bridge. That path could not retain Anthropic-specific fields and rejected structured output combined with context management or beta features. ## PR Type - 🆕 New Feature ## Relevant issues Related to mozilla-ai/octonous#4903. ## Verification - `uv run pytest tests/unit/providers/test_otari_provider.py -q --reruns 0`: 49 passed - `uv run pytest tests/unit/providers/test_anthropic_messages.py -q -k 'output_format or output_config' --reruns 0`: 7 passed - Commit-time lint, formatting, mypy, codespell, and repository hygiene hooks passed. - The existing local Anthropic `httpx`/`httpx2` full-suite mismatch is being handled separately in #1371. - Live Otari integration testing was not run because Otari credentials were unavailable locally. #### Checklist - [x] I understand the code I am submitting. - [x] I have added unit tests that prove my fix/feature works - [x] I have run this code locally and verified it fixes the issue. - [ ] New and existing tests pass locally - [x] Documentation was updated where necessary - [x] I have read and followed the [contribution guidelines](https://github.com/mozilla-ai/any-llm/blob/main/CONTRIBUTING.md) - [x] **AI Usage:** - [ ] No AI was used. - [ ] AI was used for drafting/refactoring. - [x] This is fully AI-generated. ## AI Usage Information - AI Model used: GPT-5 Codex - AI Developer Tool used: Codex - Any other info you'd like to share: The implementation was developed test-first and verified with focused provider suites. The separate Anthropic dependency mismatch discovered during full-suite verification is tracked independently in #1371. When answering questions by the reviewer, please respond yourself, do not copy/paste the reviewer comments into an AI system and paste back the answer. We want to discuss with you, not your AI :) - [x] I am an AI Agent filling out this form (check box if true) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for streaming schema-constrained Messages responses where supported. - Anthropic and Otari providers now support structured output during streaming. - Otari structured-output requests use the native Messages endpoint and support typed schemas and configuration dictionaries. - Schema-less output configuration dictionaries now return regular message responses. - **Documentation** - Clarified structured-output and streaming behaviour across the API documentation. - **Tests** - Added coverage for streaming structured output, provider-specific options, schema conversion, and native endpoint handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
Constrain the supported Anthropic SDK range to >=0.119.0,<1 until the SDK 1.x provider migration is complete (#1370).
Anthropic SDK 1.x removed temperature, top_p, and top_k from the Messages method signatures while the current provider still forwards those parameters directly. This causes common completion and native Messages requests to fail before reaching the transport. Version 0.119 and later retain the typed refusal and container functionality introduced through #1328.
This change:
The upper bound can be removed when the SDK 1.x migration in #1347 is complete and released.
PR Type
Relevant issues
Checklist
AI Usage Information
When answering questions by the reviewer, please respond yourself, do not copy/paste the reviewer comments into an AI system and paste back its answer. We want to discuss with you, not your AI :)
Summary by CodeRabbit
0.119.0up to, but not including,1.0.0.