Genkit JS API reference
    Preparing search index...

    Interface SessionSnapshot<S>

    Saved snapshot of a session's state at a given event point.

    Runtime variant of SessionSnapshotSchema, generic over the custom state type S.

    interface SessionSnapshot<S = unknown> {
        createdAt: string;
        error?: { details?: any; message: string; status?: string };
        finishReason?:
            | "length"
            | "stop"
            | "failed"
            | "other"
            | "unknown"
            | "interrupted"
            | "blocked"
            | "aborted"
            | "detached";
        heartbeatAt?: string;
        parentId?: string;
        sessionId?: string;
        snapshotId: string;
        state?: SessionState<S>;
        status?: "failed" | "completed" | "pending" | "expired" | "aborted";
        updatedAt?: string;
    }

    Type Parameters

    • S = unknown
    Index

    Properties

    createdAt: string
    error?: { details?: any; message: string; status?: string }

    Structured failure information (RuntimeError shape). status is the canonical error category (e.g. INTERNAL, FAILED_PRECONDITION).

    finishReason?:
        | "length"
        | "stop"
        | "failed"
        | "other"
        | "unknown"
        | "interrupted"
        | "blocked"
        | "aborted"
        | "detached"

    Semantic reason the turn/invocation finished (e.g. interrupted, stop). Distinct from status, which tracks the persistence lifecycle.

    heartbeatAt?: string

    Heartbeat timestamp (RFC 3339) refreshed periodically while a detached (background) turn is in flight. Used to detect a dead background worker: if a pending snapshot's heartbeat goes stale (older than the configured timeout), reads surface its status as expired (the dead process can no longer persist a terminal status itself).

    parentId?: string

    ID of the previous snapshot in this timeline. Informational lineage (for debugging and UI history trees); plays no part in resolving a session's latest snapshot.

    sessionId?: string

    ID of the session this snapshot belongs to. Assigned by the agent framework when the conversation's first invocation starts and stamped on every later snapshot in the chain, including across resumed invocations. Stores preserve it across rewrites; rows written without one (data from before session IDs existed) belong to no session.

    snapshotId: string
    state?: SessionState<S>

    Conversation state captured at this point. Empty on a pending snapshot (the live state is not yet committed); populated on terminal snapshots with the cumulative final state.

    status?: "failed" | "completed" | "pending" | "expired" | "aborted"
    updatedAt?: string

    When the snapshot was last written (RFC 3339). Equals createdAt until rewritten.