Shared memory vs message passing: where agent state lives
Updated November 2026
Give agents one shared memory when they run in one codebase and must work from a single consistent view. Have them pass messages when they belong to different teams or frameworks and should keep their internals private. With shared memory, every agent reads and writes one store, such as graph state or a blackboard. With message passing, agents send each other explicit payloads, such as handoff inputs or A2A messages, and each agent owns its own state.
At a glance
| Shared memory | message passing | |
|---|---|---|
| What it is | LangGraph state is part of the Graph API, which defines agent workflows as a graph of state, nodes, and edges. | A2A is an open standard for communication between AI agents, whatever framework or vendor built them. |
| Where the data lives | LangGraph keeps a shared snapshot of the application as state, usually a typed schema, and stores that data in channels named after the state keys. | A2A defines a message as a single turn of communication between a client and an agent, and an artifact as a tangible output generated during a task. |
| Merging and ordering | LangGraph state uses last-write-wins on most channels, while channels with a reducer combine values, for example by appending to a list. | A2A requires implementations to deliver events in the order they were generated, and each stream must receive the same events in the same order. |
| Visibility between agents | LangGraph lets a node write to any channel in the graph state, including channels outside its declared input schema. | A2A treats the remote agent as an opaque black-box system whose internal workings, memory, and tools stay hidden. |
| Human-in-the-loop | LangGraph uses Command, which updates state while routing to the next node, including resume after an interrupt. | A2A sets a goal of native support for long-running tasks and interactions that may involve human-in-the-loop scenarios. |
| Durability | LangGraph checkpointers persist a thread's graph state as checkpoints for short-term, thread-scoped memory. | A2A says not all Messages are guaranteed to be persisted in the Task history, and the agent is responsible for deciding which ones are. |
| Execution and transport | LangGraph advances in discrete super-steps, and nodes that run in parallel share one super-step. | A2A communication occurs over HTTP(S) with JSON-RPC 2.0 as the payload format for all requests and responses. |
How does each one coordinate agents?
LangGraph coordinates agents through the state they share. Its nodes read state, do work, and return updates, and LangGraph applies them through each channel's reducer. With no reducer, updates overwrite the previous value, and a custom reducer can append to a list instead. Decide per key what should happen when two agents update it in the same step.
A2A coordinates through requests and results. Its core model is for clients to send messages that start a task producing one or more artifacts, and the agent's response is either a Task or a Message. The spec says results SHOULD be returned as artifacts, which separates communication from data output. A server-generated contextId can group related Task objects across a series of interactions.
A2A's docs say MCP stays within one agent and connects it to APIs and enterprise applications, while A2A crosses the boundary between agents. In MCP's own architecture, servers receive only necessary contextual information and the full conversation history stays with the host.
When should you choose LangGraph shared state?
- Your agents are nodes in one graph. When parent and subgraph share state keys, the compiled subgraph goes straight to add_node and reads and writes the parent's channels with no wrapper function.
- Parallel agents might contradict each other. A Cognition post argues that actions carry implicit decisions and conflicting decisions carry bad results, and it recommends sharing full agent traces over individual messages.
- You need clean resume points. With a checkpointer, LangGraph saves checkpoints at super-step boundaries, and when work stops at a graph node, resume starts at that node and earlier nodes do not re-run.
- Some facts must outlive one thread. LangGraph stores hold long-term, cross-thread memory such as user preferences, facts, and shared knowledge (see the shared memory pattern page).
When should you choose A2A messages?
- Your agents come from different frameworks. Teams build with LangGraph, CrewAI, ADK and others, and A2A lets agents built with any of them work together.
- Agents must keep their internals private. A goal of the spec is to let agents exchange information without needing access to each other's internal state, memory, or tools.
- Work runs long or clients disconnect. A2A natively supports long-running tasks, including cases where agents or users drop off, through streaming and push notifications.
- Outputs are large. An A2A Part holds text, a file reference by URL or inline bytes, or structured data. Anthropic describes subagents that pass lightweight references back to the coordinator, which reduces token overhead from copying large outputs through conversation history.
Can you use them together?
Yes, with each doing its own job. A2A's docs divide the stack so that a framework builds the agent, MCP gives it context, a runtime hosts it, and A2A connects it to other agents. In a combined system, graph state can hold what your own agents share, while A2A messages carry requests to agents you do not run.
Inside LangGraph you can also keep part of the state private. When parent and subgraph schemas differ, you invoke the subgraph inside a node function, a setup the docs call common for keeping a private message history per agent. That node function transforms the parent state on the way in and maps the results back on the way out. Confluent describes a similar mix in which a blackboard becomes a data streaming topic of messages that worker agents produce and consume. The guide on keeping context in sync covers the working details.
What should you watch out for?
- Subgraph updates can lag in LangGraph. The persistence docs say the parent graph may not see a subgraph's changes immediately, and they suggest shared state via Store for data that crosses graph boundaries.
- Retries repeat side effects. After an interrupt or retry, the affected node runs again from the start of its function, so side effects before the pause run again. Make external writes idempotent.
- Checkpoints pile up. Over long conversations they accumulate, which can increase latency and storage costs, and MemorySaver and InMemorySaver lose all checkpoints when the process restarts.
- Task history in A2A may have gaps. Messages exchanged prior to task creation may not be stored there, so keep your own record where audits need one.
What else should you know?
Does LangGraph use shared memory or message passing?
It uses both. Nodes share state, and LangGraph runs graphs with message passing in the style of Google's Pregel system.
Where does MCP fit?
A2A's docs describe MCP's focus as reducing the complexity involved in connecting agents with tools and data. They add that tools are typically stateless, so agent memory belongs elsewhere in your design.
Which approach is easier to audit?
Keep an append-only record either way. The LangGraph docs tell you to use checkpointers to persist and inspect thread state, and Confluent describes a log that is permanent and unchangeable and gives all agents the same context.
Does passing everything to the next agent cost tokens?
It can. In the OpenAI Agents SDK, the agent receiving a handoff sees the entire previous conversation history unless you set an input filter. The guide on handoffs that keep context shows how to trim what gets passed.
Which sources does this page use?
- Graph API overview (docs.langchain.com), reviewed November 2026
- What is A2A? (a2a-protocol.org), reviewed November 2026
- Core Concepts (a2a-protocol.org), reviewed November 2026
- Overview (a2a-protocol.org), reviewed November 2026
- Persistence (docs.langchain.com), reviewed November 2026
- Architecture (modelcontextprotocol.io), reviewed November 2026
- Subgraphs (docs.langchain.com), reviewed November 2026
- Don't Build Multi-Agents (cognition.com), reviewed November 2026
- How we built our multi-agent research system \ Anthropic (anthropic.com), reviewed November 2026
- Four Design Patterns for Event-Driven, Multi-Agent Systems Data architecture tha (confluent.io), reviewed November 2026
- Handoffs (openai.github.io), reviewed November 2026