Skip to content

[FIX] models - gemini - start and stop reasoningContent#1557

Merged
JackYPCOnline merged 4 commits intostrands-agents:mainfrom
JackYPCOnline:move_out
Jan 27, 2026
Merged

[FIX] models - gemini - start and stop reasoningContent#1557
JackYPCOnline merged 4 commits intostrands-agents:mainfrom
JackYPCOnline:move_out

Conversation

@JackYPCOnline
Copy link
Contributor

Description

When using Gemini models with thinking_config enabled, the reasoning/thinking content was being printed to console but not captured in the agent's message history.

This PR:
Modified the Gemini model provider to properly capture reasoning content by implementing content type switching:

  • Stream Handler Enhancement: Added logic to detect transitions between "text" and "reasoning_content" types
  • Content Block Lifecycle: When content type changes, emit contentBlockStop for the previous type and contentBlockStart for the new type
  • Delta Events: Reasoning content is now emitted as contentBlockDelta events with data_type: "reasoning_content"

Referenced fix:
https://github.com/strands-agents/sdk-python/pull/947/files#diff-a1ec2ea9af3dcd76184638c766807d737d33e9c308d229c075423e961a00174c

Related Issues

#1394

Documentation PR

Type of Change

Bug fix
New feature
Breaking change
Documentation update
Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

# Conflicts:
#	src/strands/experimental/hooks/multiagent/events.py
#	src/strands/multiagent/graph.py
#	src/strands/multiagent/swarm.py
#	src/strands/session/session_manager.py
#	tests/fixtures/mock_multiagent_hook_provider.py
#	tests/strands/hooks/test_events.py
#	tests/strands/hooks/test_multi_agent_hooks.py
#	tests/strands/multiagent/conftest.py
#	tests/strands/multiagent/test_graph.py
#	tests/strands/multiagent/test_swarm.py
#	tests_integ/hooks/multiagent/test_cancel.py
#	tests_integ/hooks/multiagent/test_events.py
#	tests_integ/interrupts/multiagent/test_hook.py
@JackYPCOnline JackYPCOnline marked this pull request as ready for review January 25, 2026 00:04
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/models/gemini.py 88.88% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@JackYPCOnline JackYPCOnline merged commit 62cc949 into strands-agents:main Jan 27, 2026
14 of 15 checks passed
@JackYPCOnline JackYPCOnline deleted the move_out branch January 27, 2026 23:00
gaurav71531 pushed a commit to gaurav71531/sdk-python that referenced this pull request Feb 4, 2026
manoj-selvakumar5 pushed a commit to manoj-selvakumar5/strands-sdk-python that referenced this pull request Feb 5, 2026
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.

3 participants