What happened?
AgentSession.clearQueue() destroys messages queued by extensions via
sendCustomMessage() but does not return them, so any host that implements
"edit queued messages" as clear + replay silently loses them.
Code paths (0.85.1, same code present in 0.87.0):
steer()/followUp() write BOTH the _steeringMessages/_followUpMessages
string lists AND agent.steer()/followUp() — so user-queued text is
returned by clearQueue().
sendCustomMessage(..., { deliverAs: "followUp" | "steer" }) during an
active run calls this.agent.followUp(appMessage) directly and bypasses
those lists.
clearQueue() builds its return value from the string lists only, then
calls agent.clearAllQueues() (void) — custom-role AgentMessages are
destroyed with no snapshot, no return, no event.
Note the split is entry-path based, not role based: pi.sendUserMessage()
(extension origin, user role) routes through prompt({ streamingBehavior })
and IS returned, while pi.sendMessage() (custom role) is not.
Steps to reproduce
Verified by source inspection; concrete sequences:
- SDK: start a streaming run; while streaming, call
sendCustomMessage({ customType: "x", content: "y" }, { deliverAs: "followUp", triggerTurn: true });
then call clearQueue() → the custom message is destroyed, the return
value does not contain it, and nothing is emitted.
- TUI: install an extension that delivers background notifications via
sendMessage({ deliverAs: "followUp" }) mid-run (e.g. a subagent
orchestrator); when a notification is queued, use the dequeue key to
edit queued messages → the notification is silently dropped and the
parent model is never woken.
Affected surfaces: TUI restoreQueuedMessagesToEditor, RPC clear_queue
(#8432), and SDK embedders that clear + requeue to implement queue editing.
Expected behavior
clearQueue() should not silently destroy messages it doesn't report. Any
one of these would unblock hosts (not asking for the full queue API from
#9174):
- return everything destroyed, including custom-role entries (structured:
customType/content/details), so hosts can requeue via sendCustomMessage; or
clearQueue({ userMessagesOnly: true }) leaves extension messages in the
agent queues; or
- minimally, emit an event/diagnostic when non-user messages are dropped.
Version
0.85.1 (verified by source inspection; same code on main / 0.87.0).
What happened?
AgentSession.clearQueue()destroys messages queued by extensions viasendCustomMessage()but does not return them, so any host that implements"edit queued messages" as clear + replay silently loses them.
Code paths (0.85.1, same code present in 0.87.0):
steer()/followUp()write BOTH the_steeringMessages/_followUpMessagesstring lists AND
agent.steer()/followUp()— so user-queued text isreturned by
clearQueue().sendCustomMessage(..., { deliverAs: "followUp" | "steer" })during anactive run calls
this.agent.followUp(appMessage)directly and bypassesthose lists.
clearQueue()builds its return value from the string lists only, thencalls
agent.clearAllQueues()(void) — custom-role AgentMessages aredestroyed with no snapshot, no return, no event.
Note the split is entry-path based, not role based:
pi.sendUserMessage()(extension origin, user role) routes through
prompt({ streamingBehavior })and IS returned, while
pi.sendMessage()(custom role) is not.Steps to reproduce
Verified by source inspection; concrete sequences:
sendCustomMessage({ customType: "x", content: "y" }, { deliverAs: "followUp", triggerTurn: true });then call
clearQueue()→ the custom message is destroyed, the returnvalue does not contain it, and nothing is emitted.
sendMessage({ deliverAs: "followUp" })mid-run (e.g. a subagentorchestrator); when a notification is queued, use the dequeue key to
edit queued messages → the notification is silently dropped and the
parent model is never woken.
Affected surfaces: TUI
restoreQueuedMessagesToEditor, RPCclear_queue(#8432), and SDK embedders that clear + requeue to implement queue editing.
Expected behavior
clearQueue()should not silently destroy messages it doesn't report. Anyone of these would unblock hosts (not asking for the full queue API from
#9174):
customType/content/details), so hosts can requeue via
sendCustomMessage; orclearQueue({ userMessagesOnly: true })leaves extension messages in theagent queues; or
Version
0.85.1 (verified by source inspection; same code on main / 0.87.0).