LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphwebReducedValue
Class●Since v1.1

ReducedValue

Represents a state field whose value is computed and updated using a reducer function.

ReducedValue allows you to define accumulators, counters, aggregators, or other fields whose value is determined incrementally by applying a reducer to incoming updates.

Each time a new input is provided, the reducer function is called with the current output and the new input, producing an updated value. Input validation can be controlled separately from output validation by providing an explicit input schema.

Copy
class ReducedValue

Used in Docs

  • Build a multi-source knowledge base with routing
  • Checkpointers
  • Custom middleware
  • Graph API overview
  • INVALID_CONCURRENT_GRAPH_UPDATE

Example 1

Copy
// Accumulator with distinct input validation
const Sum = new ReducedValue(z.number(), {
  inputSchema: z.number().min(1),
  reducer: (total, toAdd) => total + toAdd
});

Example 2

Copy
// Simple running max, using only the value schema
const Max = new ReducedValue(z.number(), {
  reducer: (current, next) => Math.max(current, next)
});

Constructors

constructor
constructor→ ReducedValue<Value, Input>

Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).

Properties

property
inputSchema: SerializableSchema<unknown, Value | Input>

The schema used to validate reducer inputs. If not specified explicitly, this defaults to valueSchema.

property
InputType: Input

Represents the type that may be provided as input on each update.

property
jsonSchemaExtra: Record<string, unknown>

Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).

property
reducer: (current: Value, next: Input) => Value

The reducer function that combines a current output value and an incoming input.

property
valueSchema: SerializableSchema<unknown, Value>

The schema that describes the type of value stored in state (i.e., after reduction). Note: We use unknown for the input type to allow schemas with .default() wrappers, where the input type includes undefined.

property
ValueType: Value

Represents the value stored after all reductions.

Methods

method
isInstance→ value is ReducedValue<Value, Input>

Type guard to check if a value is a ReducedValue instance.

View source on GitHub