Skip to main content
run({ ...startOptions, prompt, onTurn }) starts a session, sends prompt, then after each turn calls onTurn(turn, session): a message it returns is the next turn, and nothing (or an empty message) stops. Without onTurn it sends one turn. It closes the session and resolves with { sessionId, cwd, turns, resume, fork }.
result.resume(prompt, options?) continues its session as a new run, and result.fork(prompt, options?) branches it into a new session that continues from there, leaving this one’s record as it is. Each takes this run’s options (its output and onTurn aside) under any options you give. A fork isolates only the conversation: without a branch of its own it works where this run did, so give concurrent forks one each. Each needs a message. A run whose session never got an id (no turn reached the agent) has nothing to continue, and both reject with RunNotResumableError.

Errors