Skip to content

Commit 420d0d6

Browse files
committed
fix(openai): add logging
1 parent 0db7641 commit 420d0d6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/strands/models/openai.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,14 @@ def format_chunk(self, event: dict[str, Any], **kwargs: Any) -> StreamEvent:
428428
def _convert_non_streaming_to_streaming(self, response: Any) -> list[StreamEvent]:
429429
"""Convert a provider non-streaming response into streaming-style events.
430430
431-
This helper intentionally *does not* emit the initial message_start/content_start events,
432-
because the caller (stream) already yields them to preserve parity with streaming flow.
431+
This helper intentionally does not emit the initial content_start event,
432+
as the caller handles it to ensure parity with the streaming flow.
433+
434+
Args:
435+
response: The non-streaming response object from the provider.
436+
437+
Returns:
438+
list[StreamEvent]: The converted streaming events.
433439
"""
434440
events: list[StreamEvent] = []
435441

@@ -457,8 +463,7 @@ def _convert_non_streaming_to_streaming(self, response: Any) -> list[StreamEvent
457463
)
458464
)
459465
except Exception:
460-
# fall back to keeping the block as text if malformed
461-
pass
466+
logger.warning("block=<%s> | failed to parse reasoning content", block, exc_info=True)
462467
# text block
463468
elif "text" in block:
464469
events.append(
@@ -605,7 +610,7 @@ async def stream(
605610
if event and hasattr(event, "usage") and event.usage:
606611
yield self.format_chunk({"chunk_type": "metadata", "data": event.usage})
607612
else:
608-
# Non-streaming provider response — convert to streaming-style events.
613+
# Non-streaming provider response — convert to streaming-style events
609614
# We manually emit the content_start event here to align with the streaming path
610615
yield self.format_chunk({"chunk_type": "content_start", "data_type": "text"})
611616
for ev in self._convert_non_streaming_to_streaming(response):

0 commit comments

Comments
 (0)