Skip to content

fix(streaming): normalize finish_reason in get_result() per streaming… - #52

Merged
Mowri Mohan (mowree) merged 1 commit into
microsoft:mainfrom
HDMowri:main
Apr 22, 2026
Merged

fix(streaming): normalize finish_reason in get_result() per streaming…#52
Mowri Mohan (mowree) merged 1 commit into
microsoft:mainfrom
HDMowri:main

Conversation

@mowree

Copy link
Copy Markdown
Collaborator

…-contract:FinishReason:MUST:5

StreamingAccumulator.get_result() now applies the same finish_reason normalization as to_chat_response(): SDK uppercase values fold to lowercase, and tool_calls presence overrides the SDK-provided reason. Previously get_result() returned raw self.finish_reason, producing inconsistent values for callers on the get_result() path.

Test suite: remove ~2,830 lines of structural and tautological tests across 7 deleted files (test_sdk_mocks, test_sdk_protection, test_sdk_protection_validation, test_protocol_compliance, test_sdk_boundary, test_session_factory, sdk_helpers). Migrate surviving contract coverage into behavioral tests: sdk-boundary:Membrane:MUST:5 and sdk-boundary:TypeTranslation:MUST:1,2 into test_sdk_boundary_contract; provider-protocol:mount:MUST:2,3 into test_contract_protocol. Add 34 new tests for deny-destroy contract clauses across 4 dedicated test modules. Restore 5 missing contract anchors (behaviors:ConfigLoading:MUST:6, provider-protocol:list_models:MUST:2, provider-protocol:name:MUST:2, sdk-boundary:TypeTranslation:MUST:1,2) with proper Contract: prefix so gate audit achieves 214/214 MUST clause coverage.

ruff: 0 errors | pyright: 0 errors | pytest (win32/py3.13): 1,154 passed | pytest (linux/py3.14): 1,162 passed | coverage: 98%

…-contract:FinishReason:MUST:5

StreamingAccumulator.get_result() now applies the same finish_reason normalization as
to_chat_response(): SDK uppercase values fold to lowercase, and tool_calls presence
overrides the SDK-provided reason. Previously get_result() returned raw self.finish_reason,
producing inconsistent values for callers on the get_result() path.

Test suite: remove ~2,830 lines of structural and tautological tests across 7 deleted
files (test_sdk_mocks, test_sdk_protection, test_sdk_protection_validation,
test_protocol_compliance, test_sdk_boundary, test_session_factory, sdk_helpers).
Migrate surviving contract coverage into behavioral tests: sdk-boundary:Membrane:MUST:5
and sdk-boundary:TypeTranslation:MUST:1,2 into test_sdk_boundary_contract;
provider-protocol:mount:MUST:2,3 into test_contract_protocol. Add 34 new tests for
deny-destroy contract clauses across 4 dedicated test modules. Restore 5 missing
contract anchors (behaviors:ConfigLoading:MUST:6, provider-protocol:list_models:MUST:2,
provider-protocol:name:MUST:2, sdk-boundary:TypeTranslation:MUST:1,2) with proper
Contract: prefix so gate audit achieves 214/214 MUST clause coverage.

ruff: 0 errors | pyright: 0 errors | pytest (win32/py3.13): 1,154 passed | pytest (linux/py3.14): 1,162 passed | coverage: 98%
@mowree
Mowri Mohan (mowree) merged commit a5777fa into microsoft:main Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants