Skip to content

Python: consume Anthropic beta flags#5772

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/anthropic-beta-flags
Open

Python: consume Anthropic beta flags#5772
he-yufeng wants to merge 1 commit 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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python Anthropic: per-run additional_beta_flags leaks into request kwargs

3 participants