fix(core): add warning log for streaming chunks missing id or otid (#9513)

Adds a diagnostic log at the streaming chokepoint in LettaAgentV3.stream()
to detect when any LettaMessage chunk is yielded without an id or otid field.
This helps trace the root cause of client-side id/otid inconsistencies.
This commit is contained in:
jnjpng
2026-02-17 14:53:26 -08:00
committed by Caren Thomas
parent 3247fa7065
commit 042c9c36af

View File

@@ -492,6 +492,17 @@ class LettaAgentV3(LettaAgentV2):
response_letta_messages.append(chunk)
if first_chunk:
request_span = self._request_checkpoint_ttft(request_span, request_start_timestamp_ns)
# Log chunks with missing id or otid for debugging
if isinstance(chunk, LettaMessage) and (not chunk.id or not chunk.otid):
self.logger.warning(
"Streaming chunk missing id or otid: message_type=%s id=%s otid=%s step_id=%s",
chunk.message_type,
chunk.id,
chunk.otid,
chunk.step_id,
)
yield f"data: {chunk.model_dump_json()}\n\n"
first_chunk = False