Skip to content

Python: Fix Anthropic streaming response bugs - #3141

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
sukeesh:sukeesh/fix-streaming-length-exhaustion
Jan 8, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
sukeesh:sukeesh/fix-streaming-length-exhaustion

Conversation

@sukeesh

Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes two bugs in the Anthropic chat client streaming implementation:

Description

  1. Use raw_representation instead of raw_response parameter (which was silently ignored)
  2. Extract finish_reason from event.delta.stop_reason in message_delta events

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@markwallace-microsoft Mark Wallace (markwallace-microsoft) added the python Usage: [Issues, PRs], Target: Python label Jan 8, 2026
@github-actions github-actions Bot changed the title Fix Anthropic streaming response bugs Python: Fix Anthropic streaming response bugs Jan 8, 2026
@sukeesh

Copy link
Copy Markdown
Contributor Author

Victor Dibia (@victordibia) Mark Wallace (@markwallace-microsoft) pls take a look! thank you.

@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/anthropic/agent_framework_anthropic
   _chat_client.py26810162%236, 278, 309, 354–355, 364, 366–367, 369, 386–387, 426, 441, 445–446, 462, 474, 476, 480–481, 522–524, 526, 536–537, 544–546, 550–552, 556–559, 570, 572, 600–602, 612–614, 622, 627–628, 636–638, 641, 649–651, 659–662, 671–682, 685–692, 698–705, 708–718, 721–724
TOTAL16875261684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2592 154 💤 0 ❌ 0 🔥 57.854s ⏱️

@eavanvalkenburg

Copy link
Copy Markdown
Member

Sukeesh (@sukeesh) make sure you have the pre-commit installed so that the code is formatted in line with our standards, the code quality error would be fixed by doing that

auto-merge was automatically disabled January 8, 2026 16:10

Head branch was pushed to by a user without write access

@sukeesh

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) sure, let me take a look at that

@sukeesh

Copy link
Copy Markdown
Contributor Author

Dmytro Struk (@dmytrostruk) or Eduard van Valkenburg (@eavanvalkenburg) can u please re-approve? 🙇🏼

Merged via the queue into microsoft:main with commit ab493af Jan 8, 2026
23 checks passed