Skip to content

Chapter 10 · Skills, Memory, and Approval Modes ​

Chapter goals:

  • Master Deep Agents Skills system (AGENTS.md file format)
  • Understand the distinction between short-term and long-term Memory
  • Learn to use three approval modes: Manual, Auto, YOLO
  • Configure remote code sandbox (E2B/Modal)

10.1 Skills System ​

Skills are reusable Agent capabilities and instructions:

markdown
<!-- .deepagents/skills/researcher/AGENTS.md -->
---
name: researcher
description: Research topics and generate comprehensive reports
model: anthropic:claude-haiku-4-5-20251001
tools: [search, read_file, write_file]
---

# Researcher Skill

You are an expert researcher. Your workflow:

1. **Search**: Use search tool to find relevant information
2. **Read**: Read documents and extract key points
3. **Synthesize**: Combine findings into coherent analysis
4. **Write**: Generate structured report

## Output Format
- Executive summary (1 paragraph)
- Key findings (bullet points)
- Sources cited
- Recommendations

10.1.1 Skill Composition ​

python
from deepagents import Skill, create_deep_agent

# Define skill programmatically
researcher = Skill(
    name="researcher",
    description="Research and analyze topics",
    model="claude-haiku",
    tools=["search", "read", "write"]
)

# Load from file
skill = Skill.from_file(".deepagents/skills/researcher/AGENTS.md")

10.2 Memory System ​

10.2.1 Short-term Memory ​

Conversation context within a session:

python
agent = create_deep_agent(
    memory="short_term",
    memory_config={
        "type": "window",
        "window_size": 10,  # Last 10 messages
        "summary_threshold": 5  # Summarize after 5 exchanges
    }
)

Behavior:

  • Keeps last N messages in context
  • Automatically summarizes older conversations
  • Session-bound (lost on restart unless persisted)

10.2.2 Long-term Memory ​

Persistent memory across sessions:

python
agent = create_deep_agent(
    memory="long_term",
    memory_config={
        "type": "vector_store",
        "store": "chroma",
        "collection": "agent_memory",
        "embedding_model": "text-embedding-3-small"
    }
)

Behavior:

  • Stores facts, preferences, and insights
  • Semantic search for relevant memories
  • Survives across sessions and restarts

10.2.3 Memory Comparison ​

FeatureShort-termLong-term
DurationSession-onlyPersistent
CapacityLimited (window)Unlimited
SearchExact matchSemantic
Use CaseContext continuityUser profiling

10.3 Approval Modes ​

10.3.1 Manual Mode ​

Every tool call requires human approval:

python
agent = create_deep_agent(
    approval_mode="manual",
    approval_callback=lambda tool_call: input(f"Approve {tool_call.name}? (y/n): ") == 'y'
)

Use Case: Sensitive operations, production deployment, compliance requirements.

10.3.2 Auto Mode ​

Auto-approve safe operations, prompt for risky ones:

python
agent = create_deep_agent(
    approval_mode="auto",
    safe_tools=["read_file", "search", "calculate"],
    risky_tools=["write_file", "execute_code", "send_email"]
)

Use Case: Balance between autonomy and safety.

10.3.3 YOLO Mode ​

No approval required, maximum autonomy:

python
agent = create_deep_agent(
    approval_mode="yolo"
)

Use Case: Development, testing, trusted environments.


10.4 Remote Code Sandbox ​

Execute Agent code in isolated sandbox:

python
from deepagents.sandbox import E2BSandbox, ModalSandbox

# E2B Sandbox
agent = create_deep_agent(
    sandbox=E2BSandbox(api_key="e2b_...")
)

# Modal Sandbox
agent = create_deep_agent(
    sandbox=ModalSandbox(api_key="modal_...")
)

10.4.1 Sandbox Benefits ​

  • Isolated execution environment
  • Resource limits (CPU, memory, time)
  • No access to host system
  • Audit trail of executions

Chapter Summary ​

  1. Skills: Reusable capabilities defined in AGENTS.md format;
  2. Memory: Short-term (session) vs Long-term (persistent vector store);
  3. Approval Modes: Manual (full control), Auto (balanced), YOLO (full autonomy);
  4. Sandbox: Isolated execution with E2B/Modal for safe code execution.

🛠️ Hands-on Practice ​

  1. Create three skills: researcher, writer, analyst. Combine them into a multi-agent team.

  2. Implement long-term memory with ChromaDB and verify persistence across sessions.

  3. Set up E2B sandbox and test code execution isolation.


🧪 随堂测验

点击你认为正确的选项。答错时会展示正确答案与原因解析。

1. What is the purpose of AGENTS.md file?

2. What is the difference between short-term and long-term memory?

3. Which approval mode requires human approval for every tool call?

4. What is the benefit of using a code sandbox?