跳到主要内容

模型

默认情况下,deepagents使用"claude-sonnet-4-5-20250929"。您可以通过传递任何LangChain 模型对象来自定义此设置。
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent

model = init_chat_model(
    model="gpt-5",
)
agent = create_deep_agent(
    model=model,
)

系统提示

深度代理自带一个受Claude Code系统提示启发的内置系统提示。默认系统提示包含使用内置规划工具、文件系统工具和子代理的详细说明。 为特定用例量身定制的每个深度代理都应包含特定于该用例的自定义系统提示。
from deepagents import create_deep_agent

research_instructions = """\
You are an expert researcher. Your job is to conduct \
thorough research, and then write a polished report. \
"""

agent = create_deep_agent(
    system_prompt=research_instructions,
)

工具

就像工具调用代理一样,深度代理可以访问一组顶级工具。
import os
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent

tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])

def internet_search(
    query: str,
    max_results: int = 5,
    topic: Literal["general", "news", "finance"] = "general",
    include_raw_content: bool = False,
):
    """Run a web search"""
    return tavily_client.search(
        query,
        max_results=max_results,
        include_raw_content=include_raw_content,
        topic=topic,
    )

agent = create_deep_agent(
    tools=[internet_search]
)
除了您提供的任何工具外,深度代理还可以访问许多默认工具
  • write_todos – 更新代理的待办事项列表
  • ls – 列出代理文件系统中的所有文件
  • read_file – 从代理文件系统中读取文件
  • write_file – 在代理文件系统中写入新文件
  • edit_file – 编辑代理文件系统中的现有文件
  • task – 生成一个子代理来处理特定任务

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.