diff --git a/api/streaming.py b/api/streaming.py index 6d1c920b..27b1a9ff 100644 --- a/api/streaming.py +++ b/api/streaming.py @@ -5264,6 +5264,18 @@ def _merge_display_messages_after_agent_result(previous_display, previous_contex # before the agent runs. When the agent returns that same user turn # in result_messages, keep the durable checkpoint and append only # the assistant/tool delta. + # The eager checkpoint was written before _assign_stable_message_ids + # stamped the result rows, so it has no `id` while the context copy + # does — which would silently defeat id-based fork/truncate alignment + # for eager-mode users. Carry the minted id onto the kept checkpoint + # so display and context share it (#5564). + if ( + isinstance(msg, dict) + and msg.get('id') is not None + and isinstance(merged[-1], dict) + and merged[-1].get('id') is None + ): + merged[-1]['id'] = msg['id'] continue if ( key is not None