Skip to content

Python: fix(anthropic): copy the response_format schema instead of modifying it - #8735

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
anishmehta24:fix/anthropic-response-format-no-mutation
Sep 28, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
anishmehta24:fix/anthropic-response-format-no-mutation

Conversation

@anishmehta24

Copy link
Copy Markdown
Contributor

Motivation & Context

AnthropicClient._prepare_response_format set additionalProperties = False directly on the schema dict it was given. That dict belongs to the caller, so after one request their response_format was changed: a schema that allowed additional properties now forbade them for every later request that reused it, including with other providers.

Description & Review Guide

  • What are the major changes? Build a copy with {**schema, "additionalProperties": False} instead of assigning into the caller's dict. The pydantic-model branch already works on a freshly generated schema, so it's unchanged.
  • What is the impact of these changes? Same request payload as before; the caller's response_format is no longer modified.
  • What do you want reviewers to focus on? Nothing beyond that one line.

Related Issue

No existing issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible

Test: test_prepare_response_format_does_not_modify_caller_schema in tests/test_anthropic_client.py; it fails on main. The anthropic tests pass and the repo's pre-commit checks are clean.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 24, 2026
Merged via the queue into microsoft:main with commit ed745e5 Sep 28, 2026
50 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — b999139f Deployed Sep 24, 2026 by anishmehta24 via team_check #5246
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.

3 participants