Skip to content

fix(mock): report finish_reason after a streamed prompt - #721

Merged
TonsOfFun merged 1 commit into
activeagents:mainfrom
pcbeingused333:fix/mock-stream-finish-reason
Nov 19, 2026
Merged

TonsOfFun merged 1 commit into
activeagents:mainfrom
pcbeingused333:fix/mock-stream-finish-reason

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

MockProvider simulates a stream that ends with a message_delta carrying stop_reason: "end_turn", but process_stream_chunk only stored it on the in-flight message and never recorded it as the stream's finish reason. A streamed generation has no response body, so response.finish_reason fell back to streamed_finish_reason and returned nil. Applications that branch on the finish reason could not exercise that path with the mock provider, unlike with the Anthropic and OpenAI Chat providers.

The mock now sets stream_finish_reason from the message_delta, the same way the Anthropic provider does. Non-streamed mock responses are unchanged.

Test: test/providers/mock_provider_test.rb gets "a streamed generation reports why it stopped", which expects "end_turn"; it fails on main with nil. The whole file passes (13 runs, 0 failures). A CHANGELOG entry is included.

This change was made with Claude Code; the tests above were run on the branch.

🤖 Generated with Claude Code

The mock emitted end_turn in its stream but never recorded it, so
response.finish_reason was nil after a streamed prompt.
@TonsOfFun TonsOfFun added this to the 1.9.10 milestone Nov 19, 2026
@TonsOfFun
TonsOfFun merged commit d9e7a7e into activeagents:main Nov 19, 2026
18 checks passed
yorzi pushed a commit to yorzi/activeagent that referenced this pull request Nov 19, 2026
…tool-choice-required

CHANGELOG: the 1.9.9 section is released, so the entries from activeagents#721 and activeagents#722
move to a new Unreleased section, with entries added for activeagents#712 and activeagents#720.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PCEJHngWphRQ7ArmDnYMmf
yorzi pushed a commit to yorzi/activeagent that referenced this pull request Nov 19, 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