Skip to content

Conversation

@eyurtsev
Copy link
Collaborator

Overview

Type of change

Type: [Replace with: New documentation page / Update existing documentation / Fix typo/bug/link/formatting / Remove outdated content / Other]

Related issues/PRs

  • GitHub issue:
  • Feature PR:
  • Linear issue:
  • Slack thread:

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed

(Internal team members only / optional): Create a preview deployment as necessary using the Create Preview Branch workflow

Additional notes

@github-actions github-actions bot added langchain For docs changes to LangChain oss internal labels Dec 15, 2025
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-eugene-1765835478-b5aff5c

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-eugene-1765853807-d9a7052

@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-eugene-1765856625-d223354

@eyurtsev eyurtsev marked this pull request as ready for review December 16, 2025 03:47
@eyurtsev eyurtsev requested a review from lnhsingh as a code owner December 16, 2025 03:47
Copilot AI review requested due to automatic review settings December 16, 2025 03:47
@eyurtsev eyurtsev merged commit 7021123 into sr/multi-agent-new-docs Dec 16, 2025
13 checks passed
@eyurtsev eyurtsev deleted the eugene/state_machine branch December 16, 2025 03:47
@github-actions
Copy link
Contributor

Mintlify preview ID generated: preview-eugene-1765856913-998ebf6

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the "State machine" pattern documentation to align it with the "handoffs" terminology and expand the implementation approaches. The changes clarify that state machines can be implemented using either middleware-based configuration changes or multi-agent subgraphs with handoff tools, providing a more comprehensive view of this architectural pattern.

Key changes:

  • Renamed the "State machine" section to "State machine (handoffs)" to align with industry terminology
  • Expanded documentation to cover both single-agent-with-middleware and multiple-agent-subgraphs implementations
  • Added comprehensive code examples for both Python and TypeScript showing handoff patterns
  • Updated the pattern description table and internal references throughout the document
  • Removed a comparative Tip from the customer-support-state-machine tutorial that was no longer accurate

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/oss/langchain/multi-agent.mdx Updated state machine pattern documentation: renamed heading to include "(handoffs)", updated table description, added new section on multiple agent subgraphs with complete examples, updated link references, changed diagram from state machine to sequence diagram, revised key characteristics, and improved warning text about stateful routers
src/oss/langchain/customer-support-state-machine.mdx Removed outdated Tip block comparing state machine efficiency to handoff-based approaches since the parent document now presents handoffs as a valid implementation approach


<Warning>
**This is challenging.** Maintaining coherent history across multiple agents is difficult, especially when agents run in parallel. Agents can become confused about context or produce inconsistent responses. Synthesizing results also becomes harder—you need to track which agents have responded and how to combine partial results across turns. Consider the [state machine pattern](#state-machine) or [subagents pattern](#subagents) instead—both are simpler to reason about.
**Stateful routers require custom history management.** If the router switches between agents across turns, conversations may not feel fluid to end users when agents have different tones or prompts. With parallel invocation, you'll need to maintain history at the router level (inputs and synthesized outputs) and leverage this history in routing logic. Consider the [state machine pattern](#state-machine) or [subagents pattern](#subagents) instead—both provide clearer semantics for multi-turn conversations.
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor link #state-machine does not match the actual heading "State machine (handoffs)" which creates the anchor #state-machine-handoffs. Update this link to use the correct anchor.

Suggested change
**Stateful routers require custom history management.** If the router switches between agents across turns, conversations may not feel fluid to end users when agents have different tones or prompts. With parallel invocation, you'll need to maintain history at the router level (inputs and synthesized outputs) and leverage this history in routing logic. Consider the [state machine pattern](#state-machine) or [subagents pattern](#subagents) instead—both provide clearer semantics for multi-turn conversations.
**Stateful routers require custom history management.** If the router switches between agents across turns, conversations may not feel fluid to end users when agents have different tones or prompts. With parallel invocation, you'll need to maintain history at the router level (inputs and synthesized outputs) and leverage this history in routing logic. Consider the [state machine pattern](#state-machine-handoffs) or [subagents pattern](#subagents) instead—both provide clearer semantics for multi-turn conversations.

Copilot uses AI. Check for mistakes.
</Tip>

**Common mechanisms:** These patterns share common mechanisms for coordinating multi-agent behavior. Most rely on **tool calling** as the primary coordination mechanism—tools can invoke subagents ([subagents](#subagents)), update state to trigger routing or behavior changes ([state machine](#state-machine)), load context on-demand ([skills](#skills)), or even invoke entire multi-agent systems (like wrapping a [router](#router) as a tool).
**Common mechanisms:** These patterns share common mechanisms for coordinating multi-agent behavior. Most rely on **tool calling** as the primary coordination mechanism—tools can invoke sub-agents ([supervisor](#supervisor)), update state to trigger routing or behavior changes ([state machine](#state-machine-handoffs)), load context on-demand ([skills](#skills)), or even invoke entire multi-agent systems (like wrapping a [router](#router) as a tool).
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor link #supervisor references a section that doesn't exist on this page. Based on the context and the structure of the document, this should likely link to #subagents instead, since "supervisor" is mentioned as an alternative name for the main agent in the subagents pattern.

Suggested change
**Common mechanisms:** These patterns share common mechanisms for coordinating multi-agent behavior. Most rely on **tool calling** as the primary coordination mechanism—tools can invoke sub-agents ([supervisor](#supervisor)), update state to trigger routing or behavior changes ([state machine](#state-machine-handoffs)), load context on-demand ([skills](#skills)), or even invoke entire multi-agent systems (like wrapping a [router](#router) as a tool).
**Common mechanisms:** These patterns share common mechanisms for coordinating multi-agent behavior. Most rely on **tool calling** as the primary coordination mechanism—tools can invoke sub-agents ([supervisor](#subagents)), update state to trigger routing or behavior changes ([state machine](#state-machine-handoffs)), load context on-demand ([skills](#skills)), or even invoke entire multi-agent systems (like wrapping a [router](#router) as a tool).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal langchain For docs changes to LangChain oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants