From 705f9e2ba1724ca38cd01c96c6a6833fab242429 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sat, 9 May 2026 22:17:09 +0200 Subject: [PATCH] fix: queue user prompt as followUp when system turn is streaming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the agent is already streaming (system-triggered turn, e.g. autonomous dispatch at startup) and the user sends a message without an explicit streamingBehavior, default to followUp instead of steer. Steer injects mid-stream into the current turn. FollowUp queues the message as a clean new turn after the system work finishes — which is what the user expects when they type their first message at startup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../pi-coding-agent/src/core/agent-session.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/pi-coding-agent/src/core/agent-session.ts b/packages/pi-coding-agent/src/core/agent-session.ts index 6e0910971..203517525 100644 --- a/packages/pi-coding-agent/src/core/agent-session.ts +++ b/packages/pi-coding-agent/src/core/agent-session.ts @@ -1214,17 +1214,16 @@ export class AgentSession { ]); } - // If streaming, queue via steer() or followUp() based on option + // If streaming, queue via steer() or followUp() based on option. + // Default to followUp when no streamingBehavior is given — this covers + // user prompts that arrive while a system-triggered turn (e.g. autonomous + // dispatch at startup) is already running. The user's message queues as + // a clean new turn after the current one finishes, not steered into it. if (this.isStreaming) { - if (!options?.streamingBehavior) { - throw new Error( - "Agent is already processing. Please wait for it to finish before sending another message.", - ); - } - if (options.streamingBehavior === "followUp") { - await this._queueFollowUp(expandedText, currentImages); - } else { + if (options?.streamingBehavior === "steer") { await this._queueSteer(expandedText, currentImages); + } else { + await this._queueFollowUp(expandedText, currentImages); } return; }