From ca6cd402cd331bed32ed9977373f59060730b628 Mon Sep 17 00:00:00 2001 From: Apostol Apostolov Date: Thu, 10 Sep 2026 15:35:36 +0300 Subject: [PATCH] Queue Grok account-rotation continuation as followUp. Bare sendUserMessage during an active turn throws Pi core's Extension "" already-processing error. deliverAs followUp queues when streaming and still starts a turn when idle. --- src/provider/rotation.ts | 2 +- tests/provider/rotation.test.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/provider/rotation.ts b/src/provider/rotation.ts index cc24aef..3d85192 100644 --- a/src/provider/rotation.ts +++ b/src/provider/rotation.ts @@ -165,7 +165,7 @@ export function registerExhaustionRotation( 'info', ); awaitingContinuation = true; - pi.sendUserMessage(ROTATION_CONTINUATION); + pi.sendUserMessage(ROTATION_CONTINUATION, { deliverAs: 'followUp' }); return; } diff --git a/tests/provider/rotation.test.ts b/tests/provider/rotation.test.ts index df0f7dd..93d2db8 100644 --- a/tests/provider/rotation.test.ts +++ b/tests/provider/rotation.test.ts @@ -136,7 +136,9 @@ describe('Grok CLI exhaustion rotation', () => { }); expect((await getAccountVault()).activeAccountId).toBe('account-1'); expect(test.setModel).not.toHaveBeenCalled(); - expect(test.sendUserMessage).toHaveBeenCalledWith(ROTATION_CONTINUATION); + expect(test.sendUserMessage).toHaveBeenCalledWith(ROTATION_CONTINUATION, { + deliverAs: 'followUp', + }); expect(test.notify).toHaveBeenCalledWith( 'Grok CLI: “Account 1” exhausted; switched to “Work” and continuing.', 'info', @@ -260,6 +262,8 @@ describe('Grok CLI exhaustion rotation', () => { await expect(pending).resolves.toBeUndefined(); expect(test.selection.accountId('session-a')).toBe('account-3'); expect((await getAccountVault()).activeAccountId).toBe('account-1'); - expect(test.sendUserMessage).toHaveBeenCalledWith(ROTATION_CONTINUATION); + expect(test.sendUserMessage).toHaveBeenCalledWith(ROTATION_CONTINUATION, { + deliverAs: 'followUp', + }); }); });