Skip to content

feat(anthropic): add typed speed option to AnthropicConfig - #3495

Merged
vvlrff merged 5 commits into
ag2ai:mainfrom
its-amann:feature/anthropic-speed-3489
Oct 25, 2026
Merged

vvlrff merged 5 commits into
ag2ai:mainfrom
its-amann:feature/anthropic-speed-3489

Conversation

@its-amann

@its-amann its-amann commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Right now the only way to use Anthropic's fast mode in AG2 is to put speed inside extra_body, which isn't typed or validated. This PR adds a proper speed option ("standard" or "fast") to AnthropicConfig, its copy overrides and CreateOptions. When it's set, the value is sent with both streaming and non-streaming requests. When it's left unset, nothing changes and speed isn't added to the request.

Some models need the fast-mode-2026-02-01 beta header. I didn't add that header automatically, so the caller stays in control of it. The docs now show how to pass it through default_headers, and there are tests checking it works alongside AG2's existing MCP beta header.

Other notes:

  • The Anthropic SDK minimum goes up to 1.15.0, since that's the first version with a public speed argument. uv.lock is updated to match.
  • I left Usage unchanged. It only adds up token counts, so a per-request speed label doesn't really fit there.

Tested on Python 3.12 with Anthropic SDK 1.15.0:

  • just test: 4,382 passed, 103 skipped, 329 deselected, 2 xfailed. This is the non-LLM run, not the full CI matrix.
  • Anthropic unit tests: 284 passed, 1 skipped, 1 xfailed, including 14 new tests for speed.
  • Ruff lint/format and strict mypy pass on the Anthropic modules.
  • Wheel and sdist build fine.

Related issue number

Closes #3489

Checks

AI assistance

I used AI assistance for parts of the implementation, the tests and this description.

  • I understand the changes in this PR and can explain them in my own words.
  • I have verified that the PR description accurately reflects the actual diff.
  • If AI assistance was used, I reviewed, tested, and validated the generated code/text before submitting.

@its-amann
its-amann requested a review from marklysze as a code owner October 24, 2026 12:07
@github-actions github-actions Bot added area:docs Documentation (website/) area:deps Python dependency updates (pyproject.toml, uv.lock) area:providers LLM provider clients and mappers (ag2/config) labels Oct 24, 2026
@CLAassistant

CLAassistant commented Oct 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
ag2/config/anthropic/anthropic_client.py 81.05% <100.00%> (+7.99%) ⬆️
ag2/config/anthropic/config.py 91.66% <100.00%> (+0.62%) ⬆️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vvlrff
vvlrff enabled auto-merge October 25, 2026 13:05
@vvlrff
vvlrff added this pull request to the merge queue Oct 25, 2026
Merged via the queue into ag2ai:main with commit d08d75c Oct 25, 2026
11 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:deps Python dependency updates (pyproject.toml, uv.lock) area:docs Documentation (website/) area:providers LLM provider clients and mappers (ag2/config)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: AnthropicConfig speed option

3 participants