Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(wip) docs: revamp conceptual docs #1663

Merged
merged 28 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2dd77ec
docs: revamp conceptual docs
vbarda Sep 9, 2024
83c3a63
multi-agent draft
vbarda Sep 9, 2024
f3625ff
typo
vbarda Sep 9, 2024
76be9d5
Update Why LangGraph page
rlancemartin Sep 11, 2024
7ab5b16
Merge branch 'main' into vb/revamp-conceptual-docs
vbarda Sep 12, 2024
d18bbbb
update multi-agent
vbarda Sep 12, 2024
fcb0b52
Update persistence page
rlancemartin Sep 13, 2024
c590bed
update
vbarda Sep 13, 2024
8b554f8
Merge branch 'vb/revamp-conceptual-docs' of github.com:langchain-ai/l…
vbarda Sep 13, 2024
7128b45
Clarification of graph re-playing
rlancemartin Sep 13, 2024
1e3aacc
Merge branch 'vb/revamp-conceptual-docs' of https://github.com/langch…
rlancemartin Sep 13, 2024
a0915ba
update persistence
vbarda Sep 13, 2024
e3e1788
more updates
vbarda Sep 13, 2024
747b860
more updates
vbarda Sep 13, 2024
a1e61bf
Add multiple schemas section to glossary
rlancemartin Sep 13, 2024
56adee7
Merge branch 'vb/revamp-conceptual-docs' of github.com:langchain-ai/l…
vbarda Sep 13, 2024
734c87c
more updates
vbarda Sep 13, 2024
8594829
Clarify I/O schema
rlancemartin Sep 13, 2024
6d56062
Merge branch 'vb/revamp-conceptual-docs' of https://github.com/langch…
rlancemartin Sep 13, 2024
826f3e6
dynamic breakpoints
vbarda Sep 13, 2024
d0b7a8d
Update agentic concepts
rlancemartin Sep 13, 2024
d46ca18
Merge branch 'vb/revamp-conceptual-docs' of https://github.com/langch…
rlancemartin Sep 13, 2024
a3db898
Fix comments
rlancemartin Sep 13, 2024
095a9fb
Update figureds
rlancemartin Sep 16, 2024
443fc19
Merge branch 'main' into vb/revamp-conceptual-docs
hwchase17 Sep 16, 2024
7c61752
cr
hwchase17 Sep 17, 2024
3fab51f
cr
hwchase17 Sep 17, 2024
e2bc7a0
cr
hwchase17 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
multi-agent draft
vbarda committed Sep 9, 2024
commit 83c3a6329336cfd6114ad80791fdf8aeb8fcf849
44 changes: 43 additions & 1 deletion docs/docs/concepts/multi_agent.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# TODO: populate this (VB)
# What is a multi-agent architecture?

A multi-agent architecture is a system with multiple LLM-based components. These components can be as simple as a prompt and an LLM call, or as complex as a ReAct agent.

The primary advantages of this architecture are:

* **Modularity**: Separate agents facilitate easier development, testing, and maintenance of agentic systems.
* **Specialization**: Developers can create expert agents focused on specific domains, and compose them into more complex applications

## Types of multi-agent architectures in LangGraph

### Agents as nodes

Agents can be defined as nodes in LangGraph. As any other node in the LangGraph, these agent nodes receive the graph state as an input and return an update to the state as their output.

* Simple LLM nodes: single LLMs with custom prompts
* Subgraph nodes: complex graphs called inside the orchestrator graph node

### Agents as tools

Agents can also be defined as tools. In this case, the orchestrator agent (e.g. ReAct agent) would use a tool-calling LLM to decide which of the agent tools to call.

You could also take a "mega-graph" approach – incorporating subordinate agents' nodes directly into the parent, orchestrator graph. However, this is not recommended for complex subordinate agents, as it would make the overall system harder to scale, maintain and debug – you should use subgraphs or tools in those cases.

## Communication in multi-agent systems

A big question in multi-agent systems is how the agents communicate amongst themselves and with the orchestrator agent. This involves both the schema of how they communicate, as well as the sequence in which they communicate. LangGraph is perfect for orchestrating these types of systems and allows you to define both.

### Schema

LangGraph provides a lot of flexibility for how to communicate within multi-agent architectures.

* A node in LangGraph can have a private input state schema that is distinct from the graph state schema. This allows passing additional information during the graph execution that is only needed for executing a particular node.
* Subgraph agents can have independent input/output schemas. In this case it’s important to add input / output transformations so that the parent graph knows how to communicate with the subgraphs.
* For tool-based subordinate agents, the orchestrator determines the inputs based on the tool schema. Additionally, LangGraph allows passing state to individual tools at runtime, so subordinate agents can access parent state, if needed.

### Sequence

LangGraph provides multiple methods to control agent communication sequence:

* **Explicit control flow (graph edges)**: LangGraph allows you to define the control flow of your application (i.e. the sequence of how agents communicate) explicitly, via graph edges.
* **Implicity control flow (tool calling)**: if the orchestrator agent treats subordinate agents as tools, the tool-calling LLM powering the orchestrator will make decisions about the order in which the tools (agents) are being called

Check failure on line 42 in docs/docs/concepts/multi_agent.md

GitHub Actions / (Check for spelling errors)

Implicity ==> Implicitly, Simplicity
* **Dynamic control flow (conditional edges)**: LangGraph also allows you to define conditional edges, where the control flow is dependent on satisfying a given condition. In such cases, you can use an LLM to decide which subordinate agent to call next.