Files
langgraphjs/libs/langgraph-swarm
dependabot[bot] a4919b667e chore(deps): bump the langchain group across 1 directory with 8 updates (#2476)
Bumps the langchain group with 8 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@langchain/anthropic](https://github.com/langchain-ai/langchainjs) |
`1.3.28` | `1.4.0` |
| [@langchain/core](https://github.com/langchain-ai/langchainjs) |
`1.1.44` | `1.1.48` |
| [langchain](https://github.com/langchain-ai/langchainjs) |
`1.4.0-dev-1777615538778` | `1.4.4` |
| [@langchain/openai](https://github.com/langchain-ai/langchainjs) |
`1.4.5` | `1.4.7` |
| [@langchain/groq](https://github.com/langchain-ai/langchainjs) |
`1.2.0` | `1.2.1` |
| [@langchain/mistralai](https://github.com/langchain-ai/langchainjs) |
`1.0.8` | `1.1.0` |
| [@langchain/classic](https://github.com/langchain-ai/langchainjs) |
`1.0.32` | `1.0.34` |
| [langsmith](https://github.com/langchain-ai/langsmith-sdk) | `0.6.0` |
`0.7.4` |


Updates `@langchain/anthropic` from 1.3.28 to 1.4.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/anthropic's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/anthropic</code><a
href="https://github.com/1"><code>@​1</code></a>.4.0</h2>
<h3>Minor Changes</h3>
<ul>
<li><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10777">#10777</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/0cfcfc66897d8fafeb7e7ed90b7299eace9a7c37"><code>0cfcfc6</code></a>
Thanks <a
href="https://github.com/jonaslalin"><code>@​jonaslalin</code></a>! -
feat(anthropic): support strict tool calling for custom tools</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/langchain-ai/langchainjs/commits/@langchain/anthropic@1.4.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `@langchain/core` from 1.1.44 to 1.1.48
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/core's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/core</code><a
href="https://github.com/1"><code>@​1</code></a>.1.48</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10832">#10832</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/1b24369a970ad6f56f1f428027f48601f87e62eb"><code>1b24369</code></a>
Thanks <a
href="https://github.com/info-arnav"><code>@​info-arnav</code></a>! -
fix(core, openrouter): make CJS default re-exports callable</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10666">#10666</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/2bb55b053f49f89e81e3252a7af08e86d71ddd95"><code>2bb55b0</code></a>
Thanks <a
href="https://github.com/hnustwjj"><code>@​hnustwjj</code></a>! -
feat(openrouter): surface reasoning content as v1 standard content
blocks</p>
<p><code>convertOpenRouterResponseToBaseMessage</code> and
<code>convertOpenRouterDeltaToBaseMessageChunk</code> now copy
OpenRouter's
<code>reasoning</code> (flat string) and <code>reasoning_details</code>
(structured array) fields
onto <code>additional_kwargs.reasoning_content</code> /
<code>additional_kwargs.reasoning_details</code>.
A new <code>ChatOpenRouterTranslator</code> is registered in
<code>@langchain/core</code> under
the <code>&quot;openrouter&quot;</code> provider key so
<code>AIMessage.contentBlocks</code> emits standard
<code>{type: &quot;reasoning&quot;}</code> blocks alongside text and
tool calls.</p>
<p>Previously, reasoning text returned by reasoning-capable models
routed
through OpenRouter (DeepSeek R1, Minimax M2, Claude extended thinking,
o-series, etc.) was silently dropped: only the
<code>reasoning_tokens</code> count
was preserved via <code>usage_metadata</code>. Consumers using standard
content blocks
(including the frontend agent UI patterns shown in the docs) could not
display the model's chain of thought.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10918">#10918</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/3999fab55870c6eea22d6d90c08aa472f9b2fac3"><code>3999fab</code></a>
Thanks <a
href="https://github.com/christian-bromann"><code>@​christian-bromann</code></a>!
- fix(openai): stream custom tool calls through Responses API chunks</p>
</li>
</ul>
<h2><code>@​langchain/core</code><a
href="https://github.com/1"><code>@​1</code></a>.1.47</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10906">#10906</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/f61b3450f275831e47e69c08899b4a2b67b4bdb3"><code>f61b345</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
feat(core): add uuid v6 utility support</p>
<p>Add <code>v6</code> UUID generation support to
<code>@langchain/core/utils/uuid</code> by vendoring the upstream uuidjs
<code>v6</code> implementation and its <code>v1ToV6</code> helper,
exporting <code>v6</code> from the UUID utils index, and adding tests
for deterministic generation, buffer/offset behavior,
validation/versioning, and ordering.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10872">#10872</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/a64007997a4940f51bba3c1c83dae89d1ccfb692"><code>a640079</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
chore(deps): remove redundant <code>@​types/uuid</code> declarations</p>
<p>Remove <code>@types/uuid</code> from package manifests that rely on
<code>@langchain/core/utils/uuid</code> or do not require uuid type
stubs directly, and refresh the lockfile entries accordingly.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10792">#10792</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/3682268cd1844b2573b01f07bee367e21cb7bdc7"><code>3682268</code></a>
Thanks <a href="https://github.com/Genmin"><code>@​Genmin</code></a>! -
fix(core): apply v1 message casting after implicit streaming
aggregation</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10901">#10901</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/f26fc4a6f461d6d0f86d59bd00197ad510432c4a"><code>f26fc4a</code></a>
Thanks <a
href="https://github.com/christian-bromann"><code>@​christian-bromann</code></a>!
- fix(testing): share fakeModel invocation state across bindTools
instances</p>
</li>
</ul>
<h2><code>@​langchain/core</code><a
href="https://github.com/1"><code>@​1</code></a>.1.46</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10847">#10847</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/1659e7d36e31e315c890fa98f43db887f7a2d52b"><code>1659e7d</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
chore(core): reduce transitive dependency exposure and tighten release
hygiene</p>
<p>Remove direct runtime dependencies on <code>ansi-styles</code>,
<code>camelcase</code>, and <code>decamelize</code>
by inlining equivalent logic in core internals, and enable npm
provenance in the
release workflow.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10790">#10790</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/ef78bc6a21f9a8808ba95c98db2023f0a6b51bcc"><code>ef78bc6</code></a>
Thanks <a href="https://github.com/Genmin"><code>@​Genmin</code></a>! -
fix(core): keep different content block types separate when merging
chunks</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/langchain-ai/langchainjs/commits/@langchain/core@1.1.48">compare
view</a></li>
</ul>
</details>
<br />

Updates `langchain` from 1.4.0-dev-1777615538778 to 1.4.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">langchain's
releases</a>.</em></p>
<blockquote>
<h2>langchain@1.4.2</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10900">#10900</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/6bbddca1f8f7f280583fd839bb40c00bf19a0d51"><code>6bbddca</code></a>
Thanks <a
href="https://github.com/christian-bromann"><code>@​christian-bromann</code></a>!
- fix(langchain): unwrap tool message outputs in agent streams</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10706">#10706</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/4ecb6606feae3156a07de67e39e2027f857c476e"><code>4ecb660</code></a>
Thanks <a
href="https://github.com/JadenKim-dev"><code>@​JadenKim-dev</code></a>!
- fix(langchain): set name on todoListMiddleware ToolMessages</p>
</li>
</ul>
<h2>langchain@1.4.1</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10879">#10879</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/eb480cb6df8e0fa792826155bfa00a6db4536444"><code>eb480cb</code></a>
Thanks <a
href="https://github.com/vignesh-gep"><code>@​vignesh-gep</code></a>! -
fix(langchain/createAgent): throw on terminal
<code>providerStrategy</code> parse failure instead of silently
resolving with <code>structuredResponse: undefined</code></p>
<p>When <code>createAgent</code> was configured with
<code>responseFormat</code> resolving to a <code>providerStrategy</code>
(either passed explicitly or auto-promoted from a bare Zod / JSON schema
for models whose profile reports <code>structuredOutput: true</code>),
and the model produced a terminal response (no <code>tool_calls</code>)
whose text could not be JSON-parsed or did not satisfy the schema, the
agent silently exited with no <code>structuredResponse</code>, surfacing
later as <code>TypeError: Cannot read properties of undefined</code>.
The agent now throws a <code>StructuredOutputParsingError</code> in that
case while still allowing the agent loop to continue when tool calls are
present. Closes <a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10878">#10878</a>.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10872">#10872</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/a64007997a4940f51bba3c1c83dae89d1ccfb692"><code>a640079</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
chore(deps): remove redundant <code>@​types/uuid</code> declarations</p>
<p>Remove <code>@types/uuid</code> from package manifests that rely on
<code>@langchain/core/utils/uuid</code> or do not require uuid type
stubs directly, and refresh the lockfile entries accordingly.</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10160">#10160</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/bba900c7c8781c7efec856d5d3e539a93f14e797"><code>bba900c</code></a>
Thanks <a
href="https://github.com/JadenKim-dev"><code>@​JadenKim-dev</code></a>!
- fix(langchain): prevent llmToolSelectorMiddleware from leaking into
message stream</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/langchain-ai/langchainjs/commits/@langchain/openai@1.4.4">compare
view</a></li>
</ul>
</details>
<br />

Updates `@langchain/openai` from 1.4.5 to 1.4.7
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/openai's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/openai</code><a
href="https://github.com/1"><code>@​1</code></a>.4.7</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10918">#10918</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/3999fab55870c6eea22d6d90c08aa472f9b2fac3"><code>3999fab</code></a>
Thanks <a
href="https://github.com/christian-bromann"><code>@​christian-bromann</code></a>!
- fix(openai): stream custom tool calls through Responses API chunks</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10791">#10791</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/fce9ab418901323618fdfaaa9fc350fa1c0d50e0"><code>fce9ab4</code></a>
Thanks <a href="https://github.com/Genmin"><code>@​Genmin</code></a>! -
fix(openai): preserve top-level Responses API ids on AI messages</p>
</li>
</ul>
<h2><code>@​langchain/openai</code><a
href="https://github.com/1"><code>@​1</code></a>.4.6</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10902">#10902</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/229a7ad67b9a7ebd8df3ca451e0b8195bea0190e"><code>229a7ad</code></a>
Thanks <a
href="https://github.com/christian-bromann"><code>@​christian-bromann</code></a>!
- fix(openai): preserve v1 assistant tool calls</p>
</li>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10895">#10895</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/36fb0ef1dc76c096dcfa0c777e10c9f9365a5240"><code>36fb0ef</code></a>
Thanks <a href="https://github.com/BertBR"><code>@​BertBR</code></a>! -
fix(openai): guard bare <code>JSON.parse</code> in Responses API
converter against trailing non-whitespace characters</p>
<p><code>convertResponsesDeltaToChatGenerationChunk</code> previously
called <code>JSON.parse(msg.text)</code> directly when
<code>response.text.format.type === &quot;json_schema&quot;</code>. Some
models (observed with <code>gpt-5-mini</code> on <code>service_tier:
&quot;auto&quot;</code>) intermittently emit trailing non-whitespace
characters (extra tokens, control characters) after a valid JSON object,
causing a <code>SyntaxError</code> that propagates as an unhandled
exception and kills the entire streaming response mid-flight. The parse
is now wrapped in a <code>try</code>/<code>catch</code>: on failure,
<code>additional_kwargs.parsed</code> is left undefined, the stream
completes normally, and the existing <code>withStructuredOutput</code>
pipeline handles the typed failure — <code>includeRaw: true</code>
returns <code>{ raw, parsed: null }</code> via its
<code>withFallbacks</code> wrapper, <code>includeRaw: false</code>
throws a typed <code>OutputParserException</code> that the caller can
catch and retry. Closes <a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10894">#10894</a>.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/langchain-ai/langchainjs/commits/@langchain/openai@1.4.7">compare
view</a></li>
</ul>
</details>
<br />

Updates `@langchain/groq` from 1.2.0 to 1.2.1
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/groq's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/groq</code><a
href="https://github.com/1"><code>@​1</code></a>.2.1</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10872">#10872</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/a64007997a4940f51bba3c1c83dae89d1ccfb692"><code>a640079</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
chore(deps): remove redundant <code>@​types/uuid</code> declarations</p>
<p>Remove <code>@types/uuid</code> from package manifests that rely on
<code>@langchain/core/utils/uuid</code> or do not require uuid type
stubs directly, and refresh the lockfile entries accordingly.</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/1b19e4f84d747b481879363b4884c20eb1c0f1a4"><code>1b19e4f</code></a>
chore: version packages (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10899">#10899</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/426e3aba21016d9ee070c3d130f74ae0047c9ce5"><code>426e3ab</code></a>
chore: fix uuid changeset (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10916">#10916</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/245c98216ce4a6c4340954711a7ad60203283424"><code>245c982</code></a>
chore(deps): bump fast-xml-builder from 1.1.5 to 1.2.0 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10914">#10914</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/126dac5a7a2fac5978448185893038ac8ea6d994"><code>126dac5</code></a>
chore(deps): bump brace-expansion from 5.0.5 to 5.0.6 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10912">#10912</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/1abe24becdddce94c5bd2acfaf920b60a683f22b"><code>1abe24b</code></a>
chore(deps): bump fast-uri from 3.1.0 to 3.1.2 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10913">#10913</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/229a7ad67b9a7ebd8df3ca451e0b8195bea0190e"><code>229a7ad</code></a>
fix(openai): preserve v1 assistant tool calls (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10902">#10902</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/f26fc4a6f461d6d0f86d59bd00197ad510432c4a"><code>f26fc4a</code></a>
fix(core): share fakeModel invocation state across bindTools instances
(<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10901">#10901</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/a0cd7477e59677c8d15e0e70b374afa0a2410582"><code>a0cd747</code></a>
chore(deps): bump fast-xml-builder from 1.1.5 to 1.1.9 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10910">#10910</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/b208e625865fc7487876b652f479dbf854263e68"><code>b208e62</code></a>
chore(deps): bump ip-address from 10.1.0 to 10.2.0 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10909">#10909</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/f7e50fb8b98bd9969c0f5cf0967a06df15453453"><code>f7e50fb</code></a>
feat(google): Service tier and custom headers (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10704">#10704</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/langchain-ai/langchainjs/compare/@langchain/groq@1.2.0...@langchain/groq@1.2.1">compare
view</a></li>
</ul>
</details>
<br />

Updates `@langchain/mistralai` from 1.0.8 to 1.1.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/mistralai's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/mistralai</code><a
href="https://github.com/1"><code>@​1</code></a>.1.0</h2>
<h3>Minor Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10873">#10873</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/a74d574f7f086bea2f5c7a852e869f7d24be2f55"><code>a74d574</code></a>
Thanks <a
href="https://github.com/baptistejamin"><code>@​baptistejamin</code></a>!
- chore(mistralai): upgrade to <code>@​mistralai/mistralai</code> v2</p>
<p>Also populates <code>response_metadata.model</code> on chat
completions (was missing before).</p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/caad0914f068477293009dbf27a220fa96bdc4b8"><code>caad091</code></a>
chore: version packages (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10919">#10919</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/f4a6149e3e754203f5886dd8c2bccaa7a6fd4f81"><code>f4a6149</code></a>
chore(deps): bump fast-uri from 3.1.0 to 3.1.2 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10926">#10926</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/7b12f6dfa537932073f96b561d7c851b30d69132"><code>7b12f6d</code></a>
chore(deps): bump protobufjs from 7.5.6 to 7.6.0 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10930">#10930</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/5c6c5fef0cb392e782675ca5926e291a4295a653"><code>5c6c5fe</code></a>
chore(deps): bump ws from 5.2.4 to 8.20.0 (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10915">#10915</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/a8652ceeb5e36434565c96fc1a6bd9a4a36304cc"><code>a8652ce</code></a>
docs: fix typos, add Ollama setup, update outdated references (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10922">#10922</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/2bb55b053f49f89e81e3252a7af08e86d71ddd95"><code>2bb55b0</code></a>
feat(openrouter): surface reasoning as v1 standard content blocks (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10666">#10666</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/4ecb6606feae3156a07de67e39e2027f857c476e"><code>4ecb660</code></a>
fix(langchain): set name on todoListMiddleware ToolMessages (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10706">#10706</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/20f27dff08a4bd5a1a16c1c71a88405c9df82914"><code>20f27df</code></a>
fix(ibm): handle API errors in streaming responses (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10721">#10721</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/45668734c3205e631cdd33ac071bbf733f4558c7"><code>4566873</code></a>
feat(ibm): add integration test to IBM implementation (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10732">#10732</a>)</li>
<li><a
href="https://github.com/langchain-ai/langchainjs/commit/6e4337fec1a7707c1a1c709a7b6aa0c5efb7b11d"><code>6e4337f</code></a>
fix(aws): add claude-haiku-4 to supportedToolChoiceValuesForModel (<a
href="https://redirect.github.com/langchain-ai/langchainjs/issues/10743">#10743</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/langchain-ai/langchainjs/compare/@langchain/classic@1.0.8...@langchain/mistralai@1.1.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `@langchain/classic` from 1.0.32 to 1.0.34
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchainjs/releases">@​langchain/classic's
releases</a>.</em></p>
<blockquote>
<h2><code>@​langchain/classic</code><a
href="https://github.com/1"><code>@​1</code></a>.0.34</h2>
<h3>Patch Changes</h3>
<ul>
<li>Updated dependencies [<a
href="https://github.com/langchain-ai/langchainjs/commit/3999fab55870c6eea22d6d90c08aa472f9b2fac3"><code>3999fab</code></a>,
<a
href="https://github.com/langchain-ai/langchainjs/commit/fce9ab418901323618fdfaaa9fc350fa1c0d50e0"><code>fce9ab4</code></a>]:
<ul>
<li><code>@​langchain/openai</code><a
href="https://github.com/1"><code>@​1</code></a>.4.7</li>
</ul>
</li>
</ul>
<h2><code>@​langchain/classic</code><a
href="https://github.com/1"><code>@​1</code></a>.0.33</h2>
<h3>Patch Changes</h3>
<ul>
<li>
<p><a
href="https://redirect.github.com/langchain-ai/langchainjs/pull/10872">#10872</a>
<a
href="https://github.com/langchain-ai/langchainjs/commit/a64007997a4940f51bba3c1c83dae89d1ccfb692"><code>a640079</code></a>
Thanks <a href="https://github.com/hntrl"><code>@​hntrl</code></a>! -
chore(deps): remove redundant <code>@​types/uuid</code> declarations</p>
<p>Remove <code>@types/uuid</code> from package manifests that rely on
<code>@langchain/core/utils/uuid</code> or do not require uuid type
stubs directly, and refresh the lockfile entries accordingly.</p>
</li>
<li>
<p>Updated dependencies [<a
href="https://github.com/langchain-ai/langchainjs/commit/229a7ad67b9a7ebd8df3ca451e0b8195bea0190e"><code>229a7ad</code></a>,
<a
href="https://github.com/langchain-ai/langchainjs/commit/36fb0ef1dc76c096dcfa0c777e10c9f9365a5240"><code>36fb0ef</code></a>]:</p>
<ul>
<li><code>@​langchain/openai</code><a
href="https://github.com/1"><code>@​1</code></a>.4.6</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/langchain-ai/langchainjs/commits/@langchain/classic@1.0.34">compare
view</a></li>
</ul>
</details>
<br />

Updates `langsmith` from 0.6.0 to 0.7.4
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langsmith-sdk/releases">langsmith's
releases</a>.</em></p>
<blockquote>
<h2>v0.7.4</h2>
<h2>What's Changed</h2>
<ul>
<li>fix(google-adk): add wrapt dependency by <a
href="https://github.com/QuentinBrosse"><code>@​QuentinBrosse</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2436">langchain-ai/langsmith-sdk#2436</a></li>
<li>chore: lock dependencies by <a
href="https://github.com/QuentinBrosse"><code>@​QuentinBrosse</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2439">langchain-ai/langsmith-sdk#2439</a></li>
<li>release(py): 0.7.4 by <a
href="https://github.com/QuentinBrosse"><code>@​QuentinBrosse</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2441">langchain-ai/langsmith-sdk#2441</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/langchain-ai/langsmith-sdk/compare/v0.7.3...v0.7.4">https://github.com/langchain-ai/langsmith-sdk/compare/v0.7.3...v0.7.4</a></p>
<h2>v0.7.3</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: propagate tracingEnabled to nested traceables by <a
href="https://github.com/hntrl"><code>@​hntrl</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2427">langchain-ai/langsmith-sdk#2427</a></li>
<li>chore(python): openai agents: delay span start for spans without
inputs on start event by <a
href="https://github.com/angus-langchain"><code>@​angus-langchain</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2424">langchain-ai/langsmith-sdk#2424</a></li>
<li>release(py): 0.7.3 by <a
href="https://github.com/angus-langchain"><code>@​angus-langchain</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2428">langchain-ai/langsmith-sdk#2428</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/langchain-ai/langsmith-sdk/compare/v0.7.2...v0.7.3">https://github.com/langchain-ai/langsmith-sdk/compare/v0.7.2...v0.7.3</a></p>
<h2>v0.7.2</h2>
<h2>What's Changed</h2>
<ul>
<li>release(js): 0.5.1 by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2389">langchain-ai/langsmith-sdk#2389</a></li>
<li>fix(js): Remove <a
href="https://github.com/internal"><code>@​internal</code></a> by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2391">langchain-ai/langsmith-sdk#2391</a></li>
<li>release(js): 0.5.2 by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2392">langchain-ai/langsmith-sdk#2392</a></li>
<li>chore(deps-dev): bump openai from 5.8.2 to 6.18.0 in /js by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2378">langchain-ai/langsmith-sdk#2378</a></li>
<li>chore(deps-dev): bump cross-env from 7.0.3 to 10.1.0 in /js by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2379">langchain-ai/langsmith-sdk#2379</a></li>
<li>chore(deps-dev): bump the js-minor-and-patch group in /js with 4
updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2376">langchain-ai/langsmith-sdk#2376</a></li>
<li>chore(deps-dev): bump node-fetch from 2.7.0 to 3.3.2 in /js by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2380">langchain-ai/langsmith-sdk#2380</a></li>
<li>Google ADK LangSmith tracing enhancements by <a
href="https://github.com/j-broekhuizen"><code>@​j-broekhuizen</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2394">langchain-ai/langsmith-sdk#2394</a></li>
<li>chore: update dependabot.yml to comply with posture checks by <a
href="https://github.com/jkennedyvz"><code>@​jkennedyvz</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2393">langchain-ai/langsmith-sdk#2393</a></li>
<li>chore(deps): bump cryptography from 46.0.3 to 46.0.5 in /python in
the uv group across 1 directory by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2397">langchain-ai/langsmith-sdk#2397</a></li>
<li>chore(deps-dev): bump the js-minor-and-patch group in /js with 6
updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2398">langchain-ai/langsmith-sdk#2398</a></li>
<li>chore(deps-dev): bump eslint-config-prettier from 8.10.0 to 10.1.8
in /js by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2399">langchain-ai/langsmith-sdk#2399</a></li>
<li>chore(deps): bump packaging from 25.0 to 26.0 in /python by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2403">langchain-ai/langsmith-sdk#2403</a></li>
<li>chore(deps-dev): bump pytest from 8.4.2 to 9.0.2 in /python by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2405">langchain-ai/langsmith-sdk#2405</a></li>
<li>chore(deps): bump the py-minor-and-patch group across 1 directory
with 20 updates by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2406">langchain-ai/langsmith-sdk#2406</a></li>
<li>fix(js): Log Vitest/Jest outputs even if test throws an error by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2408">langchain-ai/langsmith-sdk#2408</a></li>
<li>fix(js): Remove async by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2409">langchain-ai/langsmith-sdk#2409</a></li>
<li>release(js): 0.5.3 by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2410">langchain-ai/langsmith-sdk#2410</a></li>
<li>fix: ignoring p-queue dep by <a
href="https://github.com/jkennedyvz"><code>@​jkennedyvz</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2414">langchain-ai/langsmith-sdk#2414</a></li>
<li>feat(js): add feedback config CRUD and annotation queue rubric items
(closes LSPE-67) by <a
href="https://github.com/bentanny"><code>@​bentanny</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2420">langchain-ai/langsmith-sdk#2420</a></li>
<li>fix(js): Add on_start handler for traceable, use in evaluate by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2421">langchain-ai/langsmith-sdk#2421</a></li>
<li>release(js): 0.5.4 by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2422">langchain-ai/langsmith-sdk#2422</a></li>
<li>feat(python): add feedback config CRUD and annotation queue rubric
items (closes LSPE-67) by <a
href="https://github.com/bentanny"><code>@​bentanny</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2419">langchain-ai/langsmith-sdk#2419</a></li>
<li>feat(python): add exceptions_to_handle to <a
href="https://github.com/traceable"><code>@​traceable</code></a> by <a
href="https://github.com/QuentinBrosse"><code>@​QuentinBrosse</code></a>
in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2423">langchain-ai/langsmith-sdk#2423</a></li>
<li>release(py): 0.7.2 by <a
href="https://github.com/jacoblee93"><code>@​jacoblee93</code></a> in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2426">langchain-ai/langsmith-sdk#2426</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/j-broekhuizen"><code>@​j-broekhuizen</code></a>
made their first contribution in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2394">langchain-ai/langsmith-sdk#2394</a></li>
<li><a href="https://github.com/bentanny"><code>@​bentanny</code></a>
made their first contribution in <a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/pull/2420">langchain-ai/langsmith-sdk#2420</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/1132e6ce6391d08158a93acb5c96b90521ac3230"><code>1132e6c</code></a>
release(py): 0.7.4 (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2441">#2441</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/8c7cc783806e4a6d71300982d58ecb3c9bc658cd"><code>8c7cc78</code></a>
chore: lock dependencies (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2439">#2439</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/62c256ea56fdee0bc539275c749a427e510ded8f"><code>62c256e</code></a>
fix(google-adk): add wrapt dependency (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2436">#2436</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/e32d4c18a681553f47c93350f03dc0a0f0cc4890"><code>e32d4c1</code></a>
release(py): 0.7.3 (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2428">#2428</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/1c51bf881dafaeb01432db629de7cafaabca79dc"><code>1c51bf8</code></a>
chore(python): openai agents: delay span start for spans without inputs
on st...</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/a41bf22dadaea489a156dc06a9d0fbf1a977ff6d"><code>a41bf22</code></a>
fix: propagate tracingEnabled to nested traceables (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2427">#2427</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/3a6e9dac4bf3a940f7ee47e420cc1422f9f4a4b4"><code>3a6e9da</code></a>
release(py): 0.7.2 (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2426">#2426</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/f665e865e7ab7a0ba1de447f2a1cf14c719af00a"><code>f665e86</code></a>
feat(python): add exceptions_to_handle to <a
href="https://github.com/traceable"><code>@​traceable</code></a> (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2423">#2423</a>)</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/565c4a2c5769e698ecffbf7f43131ff9cc467f8d"><code>565c4a2</code></a>
feat(python): add feedback config CRUD and annotation queue rubric items
(clo...</li>
<li><a
href="https://github.com/langchain-ai/langsmith-sdk/commit/e1b1fe13c382371ebe4cffa1b95eba3bf74e2f37"><code>e1b1fe1</code></a>
release(js): 0.5.4 (<a
href="https://redirect.github.com/langchain-ai/langsmith-sdk/issues/2422">#2422</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/langchain-ai/langsmith-sdk/compare/v0.6.0...v0.7.4">compare
view</a></li>
</ul>
</details>
<br />

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: John Kennedy <jkennedyvz@users.noreply.github.com>
2026-06-03 19:51:50 -07:00
..
2026-05-18 22:47:09 +00:00
2025-03-03 22:35:57 +00:00
2025-03-03 22:35:57 +00:00
2025-10-17 16:34:43 -07:00
2025-07-02 02:35:57 +02:00

🤖 LangGraph Multi-Agent Swarm

A JavaScript library for creating swarm-style multi-agent systems using LangGraph. A swarm is a type of multi-agent architecture where agents dynamically hand off control to one another based on their specializations. The system remembers which agent was last active, ensuring that on subsequent interactions, the conversation resumes with that agent.

Swarm

Note

This library has been updated to support LangChain 1.0. However, it has not been tested with the new agents in langchain. The library currently only supports the prebuilt createReactAgent from LangGraph. This update allows users to migrate to LangChain 1.0 without changing their existing code. For users of the swarm package, we recommend continuing to use createReactAgent rather than the new createAgent pattern from LangChain for now.

Features

  • 🤖 Multi-agent collaboration - Enable specialized agents to work together and hand off context to each other
  • 🛠️ Customizable handoff tools - Built-in tools for communication between agents

This library is built on top of LangGraph, a powerful framework for building agent applications, and comes with out-of-box support for streaming, short-term and long-term memory and human-in-the-loop

Installation

npm install @langchain/langgraph-swarm @langchain/langgraph @langchain/core

Quickstart

npm install @langchain/langgraph-swarm @langchain/langgraph @langchain/core @langchain/openai

export OPENAI_API_KEY=<your_api_key>
import { z } from "zod";
import { ChatOpenAI } from "@langchain/openai";
import { tool, createAgent } from "langchain";
import { MemorySaver } from "@langchain/langgraph";
import { createSwarm, createHandoffTool } from "@langchain/langgraph-swarm";

const model = new ChatOpenAI({ modelName: "gpt-4o" });

// Create specialized tools
const add = tool(
  async (args) => args.a + args.b,
  {
    name: "add",
    description: "Add two numbers.",
    schema: z.object({
      a: z.number(),
      b: z.number()
    })
  }
);

// Create agents with handoff tools
const alice = createAgent({
  llm: model,
  tools: [add, createHandoffTool({ agentName: "Bob" })],
  name: "Alice",
  prompt: "You are Alice, an addition expert."
});

const bob = createAgent({
  llm: model,
  tools: [createHandoffTool({ 
    agentName: "Alice", 
    description: "Transfer to Alice, she can help with math" 
  })],
  name: "Bob",
  prompt: "You are Bob, you speak like a pirate."
});

// Create swarm workflow
const checkpointer = new MemorySaver();
const workflow = createSwarm({
  agents: [alice, bob],
  defaultActiveAgent: "Alice"
});

export const app = workflow.compile({ 
  checkpointer 
});

const config = { configurable: { thread_id: "1" } };
const turn1 = await app.invoke(
  { messages: [{ role: "user", content: "i'd like to speak to Bob" }] },
  config
);
console.log(turn1);

const turn2 = await app.invoke(
  { messages: [{ role: "user", content: "what's 5 + 7?" }] },
  config
);
console.log(turn2);

Memory

You can add short-term and long-term memory to your swarm multi-agent system. Since createSwarm() returns an instance of StateGraph that needs to be compiled before use, you can directly pass a checkpointer or a store instance to the .compile() method:

import { MemorySaver, InMemoryStore } from "@langchain/langgraph";

// short-term memory
const checkpointer = new MemorySaver()
// long-term memory
const store = new InMemoryStore()

alice = ...
bob = ...

const workflow = createSwarm({
  agents: [alice, bob],
  defaultActiveAgent: "Alice",
})

// Compile with checkpointer/store
const app = workflow.compile({
  checkpointer,
  store
})

Important

Adding short-term memory is crucial for maintaining conversation state across multiple interactions. Without it, the swarm would "forget" which agent was last active and lose the conversation history. Make sure to always compile the swarm with a checkpointer if you plan to use it in multi-turn conversations; e.g., workflow.compile(checkpointer=checkpointer).

How to customize

You can customize multi-agent swarm by changing either the handoff tools implementation or the agent implementation.

Customizing handoff tools

By default, the agents in the swarm are assumed to use handoff tools created with the prebuilt createHandoffTool. You can also create your own, custom handoff tools. Here are some ideas on how you can modify the default implementation:

  • change tool name and/or description
  • add tool call arguments for the LLM to populate, for example a task description for the next agent
  • change what data is passed to the next agent as part of the handoff: by default create_handoff_tool passes full message history (all of the messages generated in the swarm up to this point), as well as the contents of Command.update to the next agent

Important

If you want to change what messages are passed to the next agent, you must use a different state schema key for messages in your agent implementation (e.g., alice_messages). By default, all agent (subgraph) state updates are applied to the swarm (parent) graph state during the handoff. Since all of the agents by default are assumed to communicate over a single messages key, this means that the agent's messages are automatically combined into the parent graph's messages, unless an agent uses a different key for messages. See more on this in the customizing agent implementation section.

Here is an example of what a custom handoff tool might look like:

import { z } from "zod";
import { BaseMessage, ToolMessage } from "@langchain/core/messages";
import { tool } from "@langchain/core/tools";
import { Command, getCurrentTaskInput } from "@langchain/langgraph";

const createCustomHandoffTool = ({
  agentName,
  toolName,
  toolDescription,
}: {
  agentName: string;
  toolName: string;
  toolDescription: string;
}) => {

  const handoffTool = tool(
    async (args, config) => {
      const toolMessage = new ToolMessage({
        content: `Successfully transferred to ${agentName}`,
        name: toolName,
        tool_call_id: config.toolCall.id,
      });

      // you can use a different messages state key here, if your agent uses a different schema
      // e.g., "alice_messages" instead of "messages"
      // see this how-to guide for more details: 
      // https://langchain-ai.github.io/langgraphjs/how-tos/pass-run-time-values-to-tools/
      const { messages } = (getCurrentTaskInput() as { messages: BaseMessage[] });
      const lastAgentMessage = messages[messages.length - 1];
      return new Command({
        goto: agentName,
        graph: Command.PARENT,
        // NOTE: this is a state update that will be applied to the swarm multi-agent graph (i.e., the PARENT graph)
        update: {
          messages: [lastAgentMessage, toolMessage],
          activeAgent: agentName,
          // optionally pass the task description to the next agent
          taskDescription: args.taskDescription,
        },
      });
    },
    {
      name: toolName,
      schema: z.object({
        // you can add additional tool call arguments for the LLM to populate
        // for example, you can ask the LLM to populate a task description for the next agent
        taskDescription: z.string().describe("Detailed description of what the next agent should do, including all of the relevant context")
      }),
      description: toolDescription,
    }
  );

  return handoffTool;
}

Important

If you are implementing custom handoff tools that return Command, you need to ensure that:
(1) your agent has a tool-calling node that can handle tools returning Command (like LangGraph's prebuilt ToolNode) (2) both the swarm graph and the next agent graph have the state schema containing the keys you want to update in Command.update

Customizing agent implementation

By default, individual agents are expected to communicate over a single messages key that is shared by all agents and the overall multi-agent swarm graph. This means that all of the messages from all of the agents will be combined into a single, shared list of messages. This might not be desirable if you don't want to expose an agent's internal history of messages. To change this, you can customize the agent by taking the following steps:

  1. use custom state schema with a different key for messages, for example alice_messages
  2. write a wrapper that converts the parent graph state to the child agent state and back (see this how-to guide)
import { BaseMessage } from "@langchain/core/messages";
import { Annotation, StateGraph, messagesStateReducer } from "@langchain/langgraph";

export const AliceStateAnnotation = Annotation.Root({
  alice_messages: Annotation<BaseMessage[]>({
    reducer: messagesStateReducer,
    default: () => [],
  }),
});
import { SwarmState } from "@langchain/langgraph-swarm";

// see this guide to learn how you can implement a custom tool-calling agent
// https://langchain-ai.github.io/langgraphjs/how-tos/react-agent-from-scratch/
const alice = (
    new StateGraph(AliceStateAnnotation)
    .addNode("model", ...)
    .addNode("tools", ...)
    .addEdge(...)
    ...
    .compile()
)

// wrapper calling the agent
const callAlice = async (state: typeof SwarmState.State) => {
    // you can put any input transformation from parent state -> agent state
    // for example, you can invoke "alice" with "task_description" populated by the LLM
    const response = await alice.invoke({"alice_messages": state["messages"]})
    // you can put any output transformation from agent state -> parent state
    return { "messages": response.alice_messages }
}

const callBob = async (state: typeof SwarmState.State) => {
    ...
}

Then, you can create the swarm manually in the following way:

import { addActiveAgentRouter } from "@langchain/langgraph-swarm";

let workflow = (
    new StateGraph(SwarmState)
    .addNode("Alice", callAlice, { ends: ["Bob"] })
    .addNode("Bob", callBob, { ends: ["Alice"] })
)
// this is the router that enables us to keep track of the last active agent
workflow = addActiveAgentRouter(workflow, {
    routeTo: ["Alice", "Bob"],
    defaultActiveAgent: "Alice",
})

// compile the workflow
const app = workflow.compile()