diff --git a/src/strands/event_loop/streaming.py b/src/strands/event_loop/streaming.py index 76eda48bf..2b346c840 100644 --- a/src/strands/event_loop/streaming.py +++ b/src/strands/event_loop/streaming.py @@ -303,7 +303,7 @@ def handle_content_block_stop(state: dict[str, Any]) -> dict[str, Any]: content.append({"text": text}) state["text"] = "" - elif reasoning_text: + elif reasoning_text or "signature" in state: content_block: ContentBlock = { "reasoningContent": { "reasoningText": { diff --git a/tests/strands/event_loop/test_streaming.py b/tests/strands/event_loop/test_streaming.py index 93f8d95f8..be67c0471 100644 --- a/tests/strands/event_loop/test_streaming.py +++ b/tests/strands/event_loop/test_streaming.py @@ -481,6 +481,27 @@ def test_handle_content_block_delta(event: ContentBlockDeltaEvent, event_type, s "redactedContent": b"", }, ), + # Reasoning with empty text but non-empty signature + ( + { + "content": [], + "current_tool_use": {}, + "text": "", + "reasoningText": "", + "signature": "123", + "citationsContent": [], + "redactedContent": b"", + }, + { + "content": [{"reasoningContent": {"reasoningText": {"text": "", "signature": "123"}}}], + "current_tool_use": {}, + "text": "", + "reasoningText": "", + "signature": "123", + "citationsContent": [], + "redactedContent": b"", + }, + ), # redactedContent ( {