Skip to content

scriptbuzz/tutorial-ai-agent-harness

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Deep Agent Drive-Thru

Workshop: How To Build A Deep Agent Harness

Presented by ArtiPortal.com

Build, Customize, and Deploy "Batteries-Included" Agents.


Python License LangGraph deepagents uv Workshop


πŸ—ΊοΈ Workshop Roadmap

# Module Topic What You'll Build
0 πŸ› οΈ Prerequisites & Setup Environment & Keys Working dev environment
1 πŸš€ Your First Agent The "Health Check" Harness simple_agent.py
2 πŸ”§ Brain & Hands Model Swaps & Custom Tools custom_agent.py
3 🀝 Delegated Authority The Sub-Agent Pattern Multi-step research agent
4 πŸ§ͺ Benchmarking The Deep Agents CLI TUI coding assistant
β˜… πŸ—οΈ Advanced Patterns Production Architectures See examples directory

Welcome to the Deep Agents Workshop! This hands-on guide will transform you from an agent enthusiast into a developer capable of deploying production-ready AI agents using the Deep Agents framework and LangGraph.

At its core, Deep Agents is an Agent Harness. While most LLM implementations focus on the model, a harness focuses on the plumbing: the state management, tool-calling loops, planning logic, and context compression required for a reliable system. By building on LangGraph, Deep Agents provides a robust, stateful architecture that handles complex cycles and human-in-the-loop interactions with ease.

This workshop, curated by ArtiPortal.com, is designed to bridge the gap between "cool demos" and "functional software."

πŸ“– How to Use This Workshop

Icon Purpose What to Do
πŸš€ Module Core technical narrative and follow-along code.
πŸ§ͺ Lab Challenge Active learning β€” a task for you to solve using new skills.
πŸ” Deep Dive Under-the-hood explanation of the "Why" behind the code.
πŸ›‘ Common Gotcha Preventive troubleshooting for common friction points.
βœ… Self-Check Quick reflection questions to verify your understanding.

🎯 Learning Objectives

By the end of this workshop, you will be able to:

# Skill
1 Architect a production-ready agent harness using the create_deep_agent factory
2 Configure multi-provider LLM orchestration (e.g., Anthropic for reasoning, OpenAI for tools)
3 Implement autonomous planning and sub-agent delegation for multi-faceted tasks
4 Execute a terminal-based TUI coding assistant using the Deep Agents CLI
5 Optimize token efficiency through automated context management and summarization

πŸ—οΈ The Workshop Tech Stack

Technology Category Purpose Setup
Python 3.11+ πŸ’» Local Core runtime Download
uv πŸ’» Local Dependency manager curl -LsSf https://astral.sh/uv/install.sh | sh
Deep Agents SDK πŸ“¦ Package The agent harness uv add deepagents
Anthropic / OpenAI ☁️ SaaS Reasoning & tools API keys + credits
LangSmith ☁️ SaaS Observability & tracing Account + API key
Tavily ☁️ SaaS Web search API key (free tier available)
Modal ☁️ SaaS Remote GPU sandbox Account + uv run modal setup

πŸ” Deep Dive: The Hybrid Architecture

This workshop uses a Hybrid Infrastructure model. The "Brain" (LLM) and "Eyes" (Search) live in the cloud to minimize local hardware requirements, while the "Hands" (state management, file I/O) run locally for maximum security and control.


πŸ› οΈ Module 0: Prerequisites & Setup

Before we start, ensure your environment is ready.

Important

This workshop requires Python 3.11+ and a valid API key for an LLM provider (OpenAI is the default).

1. Installation

# Recommended: Using uv
uv add deepagents

# Traditional: Using pip
pip install deepagents

2. Environment Configuration

export OPENAI_API_KEY="your-key-here"
# Optional: For Anthropic models
export ANTHROPIC_API_KEY="your-key-here"

πŸš€ Module 1: Your First Agent

In this module, we'll run a "Health Check" agent. Deep Agents provides a create_deep_agent() factory that sets up planning, filesystem tools, and context management out of the box.

The Code

Create a file named simple_agent.py:

from deepagents import create_deep_agent

# Initialize the agent with smart defaults
# This includes planning, file access, and sub-agent capabilities
agent = create_deep_agent()

# Execute a research task
result = agent.invoke({
    "messages": [
        {"role": "user", "content": "Explain the difference between an Agent and a Chain."}
    ]
})

print(result["messages"][-1].content)

Note

Wait, why? In high-stakes environments, you don't want an agent starting from scratch. By using a harness, the agent inherits a pre-defined "memory" of how to plan and use files, drastically reducing the number of turns needed to solve a problem.

πŸ›‘ Common Gotcha: API Key Scope

If you see an "Authentication Error," ensure your OPENAI_API_KEY is exported in the same terminal session where you run the script. API keys do not persist across different terminal windows unless added to your .zshrc or .bashrc.

βœ… Module 1 Self-Check

  • What is the difference between create_deep_agent() and a standard LangChain ChatOpenAI call?
  • In the result, why is the final message usually an AIMessage?

πŸ”§ Module 2: Customizing Brain & Hands

Now, let's make the agent our own. We'll swap the model to Claude 3.5 Sonnet and add a custom tool.

Learning Lab: The Weather Agent

Create custom_agent.py:

from langchain_core.tools import tool
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent

@tool
def get_weather(city: str):
    """Get the current weather for a specific city."""
    # In a real app, you'd call an API here
    return f"The weather in {city} is sunny, 72Β°F."

# 1. Swap the model (requires anthropic SDK: uv add anthropic)
model = init_chat_model("anthropic:claude-3-5-sonnet-latest")

# 2. Re-create the agent with custom components
agent = create_deep_agent(
    model=model,
    tools=[get_weather],
    system_prompt="You are a friendly travel assistant."
)

# Test it out!
agent.invoke({"messages": [{"role": "user", "content": "What's the weather in Tokyo?"}]})

🧠 Module 3: Sub-Agents & Task Planning

Deep Agents excels at Planning. It uses a write_todos tool to break down complex goals into smaller pieces.

πŸ” Deep Dive: The Planning Cycle

Deep Agents uses a "Write-Then-Execute" pattern. When a complex prompt is received, the agent doesn't start calling tools immediately. Instead, it calls write_todos, which updates a stateful list in the LangGraph memory. This list serves as a dynamic anchor, preventing the agent from "getting lost" in long-running tasks.

βœ… Module 3 Self-Check

  • How does the task tool maintain a separate context window from the main agent?
  • What would happen if the researcher sub-agent failed? Does it stop the whole process? (Hint: See "Error Handling" in the full docs).

Challenge: Multi-Step Research

Try asking the agent:

"Research the top 3 AI papers of 2024, write a summary for each to a new file 'research.txt', and then create a sub-task to check for any critical critiques of those papers."


πŸ–₯️ Module 4: The Deep Agents CLI

The SDK also powers a TUI (Terminal User Interface) β€” a "batteries-included" coding assistant that runs in your terminal.

Installation & Run

# One-line installer
curl -LsSf https://raw.githubusercontent.com/langchain-ai/deepagents/main/libs/cli/scripts/install.sh | bash

# Fire it up
deepagents

Key Features to Try:

Feature Description
/slash commands Quick actions for common tasks
Web search Search the web directly from the prompt
Background shell Execute shell commands in the background

🌍 Exploration: Advanced Patterns

The core modules covered the foundation. To see how these principles scale to production, explore the Advanced Patterns in our examples directory:

Pattern Example Learning Outcome
πŸš€ Recursive deep_research Master the "Thinking Tool" for multi-step web research and strategic reflection
🏎️ Heterogeneous nvidia_deep_agent Orchestrate frontier models with specialized GPU-accelerated research nodes
🎨 Asset Pipeline content-builder Bundle persona memory, task skills, and image generation into a content engine
πŸ“Š Disclosure text-to-sql Implement progressive schema exploration for lean, efficient SQL agents
πŸ” Persistent ralph_mode Build long-running project loops with fresh context and Git-based memory
πŸ“¦ Portable downloading Distribute and version "Brain Folders" as portable agent artifacts
🌐 Distributed async-subagent Scale agents across infrastructure using the async Agent Protocol

Tip

Recommended Path: Start with deep_research to understand planning, then move to async-subagent to see how to host your agents as services.


🏁 Completion & Next Steps

Congratulations! You've successfully navigated the core features of Deep Agents.

πŸ“š Resources for Further Learning

Resource Description
Full Documentation Deep dives into ACP, custom skills, and sandboxing
Examples Directory Pre-built patterns for different domains
ArtiPortal Workshops More interactive AI training
Intro to Agents (LangChain) Core primitives explained
LangChain Academy Fast-paced courses on building with LangGraph
LangSmith Dashboard Visualize and debug every agent turn in real time

πŸ†˜ Support & Community

  • Lab Support: Contact labs@artiportal.com for workshop help.
  • GitHub Issues: Report bugs or request features.
  • LangChain Forum: Connect with other agent builders.

πŸ“ Workshop Summary & Key Takeaways

Pillar Insight
Framework over Feature Deep Agents provides a pre-configured LangGraph architecture that tracks state and history automatically β€” solving the "blank page" problem.
Autonomous Planning The write_todos tool creates a structured roadmap and follows it, significantly reducing mid-task drift.
Modular Power Swap frontier models (GPT-4o, Claude 3.5) while keeping your custom tools and system prompts intact β€” provider-agnostic by design.
Operational Efficiency Auto-summarization and file-based tool outputs manage token costs and context window limits β€” essential, not optional.

Final Challenge: Take the custom_agent.py you built in Module 2 and integrate it with the Sub-Agent logic from Module 3. Can you build an agent that researches a city and provides a weather-based travel itinerary in a single run?


πŸ›‘ Workshop Cleanup & Security

Warning

Prevent unexpected charges: revoke keys and shut down infrastructure before you log off.

Steps

Step Action
1 Revoke API Keys β€” OpenAI, Anthropic, Tavily, and LangSmith dashboard
2 Stop Modal sandboxes β€” modal sandbox list and terminate any active ones
3 Kill local servers β€” Ctrl+C any running uvicorn or langgraph dev processes
4 Clear env vars β€” remove keys from .zshrc/.bashrc and delete .env files
rm -f .env
unset OPENAI_API_KEY ANTHROPIC_API_KEY TAVILY_API_KEY LANGSMITH_API_KEY

πŸ“– Glossary of Terms

Term Definition
Agent Harness The structural "plumbing" (state, tools, memory) that wraps around an LLM to make it functional.
Skill A specific, file-based instruction (SKILL.md) that teaches the agent a new capability on the fly.
Memory Persistent instructions stored in AGENTS.md that define the agent's persona and rules.
Sub-Agent A specialized agent spawned by a "Supervisor" to handle a specific sub-task in isolation.
LangGraph The underlying orchestration engine that manages the agent's stateful, cyclic workflow.
TUI Terminal User Interface β€” the rich, interactive visual system used by the Deep Agents CLI.

πŸ“š Resources & Further Reading

Note

Origin & Acknowledgements This repository is a specialized workshop fork of the original Deep Agents project by LangChain, Inc. It has been restructured and enhanced with pedagogical scaffolding, lab exercises, and detailed architectural guides by ArtiPortal.com.

πŸ”° Foundational

πŸ§ͺ Advanced Deep Dives

πŸ› οΈ Developer Tools


Thank you for participating! We look forward to seeing what you build next.


Python License deepagents


Β© 2026 ArtiPortal.com | Based on the MIT-licensed LangChain Deep Agents project

About

This workshop uses a Hybrid Infrastructure model. The "Brain" (LLM) and "Eyes" (Search) live in the cloud to minimize your local hardware requirements, while the "Hands" (State management, File IO) live on your local machine for maximum security and control.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages