Skip to content

fix(anthropic): constrain SDK below v1 - #1371

Merged
HareeshBahuleyan merged 1 commit into
mainfrom
fix/anthropic-pre-v1-constraint
Sep 4, 2026
Merged

HareeshBahuleyan merged 1 commit into
mainfrom
fix/anthropic-pre-v1-constraint

Conversation

@HareeshBahuleyan

@HareeshBahuleyan HareeshBahuleyan commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • applies the upper bound to the core, Vertex Anthropic, and Azure Anthropic dependency declarations
  • restores Anthropic transport tests to httpx, which is the transport used by SDK 0.x
  • adds real SDK transport coverage for completion, native Messages, and streaming sampling parameters
  • covers container and service tier serialization through the concrete SDK client

The upper bound can be removed when the SDK 1.x migration in #1347 is complete and released.

PR Type

  • 🐛 Bug Fix

Relevant issues

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary (no user-facing API or behavior documentation changed)
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: GPT-5
  • AI Developer Tool used: Codex
  • Any other info you would like to share: The Anthropic v1 migration notes were reviewed and the sampling-signature failure was reproduced against the concrete SDK client before adding the temporary compatibility bound.

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 :)

  • I am an AI Agent filling out this form (check box if true)

Summary by CodeRabbit

  • Compatibility
    • Updated the supported Anthropic SDK range to versions from 0.119.0 up to, but not including, 1.0.0.
    • This compatibility range applies to core Anthropic integrations and the Vertex AI and Azure optional integrations.

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.
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: bbbf0ee8-3e11-4792-a870-63d87b0929ed

📥 Commits

Reviewing files that changed from the base of the PR and between c1f167b and 332d66f.

📒 Files selected for processing (2)
  • pyproject.toml
  • tests/unit/providers/test_anthropic_messages.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

Changes

The 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 httpx2 to httpx.

Anthropic Messages API

Layer / File(s) Summary
Anthropic dependency bounds
pyproject.toml
The core dependency and optional Anthropic extras require >=0.119.0,<1.
Message parameter forwarding tests
tests/unit/providers/test_anthropic_messages.py
Tests cover completion and native Messages API parameters, including sampling, container, and service tier values.
HTTP transport migration
tests/unit/providers/test_anthropic_messages.py
Existing handlers, responses, and asynchronous clients use httpx instead of httpx2.
Streaming parameter assertions
tests/unit/providers/test_anthropic_messages.py
The accumulated streaming test checks forwarded temperature, top-p, and top-k values.

Suggested reviewers: njbrake

Merge Risk: ⚪ Minimal · up to 332d6

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: constraining the Anthropic SDK below version 1.
Description check ✅ Passed The description is complete and relevant. It explains the temporary SDK constraint, affected dependencies, compatibility reason, test coverage, related issues, checklist status, and AI usage.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/anthropic-pre-v1-constraint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@HareeshBahuleyan
HareeshBahuleyan requested a lite review from Copilot September 4, 2026 09:40
@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 anthropic to >=0.119.0,<1 in core deps and the vertexaianthropic and azureanthropic optional dependency sets.
  • Update Anthropic Messages unit tests to use httpx transport (SDK 0.x) instead of httpx2.
  • 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.

@HareeshBahuleyan
HareeshBahuleyan merged commit 2388f59 into main Sep 4, 2026
21 checks passed
@HareeshBahuleyan
HareeshBahuleyan deleted the fix/anthropic-pre-v1-constraint branch September 4, 2026 09:53
@github-actions github-actions Bot added the 1.27.1 Included in release 1.27.1 label Sep 4, 2026
HareeshBahuleyan added a commit that referenced this pull request Sep 10, 2026
## 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 -->

This branch was successfully deployed

1 active deployment
integration-tests — 332d66fd Deployed Sep 4, 2026 by HareeshBahuleyan via run-docs-tests #2847
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.27.1 Included in release 1.27.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants