langchain.js
    Preparing search index...

    Class UntrackedValue<Value>

    Represents a state field whose value is transient and never checkpointed.

    Use UntrackedValue for state fields that should be tracked for the lifetime of the process, but should not participate in durable checkpoints or recovery.

    // Create an untracked in-memory cache
    const cache = new UntrackedValue<Record<string, number>>();

    // Use with a type schema for basic runtime validation
    import { z } from "zod";
    const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });

    // You can customize whether to throw on multiple updates per step:
    const session = new UntrackedValue(undefined, { guard: false });

    Type Parameters

    • Value = unknown

      The type of value stored in this field.

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Create a new untracked value state field.

      Type Parameters

      • Value = unknown

      Parameters

      • Optionalschema: SerializableSchema<Value, Value>

        Optional type schema describing the value (e.g. a Zod schema).

      • Optionalinit: UntrackedValueInit

        Optional options for tracking updates or enabling multiple-writes-per-step.

      Returns UntrackedValue<Value>

    Properties

    guard: boolean

    Whether to guard against multiple updates to this untracked value in a single step.

    • If true (default), throws an error if multiple updates are received in one step.
    • If false, only the last value from that step is kept, others are ignored.

    This helps prevent accidental state replacement within a step.

    schema?: SerializableSchema<Value, Value>

    Optional schema describing the type and shape of the value stored in this field.

    If provided, this can be used for runtime validation or code generation.

    ValueType: Value

    Represents the type of value stored in this untracked state field.

    Methods

    • Type guard to check if a value is an UntrackedValue instance.

      Type Parameters

      • Value = unknown

      Parameters

      Returns value is UntrackedValue<Value>

    • Type guard to check if a value is an UntrackedValue instance.

      Parameters

      • value: unknown

      Returns value is UntrackedValue<unknown>