Skip to content

Python: consume Anthropic beta flags - #5772

Closed
Yufeng He (he-yufeng) wants to merge 2 commits into
microsoft:mainfrom
he-yufeng:fix/anthropic-beta-flags
Closed

Python: consume Anthropic beta flags#5772
Yufeng He (he-yufeng) wants to merge 2 commits into
microsoft:mainfrom
he-yufeng:fix/anthropic-beta-flags

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • consume per-run additional_beta_flags into the Anthropic beta set without forwarding it as a raw request kwarg
  • add a regression test for _prepare_options(...)

Fixes #5764.

To verify

  • uv run pytest tests/test_anthropic_client.py -q
  • uv run ruff check agent_framework_anthropic tests/test_anthropic_client.py
  • uv run ruff format --check agent_framework_anthropic tests/test_anthropic_client.py
  • uv run pyright
  • uv run mypy --config-file pyproject.toml agent_framework_anthropic
  • python -m py_compile agent_framework_anthropic\_chat_client.py tests\test_anthropic_client.py

Copilot AI review requested due to automatic review settings May 12, 2026 08:20
@moonbox3 Evan Mattson (moonbox3) added the python Usage: [Issues, PRs], Target: Python label May 12, 2026

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.

Pull request overview

Fixes an Anthropic client integration issue where per-run additional_beta_flags were being forwarded as a raw request kwarg (causing Anthropic SDK TypeErrors) instead of being consumed into the betas set used for the request.

Changes:

  • Remove additional_beta_flags from the final run_options after it has been merged into betas.
  • Add a regression test ensuring additional_beta_flags is consumed into betas and not forwarded.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/packages/anthropic/agent_framework_anthropic/_chat_client.py Pops additional_beta_flags from run_options after preparing betas to prevent forwarding unsupported kwargs.
python/packages/anthropic/tests/test_anthropic_client.py Adds a regression test to verify additional_beta_flags is consumed into betas and removed from run_options.

@moonbox3

Evan Mattson (moonbox3) commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/anthropic/agent_framework_anthropic
   _chat_client.py4473592%461, 464, 545, 639, 641, 784, 820–821, 899, 901, 931–932, 977, 993–994, 1001–1003, 1007–1009, 1013–1016, 1130, 1140, 1192, 1340–1341, 1358, 1371, 1384, 1409–1410
TOTAL37714439488% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
7500 34 💤 0 ❌ 0 🔥 1m 59s ⏱️

@eavanvalkenburg

Copy link
Copy Markdown
Member

Yufeng He (@he-yufeng) please check the failing tests.

@moonbox3

Evan Mattson (moonbox3) commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Please re-open the PR when CI/CD checks (unit tests) are green.

auto-merge was automatically disabled June 2, 2026 09:30

Pull request was closed

@he-yufeng

Copy link
Copy Markdown
Contributor Author

I rebased this branch onto current upstream/main and force-pushed a linear one-commit head after the CI failure.

Validation on the new head:

uv run --dev python -m pytest packages\anthropic\tests\test_anthropic_client.py::test_prepare_options_consumes_additional_beta_flags -q --basetemp .tmp\pytest-5772-target2
uv run --dev python -m pytest packages\anthropic\tests\test_anthropic_client.py -q --basetemp .tmp\pytest-5772-full2
uv run --dev python -m ruff check packages\anthropic\agent_framework_anthropic\_chat_client.py packages\anthropic\tests\test_anthropic_client.py
uv run --dev python -m py_compile packages\anthropic\agent_framework_anthropic\_chat_client.py packages\anthropic\tests\test_anthropic_client.py
git diff --check upstream/main..HEAD

I tried to reopen the PR, but GitHub rejected the reopen request from my side. Could you reopen it so the fresh checks can run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python Anthropic: per-run additional_beta_flags leaks into request kwargs

4 participants