-
Notifications
You must be signed in to change notification settings - Fork 402
Closed
Description
Problem
_approvalPersistedMessageId is a single instance field on AIChatAgent. If two streams are active simultaneously and both trigger tool-approval-request, the second write overwrites the first, and stream completion for the first stream would use the wrong ID.
Current mitigation
This doesn't happen in practice because:
_streamingMessageis also a single reference (same serialization assumption)_tryCatchChatserializes stream handling- Approval pauses the stream, so concurrent streaming is unlikely
If concurrent streams are ever supported
Change _approvalPersistedMessageId from string | null to a Map<string, string> keyed by stream ID or message ID. The _streamSSEReply method would set the entry, and the completion block in _reply would look up and remove it.
Context
Introduced in the approval persistence fix (persist streaming message immediately when a tool enters approval-requested state so the approval UI survives page refresh).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels