@GitHub_Daily: 用 AI 处理长周期复杂任务,随着上下文越来越长,模型容易出现「忘事」,输出质量也直线下降。 LangChain 官方团队开源了一套教程:Deep Agents from Scratch,从零拆解主流 Agent 的核心设计模式,讲得很透…

X AI KOLs Timeline 工具

摘要

LangChain 官方团队开源了教程 'Deep Agents from Scratch',从零拆解主流 Agent 的核心设计模式,涵盖任务规划、上下文卸载到文件系统以及子代理隔离等思路,共 5 个渐进式 Notebook,可上手搭建完整深度研究 Agent。

用 AI 处理长周期复杂任务,随着上下文越来越长,模型容易出现「忘事」,输出质量也直线下降。 LangChain 官方团队开源了一套教程:Deep Agents from Scratch,从零拆解主流 Agent 的核心设计模式,讲得很透彻。 教程总结了 Manus、Claude Code 等Agent 的解决思路:任务规划、上下文卸载到文件系统、以及通过子代理实现上下文隔离。 GitHub:http://github.com/langchain-ai/deep-agents-from-scratch… 一共 5 个渐进式 Notebook,从最基础的 ReAct 循环开始,逐步加入 TODO 任务管理、虚拟文件系统、子代理委派,最后整合成一个完整的深度研究 Agent。 每一步都能跑通看到效果,不是纯理论,最终搭出来的 Agent 能做真实的网络搜索和多步骤分析任务。 想搞懂当前主流 Agent 到底是怎么设计的,或者正准备自己搭一个,这套教程值得跟着做一遍。
查看原文
查看缓存全文

缓存时间: 2026/06/28 01:57

用 AI 处理长周期复杂任务,随着上下文越来越长,模型容易出现「忘事」,输出质量也直线下降。

LangChain 官方团队开源了一套教程:Deep Agents from Scratch,从零拆解主流 Agent 的核心设计模式,讲得很透彻。

教程总结了 Manus、Claude Code 等Agent 的解决思路:任务规划、上下文卸载到文件系统、以及通过子代理实现上下文隔离。

GitHub:http://github.com/langchain-ai/deep-agents-from-scratch…

一共 5 个渐进式 Notebook,从最基础的 ReAct 循环开始,逐步加入 TODO 任务管理、虚拟文件系统、子代理委派,最后整合成一个完整的深度研究 Agent。

每一步都能跑通看到效果,不是纯理论,最终搭出来的 Agent 能做真实的网络搜索和多步骤分析任务。

想搞懂当前主流 Agent 到底是怎么设计的,或者正准备自己搭一个,这套教程值得跟着做一遍。


langchain-ai/deep-agents-from-scratch

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

🧱 Deep Agents from Scratch

Screenshot 2025-08-12 at 2 13 54 PM

Deep Research 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 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 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 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.

相似文章

@GitHub_Daily: 用 AI 智能体生产级事情,写代码、跑流程、调接口,一开始还行,但规模一大就容易失控,权限太宽、上下文丢失、调试无从下手。 于是找到了 agents-best-practices 这套完整的智能体运行框架设计指南,不限于编码场景,运营、销…

X AI KOLs Timeline

介绍了 agents-best-practices 仓库,这是一份生产级 AI 智能体运行框架设计指南,涵盖工具权限分级、上下文压缩等,支持 Codex 和 Claude Code 安装。

@vintcessun: 今晚翻到一个学习路线项目,重新理解了Agent该从哪开始学。以前总觉得Agent就是堆工具和框架,但它的核心是那个“观察-思考-执行”循环,以及harness工程对权限、状态、回溯的组织。它把学习拆成从0构建最小Agent loop到最终…

X AI KOLs Timeline

一个名为Agent-Learning-Hub的开源学习路线项目,将AI Agent学习拆分为8个阶段,从构建最小Agent loop到生产部署,提供可执行的todo list和推荐资源,由Datawhale社区成员维护。