This article is published in English.
Practical notes: Learning Skills with Deep Agents in Agentic AI
Operable walkthrough of Practical notes: Learning Skills with Deep Agents in Agentic AI: contracts, checks, and drop-in code slots for teams shipping this pattern.
Use this as an operator-facing rebuild of the ideas in “Learning Skills with Deep Agents in Agentic AI”: clear stages, ordered code slots, and recovery notes that survive a handoff. The Overview stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Deep Reinforcement Learning and Skill Acquisition
For the Deep Reinforcement Learning and stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.
DeepAgents Architecture and Learning Algorithms
For the DeepAgents Architecture and Learning stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness.
End-to-End Implementation Plan
For the End-to-End Implementation Plan stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Put human approval on edges that spend money or change production data. Compile-time wiring does not equal business completeness. For the End-to-End Implementation Plan stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
# Install deepagents and necessary tools
!pip install --upgrade deepagents langchain tavily-python
# Import libraries and set API keys (e.g., for LLM and search tool)
import os
from getpass import getpass
os.environ["OPENAI_API_KEY"] = getpass("OpenAI API Key: ")
os.environ["TAVILY_API_KEY"] = getpass("Tavily API Key: ")
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from deepagents.middleware.filesystem import FileData
from langchain.chat_models import init_chat_model
from tavily import TavilyClient
Defining the Agent and Skills
When working through the Defining the Agent and stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.
from deepagents import create_deep_agent
# Assume we have local skill directories under "./skills"
skill_dirs = ["./skills/pdf_processing", "./skills/data_analysis"]
agent = create_deep_agent(
model=model,
system_prompt="""
You are a highly capable AI assistant. Your objectives:
1. Break tasks into steps using write_todos().
2. Use internet_search and file tools to gather and store information.
3. When given a task, plan and execute it step-by-step, writing to files as needed.
4. Load skills from the filesystem to handle specialized tasks when relevant.
5. Summarize results and refine final output before returning.
""",
tools=[internet_search], # Web search tool
backend=FilesystemBackend(root_dir="./workspace"), # Persistent file storage
skills=skill_dirs, # Load skills from local directories
)
skills/
├── pdf_processing/
│ └── SKILL.md
└── data_analysis/
├── SKILL.md
└── analysis_script.py
---
name: pdf-processing
description: Skill to extract and analyze content from PDF documents.
---
# PDF Processing Skill
To use this skill, follow these steps:
1. Use `pdf-tools` to read PDF content.
2. Summarize key findings from the PDF text.
...
Example Interaction
When working through the Example Interaction stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.
from langchain.schema import HumanMessage
query = "Organize the latest quarterly sales data and write a summary report."
response = agent.invoke({
"messages": [HumanMessage(content=query)]
})
print(response["messages"][-1]["content"])
Testing and Evaluation
When working through the Testing and Evaluation stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node. When working through the Testing and Evaluation stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
System Architecture and Deployment
The System Architecture and Deployment stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.
+------------------+ +--------------+
| Client/User | <--> | API Gateway | <---> [HTTP requests]
+------------------+ +------+-------+
|
v
+-------------+
| AgentCore | <-- AWS Bedrock AgentCore (managed runtime)
+-------------+
|
+-------------+-------------+
| |
+-------------------+ +-------------------+
| Deep Agent Service | | Storage (S3/DB) | <-- File/memory backend, logs
+-------------------+ +-------------------+
| |
+-------------+-------------+
|
+---------------+
| LLM Models | <-- e.g., OpenAI, Anthropic, local LLMs
+---------------+
Code Example: Creating and Invoking a Deep Agent
The Code Example Creating and stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts.
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from deepagents.middleware.filesystem import FileData
from langchain.chat_models import init_chat_model
from tavily import TavilyClient
import os
def setup_agent():
"""Initialize the Deep Agent with tools, skills, and system prompt."""
# Model and tools initialization
model = init_chat_model(model="openai:gpt-4o")
tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def web_search(query: str, max_results: int = 3) -> str:
results = tavily_client.search(query, max_results=max_results)
return "\n".join(f"{r.title}: {r.summary}" for r in results)
# Create the deep agent with planning, files, and skills
try:
agent = create_deep_agent(
model=model,
tools=[web_search],
system_prompt="""You are an expert agent. Your workflow:
1. Create a plan with write_todos().
2. Use tools (e.g. web_search) and file system to research and work.
3. If specialized tasks arise, load relevant skills from the 'skills' directory.
4. Save results and refine the output at each step.
""",
backend=FilesystemBackend(root_dir="./workspace"),
skills=["./skills/pdf_processing", "./skills/data_analysis"]
)
return agent
except Exception as e:
print(f"Error initializing agent: {e}")
raise
def invoke_agent(agent, user_query):
"""Invoke the agent on a user query and return the final answer."""
try:
messages = [{"role": "user", "content": user_query}]
result = agent.invoke({"messages": messages})
return result["messages"][-1]["content"]
except Exception as e:
print(f"Agent invocation failed: {e}")
return None
# Example usage
if __name__ == "__main__":
agent = setup_agent()
task = "Analyze the recent research on climate change and summarize key findings."
answer = invoke_agent(agent, task)
print("Agent response:", answer)
A message from our Founder
The A message from our stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Keep graph state flat and typed. Nested blobs hide which node wrote which field and break resume after interrupts. The A message from our stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Operational checklist
When working through the Operational checklist stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest.
Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.
Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Checkpoint after expensive steps. Resume should not re-bill the same LLM call when an operator retries a later node.
Before promoting the stack, freeze versions, capture a golden transcript for the critical path, and confirm rollback steps. Shared environments need rate limits, tenancy checks, and a clear owner for secret rotation. Prefer boring reliability over clever one-off demos.
Batch note for 716df844b0ca: keep provider keys out of the repo, set a per-session token ceiling, and store transcripts next to the eval fixtures so later model swaps stay comparable.
When working through the hardening note 0 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.
Hardening detail 0/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
The hardening note 1 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Hardening detail 1/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
For the hardening note 2 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.
Hardening detail 2/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
When working through the hardening note 3 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
Hardening detail 3/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
The hardening note 4 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline.
Hardening detail 4/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
For the hardening note 5 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.
Hardening detail 5/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
When working through the hardening note 6 stage, write down the contract first: required inputs, success signal, and what happens on partial failure. That checklist keeps later code changes honest. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Hardening detail 6/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
The hardening note 7 stage works best when treated as a measurable surface. Capture one golden transcript, one failure case, and the rollback note before expanding scope. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.
Hardening detail 7/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.
For the hardening note 8 stage, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
Hardening detail 8/862: measure wall time, error class, and token spend for this note, then decide whether to keep the change based on a fixed question set rather than anecdote.