How to use durable sessions
Pause a session
Pause an OrchaJS session with .pause() and continue the same durable conversation later.
Use .pause() to safely stop active work:
const session = await orcha.supportAgent.pause(sessionId);
console.log(session.status);
// "paused"Orcha preserves what happened before the pause. You can continue the same session later.
Continue later
const result = await orcha.supportAgent.resume(sessionId, {
content: "Continue, but keep the answer under three bullets.",
}).result;
if (result.status === "completed") {
console.log(result.output);
}If the session is waiting for a client action, return its tool results instead. A new message cannot skip pending client actions.
What gets paused
- Active provider work is aborted.
- Active child-agent work is paused too.
- Streamed output is preserved as an incomplete assistant message.
run.pausedandsession.pausedevents are recorded.- The returned snapshot has
status: "paused"andrunStatus: "paused".
Calling .pause() on an already paused session safely returns its current
snapshot.
API reference
pause(sessionId: string): Promise<SessionSnapshot>sessionId— the session to stop.- The promise waits until active work has stopped and durable pause events have been saved.
- It resolves with the complete
SessionSnapshot. - Calling it again is idempotent: an already paused session returns its current snapshot.
session_not_foundis thrown when the ID does not belong to this agent.
Pausing does not delete the session or its output. Resume it with
resume().