deep-agents-memory

द्वारा langchain-ai

INVOKE THIS SKILL when your Deep Agent needs memory, persistence, or filesystem access. Covers StateBackend (ephemeral), StoreBackend (persistent),…

npx skills add https://github.com/langchain-ai/skills-benchmarks --skill deep-agents-memory
Deep Agents use pluggable backends for file operations and memory:

Short-term (StateBackend): Persists within a single thread, lost when thread ends Long-term (StoreBackend): Persists across threads and sessions Hybrid (CompositeBackend): Route different paths to different backends

FilesystemMiddleware provides tools: ls, read_file, write_file, edit_file, glob, grep

Use CaseBackendWhy
Temporary working filesStateBackendDefault, no setup
Local development CLIFilesystemBackendDirect disk access
Cross-session memoryStoreBackendPersists across threads
Hybrid storageCompositeBackendMix ephemeral + persistent
Default StateBackend stores files ephemerally within a thread. ```python from deepagents import create_deep_agent

agent = create_deep_agent() # Default: StateBackend result = agent.invoke({ "messages": [{"role": "user", "content": "Write notes to /draft.txt"}] }, config={"configurable": {"thread_id": "thread-1"}})

/draft.txt is lost when thread ends

</python>
<typescript>
Default StateBackend stores files ephemerally within a thread.
```typescript
import { createDeepAgent } from "deepagents";

const agent = await createDeepAgent();  // Default: StateBackend
const result = await agent.invoke({
  messages: [{ role: "user", content: "Write notes to /draft.txt" }]
}, { configurable: { thread_id: "thread-1" } });
// /draft.txt is lost when thread ends
Configure CompositeBackend to route paths to different storage backends. ```python from deepagents import create_deep_agent from deepagents.backends import CompositeBackend, StateBackend, StoreBackend from langgraph.store.memory import InMemoryStore

store = InMemoryStore()

composite_backend = lambda rt: CompositeBackend( default=StateBackend(rt), routes={"/memories/": StoreBackend(rt)} )

agent = create_deep_agent(backend=composite_backend, store=store)

/draft.txt -> ephemeral (StateBackend)

/memories/user-prefs.txt -> persistent (StoreBackend)

</python>
<typescript>
Configure CompositeBackend to route paths to different storage backends.
```typescript
import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents";
import { InMemoryStore } from "@langchain/langgraph";

const store = new InMemoryStore();

const agent = await createDeepAgent({
  backend: (config) => new CompositeBackend(
    new StateBackend(config),
    { "/memories/": new StoreBackend(config) }
  ),
  store
});

// /draft.txt -> ephemeral (StateBackend)
// /memories/user-prefs.txt -> persistent (StoreBackend)
Files in /memories/ persist across threads via StoreBackend routing. ```python # Using CompositeBackend from previous example config1 = {"configurable": {"thread_id": "thread-1"}} agent.invoke({"messages": [{"role": "user", "content": "Save to /memories/style.txt"}]}, config=config1)

config2 = {"configurable": {"thread_id": "thread-2"}} agent.invoke({"messages": [{"role": "user", "content": "Read /memories/style.txt"}]}, config=config2)

Thread 2 can read file saved by Thread 1

</python>
<typescript>
Files in /memories/ persist across threads via StoreBackend routing.
```typescript
// Using CompositeBackend from previous example
const config1 = { configurable: { thread_id: "thread-1" } };
await agent.invoke({ messages: [{ role: "user", content: "Save to /memories/style.txt" }] }, config1);

const config2 = { configurable: { thread_id: "thread-2" } };
await agent.invoke({ messages: [{ role: "user", content: "Read /memories/style.txt" }] }, config2);
// Thread 2 can read file saved by Thread 1
Use FilesystemBackend for local development with real disk access and human-in-the-loop. ```python from deepagents import create_deep_agent from deepagents.backends import FilesystemBackend from langgraph.checkpoint.memory import MemorySaver

agent = create_deep_agent( backend=FilesystemBackend(root_dir=".", virtual_mode=True), # Restrict access interrupt_on={"write_file": True, "edit_file": True}, checkpointer=MemorySaver() )

Agent can read/write actual files on disk

</python>
<typescript>
Use FilesystemBackend for local development with real disk access and human-in-the-loop.
```typescript
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { MemorySaver } from "@langchain/langgraph";

const agent = await createDeepAgent({
  backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
  interruptOn: { write_file: true, edit_file: true },
  checkpointer: new MemorySaver()
});

Security: Never use FilesystemBackend in web servers - use StateBackend or sandbox instead.

Access the store directly in custom tools for long-term memory operations. ```python from langchain.tools import tool, ToolRuntime from langchain.agents import create_agent from langgraph.store.memory import InMemoryStore

@tool def get_user_preference(key: str, runtime: ToolRuntime) -> str: """Get a user preference from long-term storage.""" store = runtime.store result = store.get(("user_prefs",), key) return str(result.value) if result else "Not found"

@tool def save_user_preference(key: str, value: str, runtime: ToolRuntime) -> str: """Save a user preference to long-term storage.""" store = runtime.store store.put(("user_prefs",), key, {"value": value}) return f"Saved {key}={value}"

store = InMemoryStore()

agent = create_agent( model="gpt-4.1", tools=[get_user_preference, save_user_preference], store=store )

</python>
</ex-store-in-custom-tools>

<boundaries>
### What Agents CAN Configure

- Backend type and configuration
- Routing rules for CompositeBackend
- Root directory for FilesystemBackend
- Human-in-the-loop for file operations

### What Agents CANNOT Configure

- Tool names (ls, read_file, write_file, edit_file, glob, grep)
- Access files outside virtual_mode restrictions
- Cross-thread file access without proper backend setup
</boundaries>

<fix-storebackend-requires-store>
<python>
StoreBackend requires a store instance.
```python
# WRONG
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt))

# CORRECT
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt), store=InMemoryStore())
StoreBackend requires a store instance. ```typescript // WRONG const agent = await createDeepAgent({ backend: (c) => new StoreBackend(c) });

// CORRECT const agent = await createDeepAgent({ backend: (c) => new StoreBackend(c), store: new InMemoryStore() });

</typescript>
</fix-storebackend-requires-store>

<fix-statebackend-files-dont-persist>
<python>
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access.
```python
# WRONG: thread-2 can't read file from thread-1
agent.invoke({"messages": [...]}, config={"configurable": {"thread_id": "thread-1"}})  # Write
agent.invoke({"messages": [...]}, config={"configurable": {"thread_id": "thread-2"}})  # File not found!
StateBackend files are thread-scoped - use same thread_id or StoreBackend for cross-thread access. ```typescript // WRONG: thread-2 can't read file from thread-1 await agent.invoke({ messages: [...] }, { configurable: { thread_id: "thread-1" } }); // Write await agent.invoke({ messages: [...] }, { configurable: { thread_id: "thread-2" } }); // File not found! ``` Path must match CompositeBackend route prefix for persistence. ```python # With routes={"/memories/": StoreBackend(rt)}: agent.invoke(...) # /prefs.txt -> ephemeral (no match) agent.invoke(...) # /memories/prefs.txt -> persistent (matches route) ``` Path must match CompositeBackend route prefix for persistence. ```typescript // With routes: { "/memories/": StoreBackend }: await agent.invoke(...); // /prefs.txt -> ephemeral (no match) await agent.invoke(...); // /memories/prefs.txt -> persistent (matches route) ``` Use PostgresStore for production (InMemoryStore lost on restart). ```python # WRONG # CORRECT store = InMemoryStore() store = PostgresStore(connection_string="postgresql://...") ``` Use PostgresStore for production (InMemoryStore lost on restart). ```typescript // WRONG // CORRECT const store = new InMemoryStore(); const store = new PostgresStore({ connectionString: "..." }); ``` Enable virtual_mode=True to restrict path access (prevents ../ and ~/ escapes). ```python backend = FilesystemBackend(root_dir="/project", virtual_mode=True) # Secure ``` CompositeBackend matches longest prefix first. ```python routes = {"/mem/": StoreBackend(rt), "/mem/temp/": StateBackend(rt)} # /mem/file.txt -> StoreBackend, /mem/temp/file.txt -> StateBackend (longer match) ```

langchain-ai की और Skills

langgraph-docs
langchain-ai
LangGraph दस्तावेज़ीकरण तक पहुँचकर स्टेटफुल एजेंट और मल्टी-एजेंट वर्कफ़्लो बनाएँ। स्टेट मशीन, ग्राफ़-आधारित एजेंट डिज़ाइन और ह्यूमन-इन-द-लूप पैटर्न को कवर करने वाले आधिकारिक LangGraph Python दस्तावेज़ प्राप्त करता है। प्रश्न प्रकार के अनुसार प्रासंगिक दस्तावेज़ीकरण को प्राथमिकता देता है: कैसे-करें प्रश्नों के लिए कार्यान्वयन गाइड, सिद्धांत के लिए अवधारणा पृष्ठ, एंड-टू-एंड उदाहरण
official
langgraph-human-in-the-loop
langchain-ai
ग्राफ निष्पादन को मानव समीक्षा, अनुमोदन या सत्यापन के लिए रोकें, फिर उनके इनपुट के साथ पुनः शुरू करें। तीन घटकों की आवश्यकता है: एक चेकपॉइंटर (InMemorySaver या PostgresSaver), कॉन्फ़िग में एक थ्रेड आईडी, और JSON-सीरियलाइज़ेबल इंटरप्ट पेलोड। interrupt(value) रुकता है और डेटा सतह पर लाता है; Command(resume=value) पुनः शुरू करता है और उस मान को रुके हुए नोड पर लौटाता है। interrupt() से पहले का सारा कोड पुनः शुरू हो
official
web-research
langchain-ai
वेब अनुसंधान से संबंधित अनुरोधों के लिए इस कौशल का उपयोग करें; यह व्यापक वेब अनुसंधान करने के लिए एक संरचित दृष्टिकोण प्रदान करता है
official
langchain-oss-primer
langchain-ai
किसी भी LangChain, Deep Agents या LangGraph एजेंट निर्माण प्रोजेक्ट के लिए हमेशा यहाँ से शुरू करें। अन्य कौशल चुनने या कुछ भी लिखने से पहले आवश्यक प्रारंभिक बिंदु।
official
skill-creator
langchain-ai
प्रभावी कौशल बनाने के लिए मार्गदर्शिका जो विशेष ज्ञान, कार्यप्रवाह या उपकरण एकीकरण के साथ एजेंट क्षमताओं का विस्तार करते हैं। इस कौशल का उपयोग तब करें जब उपयोगकर्ता…
official
social-media
langchain-ai
प्लेटफ़ॉर्म-विशिष्ट सोशल मीडिया पोस्ट तैयार करता है, जिसमें शोध-समर्थित सामग्री और जनरेटेड सहायक चित्र शामिल होते हैं। लिंक्डइन पोस्ट (1,300 अक्षर, पेशेवर लहजे के साथ) और ट्विटर/एक्स थ्रेड (प्रति ट्वीट 280 अक्षर, 1/🧵 प्रारूप के साथ) का समर्थन करता है। लिखने से पहले एक उप-एजेंट को शोध सौंपने की आवश्यकता होती है, फिर सटीकता और प्रासंगिकता सुनिश्चित करने के लिए निष्कर्ष पढ़ता है। generate_social_image टूल का
official
deep-agents-memory
langchain-ai
डीप एजेंट्स के लिए प्लग करने योग्य मेमोरी और फ़ाइल बैकएंड, जिसमें एफेमरल, पर्सिस्टेंट और हाइब्रिड रूटिंग विकल्प हैं। चार बैकएंड प्रकार: स्टेटबैकएंड (थ्रेड-स्कोप्ड, एफेमरल), स्टोरबैकएंड (क्रॉस-सेशन पर्सिस्टेंट), फ़ाइलसिस्टमबैकएंड (स्थानीय डेव के लिए वास्तविक डिस्क एक्सेस), और कम्पोजिटबैकएंड (विभिन्न पथों को विभिन्न बैकएंड पर रूट करता है)। फ़
official
deep-agents-orchestration
langchain-ai
उप-एजेंटों का समन्वय करें, बहु-चरणीय कार्यों की योजना बनाएं, और संवेदनशील संचालन के लिए मानव अनुमोदन आवश्यक है। कार्य उपकरण के माध्यम से विशिष्ट उप-एजेंटों को कार्य सौंपें; कस्टम उप-एजेंट पृथक उपकरण सेट और सिस्टम प्रॉम्प्ट का समर्थन करते हैं, जबकि डिफ़ॉल्ट "सामान्य-उद्देश्य" उप-एजेंट मुख्य एजेंट कॉन्फ़िगरेशन प्राप्त करता है। write_todos के साथ जटिल वर्कफ़्लो की योजना ब
official