StoreBackend: files shared across threads
StoreBackend is a backend that keeps the agent's files in a LangGraph store under a namespace, so a file written on one thread can be read on any other thread that uses the same store.
Last updated: 29 Sep, 2026 · Deep Agents 0.7
The video's two-thread test
The third backend creates a persistent key-value store. The video builds an InMemoryStore, passes it as store=, and gives StoreBackend a namespace, a function that returns ("demo-user",). On thread one it writes /notes/todo.txt; on a second thread, with a new id, it asks for the file back and gets it. With an InMemoryStore the file is not on disk at all: it lives in memory, inside the store object, as an entry under the namespace. The video's code follows, run on Groq with the model line swapped, plus a loop that lists the store's keys:
import uuid
from deepagents import create_deep_agent
from deepagents.backends import StoreBackend
from langchain.chat_models import init_chat_model
from langgraph.store.memory import InMemoryStore
store = InMemoryStore()
agent = create_deep_agent(
model=init_chat_model("groq:openai/gpt-oss-120b", max_retries=6),
backend=StoreBackend(namespace=lambda rt: ("demo-user",)),
store=store,
)
thread_1 = {"configurable": {"thread_id": str(uuid.uuid4())}}
result = agent.invoke({"messages": [{"role": "user", "content": (
"Create a file at /notes/todo.txt with exactly this content:\n"
"1. Record video\n2. Edit video\n3. Upload video\n"
"Then tell me you've done it.")}]}, config=thread_1)
print("--- Agent reply (thread 1) ---")
print(result["messages"][-1].content)
thread_2 = {"configurable": {"thread_id": str(uuid.uuid4())}}
followup = agent.invoke({"messages": [{"role": "user", "content": "Read /notes/todo.txt back to me verbatim."}]}, config=thread_2)
print("--- Read-back on a different thread ---")
print(followup["messages"][-1].content)
print("--- In the store ---")
for item in store.search(("demo-user",)):
print(item.key)--- Agent reply (thread 1) --- The file **/notes/todo.txt** has been created with the requested content. --- Read-back on a different thread --- Here is the exact content of **/notes/todo.txt**: ``` 1. Record video 2. Edit video 3. Upload video ``` --- In the store --- /notes/todo.txt
What the two threads and the store show
- Thread one wrote the file.
- Thread two started with an empty conversation, yet
read_filefound the file: the store is outside any one thread. - The store's key is the file's path, under the
demo-usernamespace.
The StoreBackend call
from deepagents.backends import StoreBackend
from langgraph.store.memory import InMemoryStore
agent = create_deep_agent(
model=model,
backend=StoreBackend(namespace=lambda rt: ("demo-user",)), # where in the store
store=InMemoryStore(), # the store itself
)The namespace function receives the run's runtime, so in a real app it can return the user's id and keep each user's files apart.
The three backends compared
| Backend | Lives in | Other threads see it | Survives a restart |
|---|---|---|---|
StateBackend | The thread's state | No | With a saved checkpointer |
FilesystemBackend | Your disk | Yes | Yes |
StoreBackend | A LangGraph store | Yes | With a persistent store, such as Postgres |
Where StoreBackend fits
- Per-user files that must follow a user into every new conversation.
- Agents deployed on LangSmith, where a store is provided for you.
- Shared notes several agents read and write.
InMemoryStore is in memory: a restart empties it, and the "long-term" files are gone. Use a persistent store in production.Related
- Previous: FilesystemBackend: files on your disk
- Next: CompositeBackend: long-term memory in /memories/
- Reference: Backends: StoreBackend
- Change the namespace to
("asha",)for a second agent on the same store and try to read the file. - Print
item.valuefor the stored file to see how the content is kept. - Write a second file on thread two and list the store's keys again.
You understood something today that you didn't yesterday.