LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
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
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
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 v0.3

ReducedValue

Copy
class ReducedValue

Used in Docs

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

Constructors

Properties

Methods

View source on GitHub

Example 1

Example 2

constructor
constructor
property
inputSchema: SerializableSchema<unknown, Value | Input>
property
InputType: Input
property
jsonSchemaExtra: Record<string, unknown>
property
reducer: (current: Value, next: Input) => Value
property
valueSchema: SerializableSchema<unknown, Value>
property
ValueType: Value
method
isInstance→ value is Overwrite<ValueType>

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.

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

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

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.

Copy
// Accumulator with distinct input validation
const Sum = new ReducedValue(z.number(), {
  inputSchema: z.number().min(1),
  reducer: (total, toAdd) => total + toAdd
});
Copy
// Simple running max, using only the value schema
const Max = new ReducedValue(z.number(), {
  reducer: (current, next) => Math.max(current, next)
});