fix(coding-agent/session): stopped post-prompt recovery waits after aborted generations
- Added a generation-aware early-exit check in `#waitForPostPromptRecovery` to return when the prompt turn is superseded. - Passed the current prompt generation into the post-prompt recovery wait after prompting. - Ensured aborted prompts no longer block while later queued retry/follow-up turns drain.
This commit is contained in:
@@ -2120,8 +2120,13 @@ export class AgentSession {
|
||||
* and fire-and-forget `agent.continue()` may still be streaming after
|
||||
* the TTSR resume gate resolves.
|
||||
*/
|
||||
async #waitForPostPromptRecovery(): Promise<void> {
|
||||
async #waitForPostPromptRecovery(generation?: number): Promise<void> {
|
||||
while (true) {
|
||||
// An abort bumps #promptGeneration. When this wait runs on behalf of a
|
||||
// specific prompt turn, stop as soon as that turn has been superseded:
|
||||
// its promise must resolve on the abort, not block on a queued
|
||||
// steer/follow-up that the post-abort drain starts as a fresh turn.
|
||||
if (generation !== undefined && this.#promptGeneration !== generation) return;
|
||||
if (this.#retryPromise) {
|
||||
await this.#retryPromise;
|
||||
continue;
|
||||
@@ -4871,7 +4876,7 @@ export class AgentSession {
|
||||
const agentPromptOptions = options?.toolChoice ? { toolChoice: options.toolChoice } : undefined;
|
||||
await this.#promptAgentWithIdleRetry(messages, agentPromptOptions);
|
||||
if (!options?.skipPostPromptRecoveryWait) {
|
||||
await this.#waitForPostPromptRecovery();
|
||||
await this.#waitForPostPromptRecovery(generation);
|
||||
}
|
||||
} finally {
|
||||
this.#endInFlight();
|
||||
|
||||
Reference in New Issue
Block a user