deep-agents-orchestration

tarafından langchain-ai

INVOKE THIS SKILL when using subagents, task planning, or human approval in Deep Agents. Covers SubAgentMiddleware, TodoList for planning, and HITL interrupts.

npx skills add https://github.com/langchain-ai/skills-benchmarks --skill deep-agents-orchestration
Deep Agents include three orchestration capabilities:
  1. SubAgentMiddleware: Delegate work via task tool to specialized agents
  2. TodoListMiddleware: Plan and track tasks via write_todos tool
  3. HumanInTheLoopMiddleware: Require approval before sensitive operations

All three are automatically included in create_deep_agent().


Subagents (Task Delegation)

Use Subagents WhenUse Main Agent When
Task needs specialized toolsGeneral-purpose tools sufficient
Want to isolate complex workSingle-step operation
Need clean context for main agentContext bloat acceptable
Main agent has `task` tool -> creates fresh subagent -> subagent executes autonomously -> returns final report.

Default subagent: "general-purpose" - automatically available with same tools/config as main agent.

Create a custom "researcher" subagent with specialized tools for academic paper search. ```python from deepagents import create_deep_agent from langchain.tools import tool

@tool def search_papers(query: str) -> str: """Search academic papers.""" return f"Found 10 papers about {query}"

agent = create_deep_agent( subagents=[ { "name": "researcher", "description": "Conduct web research and compile findings", "system_prompt": "Search thoroughly, return concise summary", "tools": [search_papers], } ] )

Main agent delegates: task(agent="researcher", instruction="Research AI trends")

</python>
<typescript>
Create a custom "researcher" subagent with specialized tools for academic paper search.
```typescript
import { createDeepAgent } from "deepagents";
import { tool } from "@langchain/core/tools";
import { z } from "zod";

const searchPapers = tool(
  async ({ query }) => `Found 10 papers about ${query}`,
  { name: "search_papers", description: "Search papers", schema: z.object({ query: z.string() }) }
);

const agent = await createDeepAgent({
  subagents: [
    {
      name: "researcher",
      description: "Conduct web research and compile findings",
      systemPrompt: "Search thoroughly, return concise summary",
      tools: [searchPapers],
    }
  ]
});

// Main agent delegates: task(agent="researcher", instruction="Research AI trends")
Configure a subagent with HITL approval for sensitive operations. ```python from deepagents import create_deep_agent from langgraph.checkpoint.memory import MemorySaver

agent = create_deep_agent( subagents=[ { "name": "code-deployer", "description": "Deploy code to production", "system_prompt": "You deploy code after tests pass.", "tools": [run_tests, deploy_to_prod], "interrupt_on": {"deploy_to_prod": True}, # Require approval } ], checkpointer=MemorySaver() # Required for interrupts )

</python>
</ex-subagent-with-hitl>

<fix-subagents-are-stateless>
<python>
Subagents are stateless - provide complete instructions in a single call.
```python
# WRONG: Subagents don't remember previous calls
# task(agent='research', instruction='Find data')
# task(agent='research', instruction='What did you find?')  # Starts fresh!

# CORRECT: Complete instructions upfront
# task(agent='research', instruction='Find data on AI, save to /research/, return summary')
Subagents are stateless - provide complete instructions in a single call. ```typescript // WRONG: Subagents don't remember previous calls // task research: Find data // task research: What did you find? // Starts fresh!

// CORRECT: Complete instructions upfront // task research: Find data on AI, save to /research/, return summary

</typescript>
</fix-subagents-are-stateless>

<fix-custom-subagents-dont-inherit-skills>
<python>
Custom subagents don't inherit skills from the main agent.
```python
# WRONG: Custom subagent won't have main agent's skills
agent = create_deep_agent(
    skills=["/main-skills/"],
    subagents=[{"name": "helper", ...}]  # No skills inherited
)

# CORRECT: Provide skills explicitly (general-purpose subagent DOES inherit)
agent = create_deep_agent(
    skills=["/main-skills/"],
    subagents=[{"name": "helper", "skills": ["/helper-skills/"], ...}]
)

TodoList (Task Planning)

Use TodoList WhenSkip TodoList When
Complex multi-step tasksSimple single-action tasks
Long-running operationsQuick operations (< 3 steps)
``` write_todos(todos: list[dict]) -> None ```

Each todo item has:

  • content: Description of the task
  • status: One of "pending", "in_progress", "completed"
Invoke an agent that automatically creates a todo list for a multi-step task. ```python from deepagents import create_deep_agent

agent = create_deep_agent() # TodoListMiddleware included by default

result = agent.invoke({ "messages": [{"role": "user", "content": "Create a REST API: design models, implement CRUD, add auth, write tests"}] }, config={"configurable": {"thread_id": "session-1"}})

Agent's planning via write_todos:

[

{"content": "Design data models", "status": "in_progress"},

{"content": "Implement CRUD endpoints", "status": "pending"},

{"content": "Add authentication", "status": "pending"},

{"content": "Write tests", "status": "pending"}

]

</python>
<typescript>
Invoke an agent that automatically creates a todo list for a multi-step task.
```typescript
import { createDeepAgent } from "deepagents";

const agent = await createDeepAgent();  // TodoListMiddleware included

const result = await agent.invoke({
  messages: [{ role: "user", content: "Create a REST API: design models, implement CRUD, add auth, write tests" }]
}, { configurable: { thread_id: "session-1" } });
Access the todo list from the agent's final state after invocation. ```python result = agent.invoke({...}, config={"configurable": {"thread_id": "session-1"}})

Access todo list from final state

todos = result.get("todos", []) for todo in todos: print(f"[{todo['status']}] {todo['content']}")

</python>
</ex-access-todo-state>

<fix-todolist-requires-thread-id>
<python>
Todo list state requires a thread_id for persistence across invocations.
```python
# WRONG: Fresh state each time without thread_id
agent.invoke({"messages": [...]})

# CORRECT: Use thread_id
config = {"configurable": {"thread_id": "user-session"}}
agent.invoke({"messages": [...]}, config=config)  # Todos preserved

Human-in-the-Loop (Approval Workflows)

Use HITL WhenSkip HITL When
High-stakes operations (DB writes, deployments)Read-only operations
Compliance requires human oversightFully automated workflows
Configure which tools require human approval before execution. ```python from deepagents import create_deep_agent from langgraph.checkpoint.memory import MemorySaver

agent = create_deep_agent( interrupt_on={ "write_file": True, # All decisions allowed "execute_sql": {"allowed_decisions": ["approve", "reject"]}, "read_file": False, # No interrupts }, checkpointer=MemorySaver() # REQUIRED for interrupts )

</python>
<typescript>
Configure which tools require human approval before execution.
```typescript
import { createDeepAgent } from "deepagents";
import { MemorySaver } from "@langchain/langgraph";

const agent = await createDeepAgent({
  interruptOn: {
    write_file: true,
    execute_sql: { allowedDecisions: ["approve", "reject"] },
    read_file: false,
  },
  checkpointer: new MemorySaver()  // REQUIRED
});
Complete workflow: trigger an interrupt, check state, approve action, and resume execution. ```python from deepagents import create_deep_agent from langgraph.checkpoint.memory import MemorySaver from langgraph.types import Command

agent = create_deep_agent( interrupt_on={"write_file": True}, checkpointer=MemorySaver() )

config = {"configurable": {"thread_id": "session-1"}}

Step 1: Agent proposes write_file - execution pauses

result = agent.invoke({ "messages": [{"role": "user", "content": "Write config to /prod.yaml"}] }, config=config)

Step 2: Check for interrupts

state = agent.get_state(config) if state.next: print(f"Pending action")

Step 3: Approve and resume

result = agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config=config)

</python>
<typescript>
Complete workflow: trigger an interrupt, check state, approve action, and resume execution.
```typescript
import { createDeepAgent } from "deepagents";
import { MemorySaver, Command } from "@langchain/langgraph";

const agent = await createDeepAgent({
  interruptOn: { write_file: true },
  checkpointer: new MemorySaver()
});

const config = { configurable: { thread_id: "session-1" } };

// Step 1: Agent proposes write_file - execution pauses
let result = await agent.invoke({
  messages: [{ role: "user", content: "Write config to /prod.yaml" }]
}, config);

// Step 2: Check for interrupts
const state = await agent.getState(config);
if (state.next) {
  console.log("Pending action");
}

// Step 3: Approve and resume
result = await agent.invoke(
  new Command({ resume: { decisions: [{ type: "approve" }] } }), config
);
Reject a pending action with feedback, prompting the agent to try a different approach. ```python result = agent.invoke( Command(resume={"decisions": [{"type": "reject", "message": "Run tests first"}]}), config=config, ) ``` Reject a pending action with feedback, prompting the agent to try a different approach. ```typescript const result = await agent.invoke( new Command({ resume: { decisions: [{ type: "reject", message: "Run tests first" }] } }), config, ); ``` Edit the proposed action arguments before allowing execution. ```python result = agent.invoke( Command(resume={"decisions": [{ "type": "edit", "edited_action": { "name": "execute_sql", "args": {"query": "DELETE FROM users WHERE last_login < '2020-01-01' LIMIT 100"}, }, }]}), config=config, ) ``` ### What Agents CAN Configure
  • Subagent names, tools, models, system prompts
  • Which tools require approval
  • Allowed decision types per tool
  • TodoList content and structure

What Agents CANNOT Configure

  • Tool names (task, write_todos)
  • HITL protocol (approve/edit/reject structure)
  • Skip checkpointer requirement for interrupts
  • Make subagents stateful (they're ephemeral)
Checkpointer is required when using interrupt_on for HITL workflows. ```python # WRONG agent = create_deep_agent(interrupt_on={"write_file": True})

CORRECT

agent = create_deep_agent(interrupt_on={"write_file": True}, checkpointer=MemorySaver())

</python>
<typescript>
Checkpointer is required when using interruptOn for HITL workflows.
```typescript
// WRONG
const agent = await createDeepAgent({ interruptOn: { write_file: true } });

// CORRECT
const agent = await createDeepAgent({ interruptOn: { write_file: true }, checkpointer: new MemorySaver() });
A consistent thread_id is required to resume interrupted workflows. ```python # WRONG: Can't resume without thread_id agent.invoke({"messages": [...]})

CORRECT

config = {"configurable": {"thread_id": "session-1"}} agent.invoke({...}, config=config)

Resume with Command using same config

agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config=config)

</python>
<typescript>
A consistent thread_id is required to resume interrupted workflows.
```typescript
// WRONG: Can't resume without thread_id
await agent.invoke({ messages: [...] });

// CORRECT
const config = { configurable: { thread_id: "session-1" } };
await agent.invoke({ messages: [...] }, config);
// Resume with Command using same config
await agent.invoke(new Command({ resume: { decisions: [{ type: "approve" }] } }), config);
Interrupts happen BETWEEN invoke() calls, not mid-execution. ```python result = agent.invoke({...}, config=config) # Step 1: triggers interrupt if "__interrupt__" in result: # Step 2: check for interrupt result = agent.invoke( # Step 3: resume Command(resume={"decisions": [{"type": "approve"}]}), config=config, ) ```

langchain-ai tarafından daha fazla skill

langgraph-docs
langchain-ai
LangGraph dokümantasyonuna erişerek durum bilgisi olan ajanlar ve çoklu ajan iş akışları oluşturun. Resmi LangGraph Python dokümanlarını getirir; durum makineleri, grafik tabanlı ajan tasarımı ve insan-döngüde desenlerini kapsar. Sorgu türüne göre ilgili dokümantasyonu önceliklendirir: nasıl yapılır soruları için uygulama kılavuzları, teori için kavram sayfaları, uçtan uca örnekler için eğitimler ve teknik detaylar için API referansları. En alakalı 2–4 dokümantasyon URL'sini otomatik olarak seçer ve yanıtlamak için içeriklerini alır...
official
langgraph-human-in-the-loop
langchain-ai
Graf yürütmesini insan incelemesi, onayı veya doğrulaması için duraklatır, ardından girdileriyle devam eder. Üç bileşen gerektirir: bir checkpointer (InMemorySaver veya PostgresSaver), config içinde bir thread ID ve JSON-serializable interrupt payload'ları. interrupt(value) duraklatır ve verileri yüzeye çıkarır; Command(resume=value) devam ettirir ve bu değeri duraklatılan düğüme döndürür. interrupt() öncesindeki tüm kod devamda yeniden çalıştırılır, bu nedenle yan etkiler idempotent olmalıdır (insert değil upsert kullanın). Onay iş akışlarını destekler,...
official
web-research
langchain-ai
Web araştırması ile ilgili talepler için bu beceriyi kullanın; kapsamlı web araştırması yapmak için yapılandırılmış bir yaklaşım sunar.
official
langchain-oss-primer
langchain-ai
Herhangi bir LangChain, Deep Agents veya LangGraph ajan oluşturma projesine BAŞLANGIÇ NOKTASI. Diğer becerileri seçmeden veya herhangi bir şey yazmadan önce gerekli başlangıç noktası.
official
skill-creator
langchain-ai
Etkili beceriler oluşturmak için rehber; bu beceriler, uzmanlaşmış bilgi, iş akışları veya araç entegrasyonları ile ajan yeteneklerini genişletir. Kullanıcı…
official
social-media
langchain-ai
Platformaya özel sosyal medya gönderilerini, araştırma destekli içerik ve oluşturulan eşlik eden görsellerle hazırlar. LinkedIn gönderilerini (profesyonel tonla 1.300 karakter) ve Twitter/X thread'lerini (tweet başına 280 karakter, 1/🧵 formatı) destekler. Yazmadan önce araştırmayı bir alt ajana devretmeyi, ardından doğruluk ve alaka düzeyini sağlamak için bulguları okumayı gerektirir. generate_social_image aracıyla, küçük... için optimize edilmiş cesur, yüksek kontrastlı kompozisyonlarla otomatik olarak dikkat çekici sosyal görseller oluşturur.
official
deep-agents-memory
langchain-ai
Deep Agents için geçici, kalıcı ve hibrit yönlendirme seçeneklerine sahip takılabilir bellek ve dosya arka uçları. Dört arka uç türü: StateBackend (iş parçacığı kapsamlı, geçici), StoreBackend (oturumlar arası kalıcı), FilesystemBackend (yerel geliştirme için gerçek disk erişimi) ve CompositeBackend (farklı yolları farklı arka uçlara yönlendirir). FilesystemMiddleware altı dosya işleme aracı sağlar: ls, read_file, write_file, edit_file, glob, grep. CompositeBackend en uzun önek eşlemesini kullanarak yönlendirme yapar...
official
deep-agents-orchestration
langchain-ai
Alt ajanları yönetir, çok adımlı görevleri planlar ve hassas işlemler için insan onayı gerektirir. Görev aracı aracılığıyla uzmanlaşmış alt ajanlara iş dağıtır; özel alt ajanlar izole araç setlerini ve sistem yönlendirmelerini desteklerken, varsayılan "genel amaçlı" alt ajan ana ajan yapılandırmasını devralır. write_todos ile karmaşık iş akışlarını planlayıp takip eder, görevleri beklemede, devam eden ve tamamlanmış durumlar arasında düzenler; kalıcılık için bir thread_id gerektirir. Uygular...
official