google-gemini/gemini-cli · warning

Not currently generating

Error message

Not currently generating

What it means

cancelPendingPrompt() aborts the in-flight prompt via its AbortController. If this.pendingPrompt is null — meaning no prompt() call is currently active — the method throws to signal that the cancel is a no-op. The Session tracks at most one active prompt at a time.

Source

Thrown at packages/cli/src/acp/acpSession.ts:200

        content: {
          type: 'text',
          text: `[MODE_UPDATE] ${payload.mode}`,
        },
      });
    }
  };

  dispose(): void {
    coreEvents.off(
      CoreEvent.ApprovalModeChanged,
      this.handleApprovalModeChanged,
    );
    this.disposeController.abort();
  }

  async cancelPendingPrompt(): Promise<void> {
    if (!this.pendingPrompt) {
      throw new Error('Not currently generating');
    }

    this.pendingPrompt.abort();
    this.pendingPrompt = null;
  }

  setMode(modeId: acp.SessionModeId): acp.SetSessionModeResponse {
    const availableModes = buildAvailableModes(
      this.context.config.isPlanEnabled(),
    );
    const mode = availableModes.find((m) => m.id === modeId);
    if (!mode) {
      throw new Error(`Invalid or unavailable mode: ${modeId}`);
    }
    // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
    this.context.config.setApprovalMode(mode.id as ApprovalMode);
    return {};
  }

View on GitHub (pinned to 5024443c72)

Solutions

  1. On the client side, track whether a prompt is active before sending a cancel notification.
  2. Wrap cancelPendingPrompt() in a try-catch and treat the 'Not currently generating' error as benign.
  3. Make cancel idempotent by checking this.pendingPrompt before calling.

Example fix

// before
await session.cancelPendingPrompt(); // throws when idle

// after
try {
  await session.cancelPendingPrompt();
} catch (e) {
  if (e instanceof Error && e.message === 'Not currently generating') {
    // No-op: nothing to cancel
  } else {
    throw e;
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Track prompt state on the caller/client side
let promptActive = false;

async function safePrompt(session: Session, params: acp.PromptRequest) {
  promptActive = true;
  try {
    return await session.prompt(params);
  } finally {
    promptActive = false;
  }
}

async function safeCancel(session: Session) {
  if (promptActive) {
    await session.cancelPendingPrompt();
  }
}

Try / catch

try {
  await session.cancelPendingPrompt();
} catch (e) {
  if (e instanceof Error && e.message === 'Not currently generating') {
    // Benign: nothing to cancel, ignore
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: An ACP client sends a cancel notification (e.g., cancelCurrentRequest) when the session is idle. This happens with duplicate cancels, cancel-after-completion, or client/server state desynchronization.

Common situations: Client-side race condition where the prompt already completed before the cancel arrived; double-cancel from the client; client state desync after an error; automated test harness sending cancel unconditionally.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/b41a52331d1581be. Report an issue: GitHub.