概览
本 guide 演示如何使用 Deep Agents 从头构建 multi-step web research agent。该 agent 会将 research questions 分解为 focused tasks,委派给 specialized sub-agents,并将 findings 综合成 comprehensive report。 你构建的 agent 将会:- 使用 todo list 规划 research
- 将 focused research tasks 委派给带 isolated context 的 sub-agents
- 在收集 information 时评估 search results 并规划 next steps
- 将 findings 与适当 citations 综合成 final report
Key concepts
本 tutorial 涵盖:- 用于 parallel、context-isolated research 的 Subagents
- 用于 web search 的 custom tools
- 使用 built-in planning tool 进行 multi-step planning
Prerequisites
需要以下 API keys:Setup
构建 agent
在 project directory 中创建agent.py:
添加 tools
添加 custom search tool。
tavily_search tool 使用 Tavily 进行 URL discovery,然后 fetch full webpage content,让 agent 可以分析 complete sources,而不是 summaries。运行 agent
你可以 synchronously 运行 agent,也就是等待完整 result 后打印;也可以在 updates 到达时 stream 它们。 将相应 tab 中的 code 添加到agent.py 底部:
- Run synchronously
- Stream updates
LANGSMITH_API_KEY environment variable,就可以在 LangSmith 中查看 agent traces,以 debug 和 monitor multi-step behavior。
完整代码
在 GitHub 上查看完整 Deep Research example。下一步
现在你已经构建了 agent,可以通过更改 agent file 中的 prompt constants 来调整 workflow、delegation strategy 或 researcher behavior。 你也可以调整 delegation limits,以允许更多 parallel sub-agents 或 delegation rounds。 如需了解本 tutorial 中 concepts 的更多信息,请查看以下 resources:- Subagents:了解如何使用不同 tools 和 prompts 配置 subagents
- Customization:自定义 models、tools、system prompts 和 planning behavior
- LangSmith:Trace research runs 并 debug multi-step behavior
- Deep Research Course:关于使用 LangGraph 进行 deep research 的完整课程
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

