11"""
22Integration test for thinking block handling during condensation.
33
4- This test validates that Claude Opus 's thinking blocks are properly handled
4+ This test validates that Anthropic Claude 's thinking blocks are properly handled
55during conversation condensation, preventing malformed signature errors that
66can occur when thinking blocks are included in conversation history.
7+
8+ Note: This test only applies to models that support extended_thinking (Anthropic
9+ Claude models). Models with reasoning_effort (like OpenAI o-series and GPT-5.x)
10+ produce reasoning items instead of thinking blocks, and are skipped.
711"""
812
913from openhands .sdk import LLM , Message , TextContent , Tool
1014from openhands .sdk .context .condenser .base import CondenserBase
1115from openhands .sdk .context .view import View
1216from openhands .sdk .conversation .impl .local_conversation import LocalConversation
1317from openhands .sdk .event import ActionEvent , Condensation
18+ from openhands .sdk .llm .utils .model_features import get_features
1419from openhands .sdk .tool import register_tool
1520from openhands .tools .terminal import TerminalTool
1621from tests .integration .base import BaseIntegrationTest , SkipTest , TestResult
@@ -135,16 +140,16 @@ def setup(self) -> None:
135140 """
136141 Validate that the model supports extended thinking.
137142
138- Thinking blocks are primarily supported by:
139- - Anthropic Claude models (extended_thinking)
140- - Some Gemini models (extended_thinking)
141- - Some other models (reasoning_effort)
143+ Thinking blocks are specifically supported by Anthropic Claude models
144+ with extended_thinking enabled. Models that only support reasoning_effort
145+ (like OpenAI o-series and GPT-5.x) produce reasoning items instead of
146+ thinking blocks, so they should be skipped.
142147 """
143148 model = self .llm_config .get ("model" , "" )
149+ features = get_features (model )
144150
145- # Check if model has extended thinking or reasoning effort configured
151+ # Check if model has extended thinking configured
146152 has_extended_thinking = self .llm_config .get ("extended_thinking" , False )
147- has_reasoning_effort = "reasoning_effort" in self .llm_config
148153
149154 # For Claude Opus, automatically enable extended thinking if not set
150155 if "opus" in model .lower () and not has_extended_thinking :
@@ -154,11 +159,15 @@ def setup(self) -> None:
154159 ** {** self .llm .model_dump (), ** self .llm_config }
155160 )
156161 self .agent .llm = self .llm
162+ has_extended_thinking = True
157163
158- # Skip test if model doesn't support thinking blocks
159- if not has_extended_thinking and not has_reasoning_effort :
164+ # Skip test if model doesn't support extended thinking (which produces
165+ # thinking_blocks). Models that only support reasoning_effort produce
166+ # responses_reasoning_item instead, which is a different mechanism.
167+ if not has_extended_thinking and not features .supports_extended_thinking :
160168 raise SkipTest (
161- f"Model { model } does not support extended thinking or reasoning effort"
169+ f"Model { model } does not support extended thinking "
170+ "(produces reasoning items instead of thinking blocks)"
162171 )
163172
164173 def conversation_callback (self , event ):
0 commit comments