Memory: AGENTS.md loaded with memory=
Memory in Deep Agents is a set of AGENTS.md files, passed with memory=, whose contents are loaded into the system prompt on every run, so project rules and preferences apply without repeating them.
Last updated: 29 Sep, 2026 · Deep Agents 0.7
AGENTS.md: a README for agents
The video searches for AGENTS.md: an open format, used by tens of thousands of open-source projects, that works as a README for coding agents, a predictable place for the context and instructions an agent needs. Claude Code's CLAUDE.md does the same job. In Deep Agents a memory file is always loaded with the system prompt, with no loading on demand, so it should stay small: project conventions, user preferences, rules that apply to every conversation. The video's example is a company's stack, FastAPI, PostgreSQL, Redis and Qdrant on AWS, so that "build a RAG pipeline" comes back in that stack.
The video creates projects/AGENTS.md with Claude Code, then passes memory=["/projects/AGENTS.md"] to create_deep_agent. With the default backend the file has to be in the agent's state, so the call seeds it through files, using create_file_data to wrap the text in the shape the backend expects. Asked "What's in your memory? Who are you?", the agent answered from the file: plan first with a to-do tool, offload work to files, delegate to subagents. On screen the path is typed as projects/AGENTS.md; the saved notebook, shown here, uses /projects/AGENTS.md, the same path as the seeded file.
from deepagents.backends.utils import create_file_data
agent = create_deep_agent(
model="openai:gpt-5.4",
memory=["/projects/AGENTS.md"],
checkpointer=MemorySaver(),
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "What's in your memory? Who are you?"}],
"files": {"/projects/AGENTS.md": create_file_data(agents_md)}},
config={"configurable": {"thread_id": "default-demo-1"}},
)Shown as it ran in the video, not run here: it reads the 6,000-character AGENTS.md from the video's repository (github.com/krishnaik06/Deep-agents-With-Langchain). The trip planner below uses a four-line file of its own.
The memory= syntax
agent = create_deep_agent(model=model, memory=["/AGENTS.md"]) # a list of paths
agent.invoke({"messages": [...], "files": {"/AGENTS.md": create_file_data(text)}}) # StateBackend: seed itThe trip desk rules
The planner needs both tools. Start trip.py with search_travel and add_costs, from write_todos: planning with TodoListMiddleware:
from langchain.tools import tool
CATALOG = {
"paris": {
"flight": ["Return flight Delhi to Paris: 42,000 rupees"],
"hotel": ["Seine Budget Inn, Latin Quarter: 5,200 rupees a night",
"Hotel Lumiere, Montmartre: 7,500 rupees a night",
"Le Grand Opera Hotel: 16,000 rupees a night"],
"sight": ["Eiffel Tower summit: 3,100 rupees", "Louvre Museum: 2,000 rupees",
"Seine river cruise: 1,500 rupees", "Versailles day trip: 2,600 rupees",
"Montmartre walking tour: free"],
"food": ["Cafe breakfast and bistro dinner: 3,000 rupees a day"],
},
}
@tool
def search_travel(city: str, kind: str) -> str:
"""Search the travel catalog. kind is "flight", "hotel", "sight" or "food". Prices are in rupees."""
entries = CATALOG.get(city.lower(), {}).get(kind)
return "\n".join(entries) if entries else f"The catalog has no {kind} entries for {city}."
@tool
def add_costs(amounts: list[int]) -> int:
"""Add rupee amounts and return the exact total. Use it for every sum."""
return sum(amounts)from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model
model = init_chat_model("groq:openai/gpt-oss-120b", temperature=0, max_retries=6)
from deepagents.backends.utils import create_file_dataAGENTS_MD = """# Trip desk rules
- Plans have one line per day, starting with "Day 1:".
- Write every price as rupees with commas, like 5,200 rupees.
- End every plan with a line "Total: <amount> rupees", added up with add_costs.
"""An agent that loads the rules
agent = create_deep_agent(
model=model,
tools=[search_travel, add_costs],
memory=["/AGENTS.md"], # loaded into the system prompt on every run
system_prompt="You are a travel planner. Use only prices from search_travel.",
)A plan that follows AGENTS.md
result = agent.invoke({
"messages": [{"role": "user", "content": "Plan 2 days of Paris sightseeing, sights only."}],
"files": {"/AGENTS.md": create_file_data(AGENTS_MD)}, # the StateBackend reads it from state
})
print(result["messages"][-1].text)Day 1: Eiffel Tower summit (3,100 rupees), Louvre Museum (2,000 rupees), Seine river cruise (1,500 rupees) Day 2: Versailles day trip (2,600 rupees), Montmartre walking tour (free) Total: 9,200 rupees
How the reply follows the file
- One line per day, each starting with "Day 1:", as the first rule says.
- Prices in rupees with commas, from the catalog.
- A total line at the end, "Total: 9,200 rupees", as the third rule asks. None of these rules is in the system prompt; they came from
/AGENTS.md.
Memory vs system prompt
| system_prompt | memory=[...] | |
|---|---|---|
| Where it lives | In your code | In a file on a backend |
| Who can change it | You, by editing code | You, or the agent with edit_file |
| Loaded | Every call | Every call |
Where memory files fit
- House rules for every answer, like the format above.
- Facts about a project: its stack, its conventions, where things are.
- Preferences the agent learns and writes back, kept in a store as the composite-backend lesson showed.
The memory file is read when a thread starts and its text is added to every model call on that thread. An edit the agent makes during a thread shows up from the next thread on.
AGENTS.md costs tokens on each step and can confuse the model; move detailed, occasional knowledge into skills.Related
- Previous: CompositeBackend: long-term memory in /memories/
- Next: Skills: SKILL.md loaded on demand
- Reference: Deep Agents memory
- Add a rule "Mention one free activity each day" and run the plan again.
- Run the same request without the
filesseed and read how the format changes. - Ask the agent "Add a rule that prices also show euros" and print the file it edits.
This is what real progress feels like.