npm / langchain
langchain
What changed in langchain 0.3 to 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-12-05.
55 breaking8 security47 new APIs and options2 performance17 behavior and defaults1 tooling60 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initlangchain 1188 changes
Breaking changes 55
When configurableFields is omitted, ConfigurableModel no longer allows configurable.model or configurable.modelProvider to swap the model at invoke time; pass both fields to retain runtime swapping.
Installed dependencies must use Zod 4.6.6 or newer to exclude versions affected by GHSA-mrhx-c7xc-m3w5; Zod v3 schemas remain supported through the bundled zod/v3 entry point.
Adds middleware that throws ModelRefusalError when the model refuses, rather than ending the run as if it succeeded; the error passes through unwrapped instead of as a MiddlewareError.
A tool that throws GraphDrained now stops the agent run with that error instead of returning an error ToolMessage and allowing the agent to continue.
In both modes, setting tool to true allows every decision, including respond.
Respects retryability marks by default and stops retrying once a non-retryable error is found; unclassified errors retain the previous retry behavior.
Aborted calls, context overflow, and oversized payloads are marked non-retryable out of the box, so they fail without consuming retry budgets.
Passing retryOn: () => true restores the previous retry behavior for errors marked non-retryable.
Middleware-internal model calls and summaries are no longer projected as messages in run.messages or message streams; they remain observable through v2 stream events via lc_source.
Throws StructuredOutputParsingError when a terminal providerStrategy response cannot be parsed or does not satisfy the schema; tool calls can still continue the agent loop.
Fireworks is extracted into a standalone provider package.
A standalone Perplexity provider package is available.
Together AI is migrated into a provider package.
Renamed getSubgraphAsync to getSubgraphsAsync.
The afterModel router now respects the tool behavior version: v1 routes the full AIMessage to one ToolNode invocation, while v2 dispatches each tool call as a separate Send task.
fakeModel moved from utils/testing to the testing namespace, so update imports to use the updated namespace.
The default model changes to claude-sonnet-4-5-20250929, replacing the retired claude-3-5-sonnet-latest.
Hooks that return void no longer re-emit the input state.
strict now defaults to true in providerStrategy for OpenAI compatibility.
Constrained the lower bound of the core peer dependency, affecting which @langchain/core versions satisfy the peer dependency requirement.
The exit behavior was renamed from throw to error.
call is removed; use invoke instead.
predict is removed; use invoke instead.
predictMessages is removed; use invoke instead.
loadAndSplit is removed; use load followed by a text splitter.
addAIChatMessage is removed; use addMessage with AIMessage.
call is removed; use invoke instead.
predict is removed; use invoke instead.
getRelevantDocuments is removed; use invoke instead.
BaseStoreInterface is removed; use specific store implementations.
runMap is removed; use LangSmith tracing APIs.
fromPromptMessages is removed; use fromMessages.
Pass a plain model string or instance and a separate tools list; pre-bound models are not supported.
The prompt parameter is renamed to systemPrompt.
Introduces the standard API for building agents, with customization through middleware.
The React agent prebuilt is available from langchain as createAgent, replacing createReactAgent from @langchain/langgraph/prebuilts.
createChatMessageChunkEncoderStream is removed; use the stream method directly.
Package builds use a bundler-based approach instead of raw TypeScript outputs; imports from dist/ need updating to the new module system.
Use middleware to generate dynamic system prompts based on conversation state or runtime context.
getRuntimeEnvironmentSync is removed; use async getRuntimeEnvironment.
Built-in human-in-the-loop middleware supports tool approval decisions configured with interruptOn.
The package namespace is streamlined to essential agent building blocks; legacy functionality is no longer imported from it and has moved to
@langchain/classic.Legacy chains, retrievers, indexing, community exports, and other deprecated functionality move to this package.
Post-model hooks are replaced by middleware implementing afterModel, allowing multiple handlers after the model responds.
Pre-model hooks are replaced by middleware implementing beforeModel, allowing multiple handlers to run before the model call.
Dynamic model selection moves to middleware using wrapModelCall to swap models and tools based on state or runtime context.
Configure tool error handling through middleware implementing wrapToolCall.
The streamed agent node name changes from agent to model; update filters or event matching that use the node name.
All LangChain packages require Node.js 22 or higher; Node 18 support is dropped.
Prompted output through custom instructions in responseFormat is removed in favor of toolStrategy and providerStrategy.
RemoteRunnable is no longer supported.
Runnable.bind is removed; use bindTools or other specific binding methods.
Runnable.map is removed; use batch instead.
Built-in summarization middleware is available for summarizing conversation history before a model call.
TraceGroup is removed; use LangSmith tracing instead.
Security 7
Adds middleware that blocks listed tool calls a decision model judges risky.
Middleware hook input state is derived from the current invocation state instead of cross-node cached state, preventing state from leaking across threads.
LangChain serialization injection vulnerability enables secret extraction
Security hardening was added for load.
Prevents summarization middleware from leaking streaming events.
Adds prebuilt middleware that requires approval for sensitive tool calls.
Adds prebuilt middleware to redact sensitive information before sending it to the model.
New APIs and options 47
Adds middleware that picks the agent's model for each run from a decision model's Choice answer.
Adds tracePolicy to control what LangChainTracer sends to LangSmith during middleware lifecycle hook runs.
Adds model-routing middleware for agents.
Adds a beta runnable with typed predicate, choice and score questions.
Adds tool-risk middleware for agents.
Adds opt-in per_call mode, which raises a separate tool_approval interrupt for each gated tool call, answered by interrupt ID; respond is supported.
Adds Interrupt.response_schema.
Adds an API to read an error's retryability mark; it returns undefined when an error has not been classified.
Models accept a per-call maxRetries value so a surrounding retry loop can take over.
Adds an API to mark errors as retryable or non-retryable without changing their class or shape, allowing provider SDK errors and tool failures to be classified.
initChatModel now supports the LangSmith gateway.
Adds middleware for handling tool execution errors.
V3 runs expose named nested agents invoked from tools through run.subagents, with scoped messages, tool calls, and output.
Adds a typed stream handle for named nested agents, exposing name, cause, scoped messages and tool calls, and output.
Adds middleware that makes a best-effort attempt to use prompt caching features for supported Bedrock models.
Adds an optional when callback that dynamically skips interrupts for specific tool calls by deciding whether to interrupt or auto-approve.
LangChain adds support for browser tools.
initChatModel adds support for ChatGoogle.
Adds support for dynamic structured output.
LangSmith integration metadata is added to createAgent and initChatModel.
Adds a browser export for LangChain, allowing browser-specific module resolution.
Adds Vitest matchers for LangChain message and tool call assertions, registerable with expect.extend; the matchers are also re-exported from langchain.
Structured output now supports standard schemas.
Added a getter/setter that forwards store access to the internal compiled graph.
Adds an optional tools parameter for more accurate token estimates when tools are bound to a model.
Adds an optional modelProvider parameter for direct config lookup, avoiding className collisions while preserving callers that pass only className.
Adds a ReactAgent method for setting default configuration values that merge with invocation-time config.
Summarization model calls are tagged with lc_source metadata, allowing developers to identify their source.
Agent generics now use a type bag pattern with AgentTypeConfig, MiddlewareTypeConfig, and helper types for type extraction.
Prompt pulling now supports secrets.
Prompt pulling now supports secretsFromEnv.
The stream API now supports the callbacks property.
Allows developers to set the strict tag manually in providerStrategy.
New TypeScript types provide strong typing for standard content blocks.
Adds a provider-agnostic, type-safe property for accessing reasoning traces, citations, built-in tools, and other content features.
Pass static, read-only configuration through the context config argument instead of config.configurable; the old pattern remains supported.
Adds structured output generation in the main agent loop, allowing models to choose between tools and provider-side structured output without an additional LLM call.
Lets developers implement custom middleware hooks to intercept agent, model, and tool execution.
Adds control over error handling for parsing errors and multiple tool calls in structured output.
Adds prebuilt middleware for interrupting agent execution for human approval.
Set LC_OUTPUT_VERSION=v1 to opt in to serializing standard content blocks into the content attribute.
Set outputVersion to v1 to opt in to serializing standard content blocks into the content attribute.
Use providerStrategy for provider-native structured output generation.
Accepts a schema for structured output from an agent, available on the result as
structuredResponse.Introduces standard content blocks as one of the core improvements in the release.
Adds prebuilt middleware to condense conversation history when it gets too long.
Use toolStrategy for structured output generated through artificial tool calling.
Performance 2
Parallel tool tasks restore tool and middleware state from graph channels instead of copying full agent state, while retaining support for full-state tasks in older checkpoints.
Structured output is generated in the main loop, can use provider-side structured output, and eliminates an additional LLM call.
Behavior and default changes 17
The function now accepts tool messages.
Tool messages created for reject and respond decisions now include lc_source and lc_data metadata identifying the interrupt decision.
The default todo-list system prompt and tool description now align with Python and guide the agent to deliver a substantive final answer after its last todo update.
Error ToolMessages from the tool node carry status: "error"; a ToolMessage returned by a custom handleToolErrors function defaults to that status if none is set.
A custom onFailedAttempt handler replaces the built-in handler and opts out of automatic error marking.
Tool-call streams now treat any serialized graph interrupt as control flow, keeping the call pending so it can resume instead of rejecting its output promise.
Adds ls_agent_type to tracing metadata when creating agent runs.
Accepts cross-version runnable models.
Dynamic tools can be used in wrapModelCall with wrapToolCall.
Store and configurable are now propagated to the ToolNode middleware runtime.
The middleware runtime now receives configurable from the LangGraph config.
Middleware hooks can return Command objects for advanced control flow, matching the existing wrapToolCall pattern.
Summarization middleware messages now include the lc_source tag.
Adds support for anyOf, allOf, and oneOf in OpenAPI conversion.
Context editing was aligned with the summarization interface.
Summarization middleware now uses profile.maxInputTokens.
Tool call contents and tool call IDs are now included to improve token count approximation.
Tooling 1
Type inference is implemented for tool streams, allowing developers to infer their types.
Fixes and other changes 59
A failed tool call or subagent no longer crashes the process when its output promise is never consumed.
A Command returned from wrapModelCall is applied once when outer middleware passes it through.
Preserves model errors propagated through middleware.
The array form of retryOn now retries errors that are subclasses of a listed class, matching toolRetryMiddleware.
Approved, edited, and auto-approved tool calls are now executed when other calls in the same interrupt are rejected, instead of being dropped without a ToolMessage.
Edits in per_call mode are pinned to the called tool and checked against the input side of its Zod v4 schema, so transforms run once when the tool does; invalid answers throw without being saved.
With middleware, createAgent now passes a Command built by a different copy of @langchain/langgraph to the graph as-is instead of merging it into the input state as a plain object.
Preserves LangGraph interrupts instead of retrying them or converting them into tool errors, allowing interrupted tool calls to pause and resume through their checkpointer.
A failed returnDirect tool call, including one with arguments that fail the tool schema, now returns to the model for correction and retry; the run ends on the first successful returnDirect result.
Callbacks are preserved when the compiled graph is extracted, without duplicate calls through the agent.
Structured-output parsing now ignores thought/reasoning text blocks.
The gateway now uses a unified endpoint.
Runtime instance comparisons now use the same logic as .isInstance(), avoiding conflicts when multiple versions of core are installed.
Resolves LocalFileStore keys with path.relative.
Malformed tool input schemas are unrecoverable.
Strict tools are decoupled from strict structured output responses.
Tool message outputs are unwrapped in agent streams.
ToolMessages produced by todoListMiddleware now have a name set.
Prevents llmToolSelectorMiddleware from leaking into the message stream.
Prevents local file corruption when using LocalFileStore.
createAgent and prebuilt middleware are now exported from the browser entry point, making them available to browser users.
Reverting the Zod import in utils.ts fixes interoperability between Zod v3 and v4.
Adds the aws alias so hub/node can auto-detect ChatBedrockConverse from Python-serialized prompts.
Structured output using providerStrategy is supported for Google Gemini models in createAgent.
Fixes routing when an agent combines returnDirect tools with beforeModel middleware, preventing non-returnDirect tools from failing with an unknown or null destination.
Serializable schemas are now exposed on the create agent response format.
The todo schema is now exported for developers to use.
Structured output retry Commands are now propagated through wrapModelCall middleware.
Added a getter/setter that forwards checkpointer access to the internal compiled graph, fixing ignored LangGraph API server checkpointer injection and lost thread state across restarts.
The middleware runtime now receives store from the LangGraph config; previously, runtime.store was always undefined even when a store was provided to createAgent().
Middleware hooks now infer StateSchema value types correctly.
The shared currentSystemMessage is reset when a middleware handler retries.
Export the ModelRequest interface so developers can import and use it.
Persist underscore-prefixed middleware state fields across graph steps.
Fixed streaming types.
Fixed structured output on opus.
Subagent names are now propagated in metadata.
Supports concurrent dynamic prompts in agentNode.
Pregel keys are filtered from the cache key to avoid out-of-memory errors.
StateSchema is now supported in the middleware pipeline.
Middleware state parsing now correctly handles both Zod objects and LangGraph's StateSchema.
Graph interrupt errors are now bubbled up as-is.
Middleware errors use cause instead of concatenating the error, preserving the underlying cause.
createAgent state schemas now preserve reducer metadata.
Models now make only one write_todo call at a time.
The afterModel Router now uses parseJumpToTarget.
Message summarization now uses getBufferString, changing how messages are converted to summary input.
Summarization now preserves tool call and AIMessage pairings.
The schema title is now passed through properly.
Interop with Zod is improved.
Prevents functions from being accidentally assignable to AgentMiddleware.
Fixes patch prompts created from runs.
Structured output is now properly retrieved from a thinking block.
Uses summaryPrefix or falls back to the default prefix.
Invoke responses are detected better in agent nodes.
State rendering in LangSmith studio was improved.
Detection of models with native support for structured output was fixed.
AgentNode error handling behaviour was updated.
The toolEmulator middleware was improved.
langchain 0.32 changes
Security 1
Fixes CVE 2025 12735.
Fixes and other changes 1
Fixes the default temperature option for v0/anthropic.