streaming: pre-assign message_id, add block_index and seq#32440
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc67ffef94
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| state.currentMessageId = undefined; | ||
| state.currentBlockIndex = undefined; | ||
| state.currentBlockType = null; | ||
| state.toolUseIdToBlockIndex.clear(); |
There was a problem hiding this comment.
Keep tool-use events on the persisted assistant message
For any assistant response that includes tool calls, AgentLoop.run() dispatches message_complete before it dispatches the corresponding tool_use events (see assistant/src/agent/loop.ts around the onEvent({ type: "message_complete" ... }) call followed by the for (const toolUse of toolUseBlocks) loop). Resetting currentMessageId here therefore closes the persisted assistant row before its tool blocks are streamed; the later handleToolUse allocates a new message id, so tool_use_start/tool_result are attached to the wrong message (often the follow-up text row) and their blockIndex no longer matches the persisted content. Tool-using turns will corrupt the new streaming protocol's message/block identity even though legacy events still arrive.
Useful? React with 👍 / 👎.
Summary
Part of plan: streaming-message-architecture.md (PR 1 of 6)