@sema-agent/core
Version:
Stateless, task-oriented AI agent core
23 lines (22 loc) • 1.81 kB
TypeScript
import type { RunnerSelfSeat } from "./runner/contracts.js";
import type { TaskResult, TaskSpec } from "./types.js";
/**
* design/114 P0 — a convenience for the RECOMMENDED safe warm-resume of a (failed / timed-out) run: FORK the
* session, then run a continuation on the fork. Fork-first is the safe path (design/114 §3.2):
* - **idempotent** — each call branches a FRESH session, so resuming twice can't corrupt the source's linear
* history (vs `runTask({sessionId})` reuse, which appends two divergent continuations onto one history);
* - **orphan-safe** — the fork drops an in-flight tool call (`settledForkOptions`), so a continuation of an agent
* that died mid-tool-call gets a clean point rather than inheriting an `[INTERRUPTED]` orphan;
* - **fail-loud** — a missing source returns `null`; it NEVER silently starts a fresh EMPTY run the way
* `runTask({sessionId})` would via create-on-miss (the "looks warm, actually fresh" trap). Cross-restart /
* cross-replica warm-resume therefore requires a DURABLE `SessionRepo` — an in-memory fork is lost on restart.
*
* Returns `null` when the store can't fork OR the source session is gone — the caller decides what to do (surface
* an error, fall back, etc.), never a silent fresh run. `sessionId` typically comes from a failed
* `WorkflowAgentRun.sessionId` (design/114) or a prior `TaskResult.sessionId`. The continuation's `objective` is
* the directive for picking up the work; pass the model (and any other spec fields) via `opts` — a continuation
* still needs a model like any task.
*/
export declare function warmResume(runner: RunnerSelfSeat, sessionId: string, objective: string, opts?: Omit<Partial<TaskSpec>, "objective" | "sessionId"> & {
owner?: string | null;
}): Promise<TaskResult | null>;