paperclipai/paperclip · error
interrupt the active turn before deleting the remote session
Error message
interrupt the active turn before deleting the remote session
What it means
deleteManagedRemoteSession refuses to destroy the remote session while a turn is still active (#activeTurnId !== null). The provider cannot safely delete an in-flight session, so the caller must interrupt the current turn first.
Source
Thrown at packages/paperclip-runner/src/live/live-session.ts:2109
return this.snapshot();
}
async deleteManagedRemoteSession(): Promise<CapabilityLiveSessionSnapshot> {
if (
(this.#config.provider !== "claude_managed" &&
this.#config.provider !== "aws_agentcore") ||
this.#transport === null
) {
throw new Error(
"remote session deletion requires a connected remote provider session",
);
}
if (
this.#activeTurnId !== null ||
this.#turnWaiter !== null ||
this.#pendingTurnAdmission !== null
) {
throw new Error(
"interrupt the active turn before deleting the remote session",
);
}
await this.#transport.request("session/destroy", {});
this.#providerSessionId = null;
this.#authority.active = false;
this.#status = "closed";
this.#appendEvidence("cleanup", null, {
reason: "remote session explicitly deleted",
remoteDeleted: true,
resumable: false,
});
await this.#persist();
return this.snapshot();
}
async resolveInteraction(input: CapabilityInteractionResolution): Promise<CapabilityLiveTurnResult> {
const interaction = pendingInteractions(this.#port).find(View on GitHub (pinned to 01ad858492)
Solutions
- Interrupt/abort the active turn (e.g. session.interrupt()) and await it before deleting
- Await turn completion before triggering deletion
- Serialize operations so delete is only issued when the session is idle
- Catch this error in UI code and prompt the user to stop the turn first
Example fix
// before
await session.deleteManagedRemoteSession(); // throws if a turn is active
// after
if (session.snapshot().activeTurnId !== null) {
await session.interrupt();
}
await session.deleteManagedRemoteSession(); Defensive patterns
Strategy: validation
Validate before calling
if (session.snapshot().activeTurnId !== null) await session.interrupt();
Try / catch
try {
await session.deleteManagedRemoteSession();
} catch (err) {
if (err instanceof Error && err.message.includes('interrupt the active turn')) {
await session.interrupt();
await session.deleteManagedRemoteSession();
} else throw err;
} Prevention
- Disable delete UI while a turn is streaming
- Always check active turn state before teardown
- Await turn completion in shutdown paths before deleting remote sessions
When it happens
Trigger: Calling deleteManagedRemoteSession while a model turn is executing (e.g. user hits delete during a streaming response, or shutdown code fires mid-turn).
Common situations: Deleting a session from the UI while the agent is mid-answer; watchdog cleanup racing an active turn; forgetting to await turn completion before teardown.
Related errors
- remote session deletion requires a connected remote provider
- The Pi ACPX profile is not available
- Claude Managed live sessions require a qualified managed pro
- AWS AgentCore live sessions require a qualified AgentCore pr
- Managed live sessions require an explicit qualified model
AI-assisted analysis of paperclipai/paperclip@01ad858492 (2026-09-10).
Data as JSON: /api/errors/2c3fcc2a4f459872.
Report an issue: GitHub.