{"id":29858253,"url":"https://github.com/hwchase17/deepagents","last_synced_at":"2025-08-03T05:05:25.269Z","repository":{"id":306863479,"uuid":"1027384981","full_name":"hwchase17/deepagents","owner":"hwchase17","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-29T21:35:00.000Z","size":48,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-30T02:06:38.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hwchase17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-27T23:07:53.000Z","updated_at":"2025-07-29T22:15:16.000Z","dependencies_parsed_at":"2025-07-30T02:06:43.408Z","dependency_job_id":"e60b37f5-3a83-42f9-81cb-e1b2e08ddc0d","html_url":"https://github.com/hwchase17/deepagents","commit_stats":null,"previous_names":["hwchase17/claude-everything","hwchase17/deepagents"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/hwchase17/deepagents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwchase17%2Fdeepagents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwchase17%2Fdeepagents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwchase17%2Fdeepagents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwchase17%2Fdeepagents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hwchase17","download_url":"https://codeload.github.com/hwchase17/deepagents/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hwchase17%2Fdeepagents/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267974764,"owners_count":24174557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-30T01:40:35.279Z","updated_at":"2025-07-31T02:01:53.067Z","avatar_url":"https://github.com/hwchase17.png","language":"Python","funding_links":[],"categories":["A01_文本生成_文本对话","Python"],"sub_categories":["大语言对话模型及数据"],"readme":"# 🧠🤖Deep Agents\n\nUsing an LLM to call tools in a loop is the simplest form of an agent. \nThis architecture, however, can yield agents that are “shallow” and fail to plan and act over longer, more complex tasks. \nApplications like “Deep Research”, \"Manus\", and “Claude Code” have gotten around this limitation by implementing a combination of four things:\na **planning tool**, **sub agents**, access to a **file system**, and a **detailed prompt**.\n\n\u003cimg src=\"deep_agents.png\" alt=\"deep agent\" width=\"600\"/\u003e\n\n`deepagents` is a Python package that implements these in a general purpose way so that you can easily create a Deep Agent for your application.\n\n**Acknowledgements: This project was primarily inspired by Claude Code, and initially was largely an attempt to see what made Claude Code general purpose, and make it even more so.**\n\n## Installation\n\n```bash\npip install deepagents\n```\n\n## Usage\n\n(To run the example below, will need to `pip install tavily-python`)\n\n```python\nimport os\nfrom typing import Literal\n\nfrom tavily import TavilyClient\nfrom deepagents import create_deep_agent\n\n\n# Search tool to use to do research\ndef internet_search(\n    query: str,\n    max_results: int = 5,\n    topic: Literal[\"general\", \"news\", \"finance\"] = \"general\",\n    include_raw_content: bool = False,\n):\n    \"\"\"Run a web search\"\"\"\n    tavily_async_client = TavilyClient(api_key=os.environ[\"TAVILY_API_KEY\"])\n    return tavily_async_client.search(\n        query,\n        max_results=max_results,\n        include_raw_content=include_raw_content,\n        topic=topic,\n    )\n\n\n# Prompt prefix to steer the agent to be an expert researcher\nresearch_instructions = \"\"\"You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.\n\nYou have access to a few tools.\n\n## `internet_search`\n\nUse this to run an internet search for a given query. You can specify the number of results, the topic, and whether raw content should be included.\n\"\"\"\n\n# Create the agent\nagent = create_deep_agent(\n    [internet_search],\n    research_instructions,\n)\n\n# Invoke the agent\nresult = agent.invoke({\"messages\": [{\"role\": \"user\", \"content\": \"what is langgraph?\"}]})\n```\n\nSee [examples/research/research_agent.py](examples/research/research_agent.py) for a more complex example.\n\nThe agent created with `create_deep_agent` is just a LangGraph graph - so you can interact with it (streaming, human-in-the-loop, memory, studio)\nin the same way you would any LangGraph agent.\n\n## Creating a custom deep agent\n\nThere are three parameters you can pass to `create_deep_agent` to create your own custom deep agent.\n\n### `tools` (Required)\n\nThe first argument to `create_deep_agent` is `tools`.\nThis should be a list of functions or LangChain `@tool` objects.\nThe agent (and any subagents) will have access to these tools.\n\n### `instructions` (Required)\n\nThe second argument to `create_deep_agent` is `instructions`.\nThis will serve as part of the prompt of the deep agent.\nNote that there is a [built in system prompt](#built-in-prompt) as well, so this is not the *entire* prompt the agent will see.\n\n### `subagents` (Optional)\n\nA keyword-only argument to `create_deep_agent` is `subagents`.\nThis can be used to specify any custom subagents this deep agent will have access to.\nYou can read more about why you would want to use subagents [here](#sub-agents)\n\n`subagents` should be a list of dictionaries, where each dictionary follow this schema:\n\n```python\nclass SubAgent(TypedDict):\n    name: str\n    description: str\n    prompt: str\n    tools: NotRequired[list[str]]\n```\n\n- **name**: This is the name of the subagent, and how the main agent will call the subagent\n- **description**: This is the description of the subagent that is shown to the main agent\n- **prompt**: This is the prompt used for the subagent\n- **tools**: This is the list of tools that the subagent has access to. By default will have access to all tools passed in, as well as all built-in tools.\n\nTo use it looks like:\n\n```python\nresearch_sub_agent = {\n    \"name\": \"research-agent\",\n    \"description\": \"Used to research more in depth questions\",\n    \"prompt\": sub_research_prompt,\n}\nsubagents = [research_subagent]\nagent = create_deep_agent(\n    tools,\n    prompt,\n    subagents=subagents\n)\n```\n\n### `model` (Optional)\n\nBy default, `deepagents` will use `\"claude-sonnet-4-20250514\"`. If you want to use a different model,\nyou can pass a [LangChain model object](https://python.langchain.com/docs/integrations/chat/).\n\n## Deep Agent Details\n\nThe below components are built into `deepagents` and helps make it work for deep tasks off-the-shelf.\n\n### System Prompt\n\n`deepagents` comes with a [built-in system prompt](src/deepagents/prompts.py). This is relatively detailed prompt that is heavily based on and inspired by [attempts](https://github.com/kn1026/cc/blob/main/claudecode.md) to [replicate](https://github.com/asgeirtj/system_prompts_leaks/blob/main/Anthropic/claude-code.md)\nClaude Code's system prompt. It was made more general purpose than Claude Code's system prompt.\nThis contains detailed instructions for how to use the built-in planning tool, file system tools, and sub agents.\nNote that part of this system prompt [can be customized](#promptprefix--required-)\n\nWithout this default system prompt - the agent would not be nearly as successful at going as it is.\nThe importance of prompting for creating a \"deep\" agent cannot be understated.\n\n### Planing Tool\n\n`deepagents` comes with a built-in planning tool. This planning tool is very simple and is based on ClaudeCode's TodoWrite tool.\nThis tool doesn't actually do anything - it is just a way for the agent to come up with a plan, and then have that in the context to help keep it on track.\n\n### File System Tools\n\n`deepagents` comes with four built-in file system tools: `ls`, `edit_file`, `read_file`, `write_file`.\nThese do not actually use a file system - rather, they mock out a file system using LangGraph's State object.\nThis means you can easily run many of these agents on the same machine without worrying that they will edit the same underlying files.\n\nRight now the \"file system\" will only be one level deep (no sub directories).\n\nThese files can be passed in (and also retrieved) by using the `files` key in the LangGraph State object.\n\n```python\nagent = create_deep_agent(...)\n\nresult = agent.invoke({\n    \"messages\": ...,\n    # Pass in files to the agent using this key\n    # \"files\": {\"foo.txt\": \"foo\", ...}\n})\n\n# Access any files afterwards like this\nresult[\"files\"]\n```\n\n### Sub Agents\n\n`deepagents` comes with the built-in ability to call sub agents (based on Claude Code).\nIt has access to a `general-purpose` subagent at all times - this is a subagent with the same instructions as the main agent and all the tools that is has access to.\nYou can also specify [custom sub agents](#subagents--optional-) with their own instructions and tools.\n\nSub agents are useful for [\"context quarantine\"](https://www.dbreunig.com/2025/06/26/how-to-fix-your-context.html#context-quarantine) (to help not pollute the overall context of the main agent)\nas well as custom instructions.\n\n## Roadmap\n[] Allow users to customize full system prompt\n[] Code cleanliness (type hinting, docstrings, formating)\n[] Allow for more of a robust virtual filesystem\n[] Create an example of a deep coding agent built on top of this\n[] Benchmark the example of [deep research agent](examples/research/research_agent.py)\n[] Add human-in-the-loop support for tools\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwchase17%2Fdeepagents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhwchase17%2Fdeepagents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhwchase17%2Fdeepagents/lists"}