fix(sdk): reconnect v2 SSE and WebSocket thread streams after disconnect#2462
Merged
Christian Bromann (christian-bromann) merged 6 commits intoJun 11, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: e560c72 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@langchain/langgraph-checkpoint
@langchain/langgraph-checkpoint-mongodb
@langchain/langgraph-checkpoint-postgres
@langchain/langgraph-checkpoint-redis
@langchain/langgraph-checkpoint-sqlite
@langchain/langgraph-checkpoint-validation
create-langgraph
@langchain/langgraph-api
@langchain/langgraph-cli
@langchain/langgraph
@langchain/langgraph-cua
@langchain/langgraph-supervisor
@langchain/langgraph-swarm
@langchain/langgraph-ui
@langchain/langgraph-sdk
@langchain/angular
@langchain/react
@langchain/svelte
@langchain/vue
commit: |
Add automatic reconnect with resume for protocol transports, route HTTP through AsyncCaller from client.threads.stream, and add integration tests for client.threads.stream + run.start against a mock langgraph-api server.
Co-authored-by: Cursor <cursoragent@cursor.com>
69de1a7 to
c60c62c
Compare
Contributor
There was a problem hiding this comment.
Open SWE Review found no issues in the changed lines.
🔍 2 out-of-diff findings
These relate to code outside this PR's changed lines.
- 🟡 Latest checkpoint delta history is empty —
libs/checkpoint/src/memory.ts lines 570-571
When callers request delta-channel history with the normal “latest checkpoint for this thread” config (nocheckpoint_id),checkpointIdis empty here, sotargetEntryis forced toundefinedand the parent-chain walk never starts. The base implementation first resolvesgetTuple(config), which handles the no-checkpoint_idcase by selecting the latest checkpoint, but this optimized override skips that behavior. As a result, MemorySaver reconstructs delta channels from{ configurable: { thread_id } }with no ancestor writes, so hydrated delta-channel state can be silently empty/stale even though the latest checkpoint has persisted history. - 🟡 Idle hydrated threads miss remote runs —
libs/sdk/src/stream/controller.ts line 709
This defers the root pump whenevergetState()says the thread is currently idle. That works for a purely local nextsubmit(), but it removes the always-on subscription that previously observed server-side runs started elsewhere after the UI mounted. For an existing idle thread opened in one tab/client, a run started from another client has no localsubmit()to call#startDeferredRootPump, so this controller never subscribes andisLoading, messages, values, interrupts, and discovery state stay stale until a reload/manual action.
17c44a3
into
main
29 of 30 checks passed
Christian Bromann (christian-bromann)
pushed a commit
that referenced
this pull request
Jun 11, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @langchain/langgraph-supervisor@1.1.0 ### Minor Changes - [#2521](#2521) [`56682a6`](56682a6) Thanks [@open-swe](https://github.com/apps/open-swe)! - feat(langgraph-supervisor): Add `addHandoffMessages` to `createSupervisor` and `createHandoffTool`, allowing supervisor-to-agent handoff bookkeeping messages to be omitted from the expert agent's message history. When `addHandoffBackMessages` is not provided, it now defaults to the same value as `addHandoffMessages`, matching the Python package behavior. `createHandoffTool` now also accepts `description` as the preferred option name while continuing to support the existing `agentDescription` option as deprecated for backwards compatibility. ### Patch Changes - [#2407](#2407) [`59d4765`](59d4765) Thanks [@pragnyanramtha](https://github.com/pragnyanramtha)! - Normalize all whitespace in supervisor handoff tool names. ## @langchain/langgraph@1.4.1 ### Patch Changes - [#2520](#2520) [`2da5c33`](2da5c33) Thanks [@christian-bromann](https://github.com/christian-bromann)! - fix(state): validate Zod state updates from nodes Validate node return values and Command updates against Zod state schema constraints before applying them to graph state. Fixes [#2519](#2519) - [#2511](#2511) [`ef04db3`](ef04db3) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(ToolNode): forward graph state to tools via `runtime.state` `ToolNode` now forwards its input to each tool through the second argument as `runtime.state`. When using `ToolNode` as a node in a LangGraph graph, this gives tools access to the current graph state for workflows that need tool-call support in LangGraph proper. Tools can type the second parameter as `ToolRuntime<StateType>` from `@langchain/core/tools` and read `runtime.state` directly. This works in every runtime, including web browsers, and removes the need for `getCurrentTaskInput()` (which relies on `node:async_hooks`/`AsyncLocalStorage`). `getCurrentTaskInput(config)` continues to work for backwards compatibility. - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 ## @langchain/langgraph-sdk@1.9.21 ### Patch Changes - [#2522](#2522) [`3855985`](3855985) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(stream): add per-event side-effect selector Add `useChannelEffect` (React/Svelte/Vue) / `injectChannelEffect` (Angular), a side-effect counterpart to `useChannel` that invokes an `onEvent` callback once per raw protocol event without re-rendering. This is the idiomatic v1 replacement for the old `onLangChainEvent` / `onCustomEvent` callbacks for analytics and logging. Backed by a new framework-agnostic `acquireChannelEffect` helper in `@langchain/langgraph-sdk/stream` that shares a ref-counted subscription with matching `useChannel` consumers. - [#2523](#2523) [`7c3e9e9`](7c3e9e9) Thanks [@christian-bromann](https://github.com/christian-bromann)! - fix(sdk): stop re-streaming seeded messages on idle-thread submit An idle (finished) thread defers its root SSE pump, so the first `submit()` brings it up and the transport replays the finished run from `seq=0`. The replayed `messages` channel carries no step (unlike `values`, guarded by `maxStep`), so it rebuilt each already-complete message from an empty `message-start` and re-streamed the whole turn token-by-token — a visible "messages replay" of the existing conversation. Seal the message ids seeded from the idle `getState()` snapshot so replayed deltas can't downgrade the complete tail; the seal lifts once a newer checkpoint advances the timeline or on thread rebind, and ids from the next run are never sealed. - [#2462](#2462) [`17c44a3`](17c44a3) Thanks [@christian-bromann](https://github.com/christian-bromann)! - fix(sdk): reconnect v2 SSE and WebSocket thread streams after disconnect Add automatic reconnect with resume (`since` for SSE) for protocol transports, wire `AsyncCaller` through `client.threads.stream`, and expose optional reconnect tuning on `ThreadStreamOptions`. Includes integration tests against an in-process mock langgraph-api server. ## @langchain/angular@1.0.22 ### Patch Changes - [#2522](#2522) [`3855985`](3855985) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(stream): add per-event side-effect selector Add `useChannelEffect` (React/Svelte/Vue) / `injectChannelEffect` (Angular), a side-effect counterpart to `useChannel` that invokes an `onEvent` callback once per raw protocol event without re-rendering. This is the idiomatic v1 replacement for the old `onLangChainEvent` / `onCustomEvent` callbacks for analytics and logging. Backed by a new framework-agnostic `acquireChannelEffect` helper in `@langchain/langgraph-sdk/stream` that shares a ref-counted subscription with matching `useChannel` consumers. - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 ## @langchain/react@1.0.22 ### Patch Changes - [#2522](#2522) [`3855985`](3855985) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(stream): add per-event side-effect selector Add `useChannelEffect` (React/Svelte/Vue) / `injectChannelEffect` (Angular), a side-effect counterpart to `useChannel` that invokes an `onEvent` callback once per raw protocol event without re-rendering. This is the idiomatic v1 replacement for the old `onLangChainEvent` / `onCustomEvent` callbacks for analytics and logging. Backed by a new framework-agnostic `acquireChannelEffect` helper in `@langchain/langgraph-sdk/stream` that shares a ref-counted subscription with matching `useChannel` consumers. - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 ## @langchain/svelte@1.0.22 ### Patch Changes - [#2522](#2522) [`3855985`](3855985) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(stream): add per-event side-effect selector Add `useChannelEffect` (React/Svelte/Vue) / `injectChannelEffect` (Angular), a side-effect counterpart to `useChannel` that invokes an `onEvent` callback once per raw protocol event without re-rendering. This is the idiomatic v1 replacement for the old `onLangChainEvent` / `onCustomEvent` callbacks for analytics and logging. Backed by a new framework-agnostic `acquireChannelEffect` helper in `@langchain/langgraph-sdk/stream` that shares a ref-counted subscription with matching `useChannel` consumers. - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 ## @langchain/vue@1.0.22 ### Patch Changes - [#2522](#2522) [`3855985`](3855985) Thanks [@christian-bromann](https://github.com/christian-bromann)! - feat(stream): add per-event side-effect selector Add `useChannelEffect` (React/Svelte/Vue) / `injectChannelEffect` (Angular), a side-effect counterpart to `useChannel` that invokes an `onEvent` callback once per raw protocol event without re-rendering. This is the idiomatic v1 replacement for the old `onLangChainEvent` / `onCustomEvent` callbacks for analytics and logging. Backed by a new framework-agnostic `acquireChannelEffect` helper in `@langchain/langgraph-sdk/stream` that shares a ref-counted subscription with matching `useChannel` consumers. - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 ## @example/ai-elements@0.1.37 ### Patch Changes - Updated dependencies \[[`3855985`](3855985), [`2da5c33`](2da5c33), [`ef04db3`](ef04db3)]: - @langchain/react@1.0.22 - @langchain/langgraph@1.4.1 ## @examples/assistant-ui-claude@0.1.37 ### Patch Changes - Updated dependencies \[[`3855985`](3855985), [`2da5c33`](2da5c33), [`ef04db3`](ef04db3)]: - @langchain/react@1.0.22 - @langchain/langgraph@1.4.1 ## @examples/ui-angular@0.0.47 ### Patch Changes - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`2da5c33`](2da5c33), [`ef04db3`](ef04db3), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 - @langchain/angular@1.0.22 - @langchain/langgraph@1.4.1 ## @examples/ui-multimodal@0.0.23 ### Patch Changes - Updated dependencies \[[`3855985`](3855985), [`2da5c33`](2da5c33), [`ef04db3`](ef04db3)]: - @langchain/react@1.0.22 - @langchain/langgraph@1.4.1 ## @examples/ui-react@0.0.23 ### Patch Changes - Updated dependencies \[[`3855985`](3855985), [`7c3e9e9`](7c3e9e9), [`2da5c33`](2da5c33), [`ef04db3`](ef04db3), [`17c44a3`](17c44a3)]: - @langchain/langgraph-sdk@1.9.21 - @langchain/react@1.0.22 - @langchain/langgraph@1.4.1 ## langgraph@1.0.41 ### Patch Changes - Updated dependencies \[[`2da5c33`](2da5c33), [`ef04db3`](ef04db3)]: - @langchain/langgraph@1.4.1 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ProtocolSseTransportAdapterandProtocolWebSocketTransportAdapter(resume viasinceon SSE, full buffer replay on WebSocket, withMaxWebSocketReconnectAttemptsErrorwhen the budget is exceeded).AsyncCallerand reconnect defaults throughclient.threads.stream, with optionalmaxReconnectAttempts,reconnectDelayMs, andonReconnectonThreadStreamOptions.fetchis passed (test/mocks), and addpnpm test:intintegration tests usingclient.threads.stream+run.startagainst an in-process mock server.