@GitHub_Daily: AI for long-running complex tasks: as context grows, models tend to 'forget' and output quality drops sharply. The LangChain team has open-sourced a tutorial: Deep Agents from Scratch, which deconstructs core design patterns of mainstream agents from scratch, explained thoroughly...

X AI KOLs Timeline Tools

Summary

The LangChain team has open-sourced the tutorial 'Deep Agents from Scratch', which deconstructs the core design patterns of mainstream agents from scratch, covering task planning, context offloading to a file system, and sub-agent isolation. It includes 5 progressive notebooks, allowing you to build a complete deep research agent hands-on.

When using AI for long-running complex tasks, as the context gets longer, the model tends to 'forget' things, and the output quality drops sharply. The LangChain team has open-sourced a tutorial: Deep Agents from Scratch, which deconstructs the core design patterns of mainstream agents from scratch, explained very thoroughly. The tutorial summarizes the approaches of agents like Manus and Claude Code: task planning, context offloading to a file system, and context isolation through sub-agents. GitHub: http://github.com/langchain-ai/deep-agents-from-scratch... There are 5 progressive notebooks in total, starting from the most basic ReAct loop, gradually adding TODO task management, virtual file system, sub-agent delegation, and finally integrating into a complete deep research agent. Every step can be run and the results seen; it's not pure theory. The final built agent can perform real web searches and multi-step analysis tasks. If you want to understand how current mainstream agents are designed, or you are about to build one yourself, this tutorial is worth following along.
Original Article
View Cached Full Text

Cached at: 06/28/26, 01:57 AM

Using AI for long-horizon complex tasks, the model tends to “forget” things as the context grows longer, and output quality drops sharply. The LangChain official team has open-sourced a tutorial: Deep Agents from Scratch, which breaks down the core design patterns of mainstream agents from the ground up with thorough explanations. The tutorial summarizes the solutions used by agents like Manus and Claude Code: task planning, context offloading to the file system, and context isolation via sub-agents.
GitHub: http://github.com/langchain-ai/deep-agents-from-scratch

It consists of 5 progressive notebooks, starting from the most basic ReAct loop, gradually adding TODO task management, a virtual file system, sub-agent delegation, and finally integrating into a complete deep research agent. Each step is runnable and shows tangible results — it’s not pure theory. The final agent can perform real web searches and multi-step analysis tasks. If you want to understand how current mainstream agents are actually designed, or if you are planning to build one yourself, this tutorial is well worth following through.


langchain-ai/deep-agents-from-scratch

Source: https://github.com/langchain-ai/deep-agents-from-scratch

🧱 Deep Agents from Scratch

Deep Research (https://academy.langchain.com/courses/deep-research-with-langgraph) broke out as one of the first major agent use-cases along with coding. Now, we’ve seeing an emergence of general purpose agents that can be used for a wide range of tasks. For example, Manus (https://manus.im/blog/Context-Engineering-for-AI-Agents-Lessons-from-Building-Manus) has gained significant attention and popularity for long-horizon tasks; the average Manus task uses ~50 tool calls!. As a second example, Claude Code is being used generally for tasks beyond coding.

Careful review of the context engineering patterns (https://docs.google.com/presentation/d/16aaXLu40GugY-kOpqDU4e-S0hD1FmHcNyF0rRRnb1OU/edit?slide=id.p#slide=id.p) across these popular “deep” agents shows some common approaches:

  • Task planning (e.g., TODO), often with recitation
  • Context offloading to file systems
  • Context isolation through sub-agent delegation

This course will show how to implement these patterns from scratch using LangGraph!

🚀 Quickstart

Prerequisites

  • Ensure you’re using Python 3.11 or later.
  • This version is required for optimal compatibility with LangGraph.
python3 --version
  • uv (https://docs.astral.sh/uv/) package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Update PATH to use the new uv version
export PATH="/Users/$USER/.local/bin:$PATH"

Installation

  1. Clone the repository:
git clone https://github.com/langchain-ai/deep-agents-from-scratch.git
cd deep-agents-from-scratch
  1. Install the package and dependencies (this automatically creates and manages the virtual environment):
uv sync
  1. Create a .env file in the project root with your API keys:
# Create .env file
touch .env

Add your API keys to the .env file:

# Required for research agents with external search
TAVILY_API_KEY=your_tavily_api_key_here

# Required for model usage
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Optional: For evaluation and tracing
LANGSMITH_API_KEY=your_langsmith_api_key_here
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=deep-agents-from-scratch
  1. Run notebooks or code using uv:
# Run Jupyter notebooks directly
uv run jupyter notebook

# Or activate the virtual environment if preferred
source .venv/bin/activate
# On Windows: .venv\Scripts\activate
jupyter notebook

📚 Tutorial Overview

This repository contains five progressive notebooks that teach you to build advanced AI agents:

0_create_agent.ipynb

  • Learn how to use the create_agent component. This component
    • implements a ReAct (Reason - Act) loop that forms the foundation for many agents.
    • is easy to use and quick to set up.
    • serves as the basis for the following lessons.

1_todo.ipynb

  • Task Planning Foundations Learn to implement structured task planning using TODO lists. This notebook introduces:
  • Task tracking with status management (pending/in_progress/completed)
  • Progress monitoring and context management
  • The write_todos() tool for organizing complex multi-step workflows
  • Best practices for maintaining focus and preventing task drift

2_files.ipynb

  • Virtual File Systems Implement a virtual file system stored in agent state for context offloading:
  • File operations: ls(), read_file(), write_file(), edit_file()
  • Context management through information persistence
  • Enabling agent “memory” across conversation turns
  • Reducing token usage by storing detailed information in files

3_subagents.ipynb

  • Context Isolation Master sub-agent delegation for handling complex workflows:
  • Creating specialized sub-agents with focused tool sets
  • Context isolation to prevent confusion and task interference
  • The task() delegation tool and agent registry patterns
  • Parallel execution capabilities for independent research streams

4_full_agent.ipynb

  • Complete Research Agent Combine all techniques into a production-ready research agent:
  • Integration of TODOs, files, and sub-agents
  • Real web search with intelligent context offloading
  • Content summarization and strategic thinking tools
  • Complete workflow for complex research tasks with LangGraph Studio integration

Each notebook builds on the previous concepts, culminating in a sophisticated agent architecture capable of handling real-world research and analysis tasks.

Similar Articles

@GitHub_Daily: Many tutorials teach AI Agent development by jumping straight into frameworks — you install it and it runs, but you don't really understand what's going on underneath. ai-agents-from-scratch takes the opposite approach, starting from the most basic model call and gradually building up core patterns like tool calling, memory, and ReAct loops. It uses local models throughout…

X AI KOLs Timeline

GitHub_Daily recommends an open-source project called ai-agents-from-scratch. It starts from zero and uses local models to gradually implement core patterns such as tool calling, memory, and ReAct loops, helping developers understand the underlying principles of AI Agents without directly using frameworks.

@Huahuazo: I want to understand how to build an Agent from scratch, not just call APIs—I've looked through many resources, and they're either too abstract or just hand you a finished product to tweak parameters, leaving the 'why design this way' part basically blank. LangChain's official Agents From Scratch...

X AI KOLs Timeline

LangChain's official Agents From Scratch tutorial provides a detailed guide on how to build an AI agent from scratch with human-in-the-loop and memory capabilities, covering four parts: basic setup, evaluation system, human-in-the-loop (HITL), and long-term memory.

@Jolyne_AI: LangChain official team has open-sourced a practical tutorial called "Agents From Scratch" that takes you from zero to building an AI Agent. You will hands-on create a smart assistant that can manage your email, step by step mastering key capabilities such as agent construction, evaluation system, human-machine collaboration, and memory mechanisms, and finally connect to real…

X AI KOLs Timeline

LangChain official team has open-sourced a hands-on tutorial "Agents From Scratch" for building an AI Agent from scratch, covering agent construction, evaluation, human-machine collaboration, memory mechanisms, and finally integrating with Gmail API to create a real email management assistant.

@GitHub_Daily: Using AI agents for production-grade tasks—writing code, running workflows, calling APIs—works fine initially, but as the scale grows, things easily get out of control: permissions too broad, context loss, and debugging becomes impossible. That's where agents-best-practices comes in: a complete guide to designing a runtime framework for AI agents, not limited to coding scenarios, but also applicable to operations, sales...

X AI KOLs Timeline

Introduces the agents-best-practices repository, a production-grade AI agent runtime framework design guide covering tool permission tiers, context compression, etc., supporting Codex and Claude Code installation.