npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

deepagentsjs

v0.0.0

Published

Deep Agents - a library for building controllable AI agents with LangGraph

Downloads

35

Readme

🧠🤖Deep Agents

Using an LLM to call tools in a loop is the simplest form of an agent. This architecture, however, can yield agents that are "shallow" and fail to plan and act over longer, more complex tasks. Applications like "Deep Research", "Manus", and "Claude Code" have gotten around this limitation by implementing a combination of four things: a planning tool, sub agents, access to a file system, and a detailed prompt.

deepagents is a TypeScript package that implements these in a general purpose way so that you can easily create a Deep Agent for your application.

![TIP] Looking for the Python version of this package? See here: hwchase17/deepagents

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.

Installation

yarn add deepagentsjs

Usage

(To run the example below, you will need to install tavily: yarn add @langchain/tavily)

import { TavilySearch } from "@langchain/tavily";
import { createDeepAgent } from "deepagentsjs";

// Search tool to use to do research
const internetSearch = new TavilySearch({
  maxResults: 5,
  tavilyApiKey: process.env.TAVILY_API_KEY,
});

// Prompt prefix to steer the agent to be an expert researcher
const researchInstructions = `You are an expert researcher. Your job is to conduct thorough research, and then write a polished report.

You have access to a few tools.

## \`internet_search\`

Use 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.
`;

// Create the agent
const agent = createDeepAgent({
  tools: [internetSearch],
  instructions: researchInstructions,
});

// Invoke the agent
const result = await agent.invoke({
  messages: [{ role: "user", content: "what is langgraph?" }]
});

See examples/research-agent.ts for a more complex example.

The agent created with createDeepAgent is just a LangGraph graph - so you can interact with it (streaming, human-in-the-loop, memory, studio) in the same way you would any LangGraph agent.

Creating a custom deep agent

There are three parameters you can pass to createDeepAgent to create your own custom deep agent.

tools (Required)

The first argument to createDeepAgent is tools. This should be a list of LangChain tools. The agent (and any subagents) will have access to these tools.

instructions (Required)

The second argument to createDeepAgent is instructions. This will serve as part of the prompt of the deep agent. Note that there is a built in system prompt as well, so this is not the entire prompt the agent will see.

subagents (Optional)

A keyword-only argument to createDeepAgent is subagents. This can be used to specify any custom subagents this deep agent will have access to. You can read more about why you would want to use subagents here

subagents should be a list of objects, where each object follows this schema:

interface SubAgent {
  name: string;
  description: string;
  prompt: string;
  tools?: string[];
}
  • name: This is the name of the subagent, and how the main agent will call the subagent
  • description: This is the description of the subagent that is shown to the main agent
  • prompt: This is the prompt used for the subagent
  • 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.

To use it looks like:

const researchSubAgent = {
  name: "research-agent",
  description: "Used to research more in depth questions",
  prompt: subResearchPrompt,
};

const subagents = [researchSubAgent];

const agent = createDeepAgent({
  tools,
  instructions: prompt,
  subagents
});

model (Optional)

By default, deepagents will use "claude-sonnet-4-20250514". If you want to use a different model, you can pass a LangChain model object.

Deep Agent Details

The below components are built into deepagents and helps make it work for deep tasks off-the-shelf.

System Prompt

deepagents comes with a built-in system prompt. This is relatively detailed prompt that is heavily based on and inspired by attempts to replicate Claude Code's system prompt. It was made more general purpose than Claude Code's system prompt. This contains detailed instructions for how to use the built-in planning tool, file system tools, and sub agents. Note that part of this system prompt can be customized

Without this default system prompt - the agent would not be nearly as successful at going as it is. The importance of prompting for creating a "deep" agent cannot be understated.

Planning Tool

deepagents comes with a built-in planning tool. This planning tool is very simple and is based on ClaudeCode's TodoWrite tool. This 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.

File System Tools

deepagents comes with four built-in file system tools: ls, edit_file, read_file, write_file. These do not actually use a file system - rather, they mock out a file system using LangGraph's State object. This means you can easily run many of these agents on the same machine without worrying that they will edit the same underlying files.

Right now the "file system" will only be one level deep (no sub directories).

These files can be passed in (and also retrieved) by using the files key in the LangGraph State object.

const agent = createDeepAgent({ ... });

const result = await agent.invoke({
  messages: [...],
  // Pass in files to the agent using this key
  // files: {"foo.txt": "foo", ...}
});

// Access any files afterwards like this
result.files;

Sub Agents

deepagents comes with the built-in ability to call sub agents (based on Claude Code). It 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. You can also specify custom sub agents with their own instructions and tools.

Sub agents are useful for "context quarantine" (to help not pollute the overall context of the main agent) as well as custom instructions.