deepagents 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -6
- package/README.md +490 -86
- package/dist/index.d.ts +624 -5
- package/dist/index.js +1866 -15
- package/package.json +64 -49
- package/dist/graph.d.ts +0 -46
- package/dist/graph.js +0 -44
- package/dist/model.d.ts +0 -4
- package/dist/model.js +0 -25
- package/dist/prompts.d.ts +0 -5
- package/dist/prompts.js +0 -102
- package/dist/state.d.ts +0 -15
- package/dist/state.js +0 -31
- package/dist/subAgent.d.ts +0 -30
- package/dist/subAgent.js +0 -72
- package/dist/tools.d.ts +0 -105
- package/dist/tools.js +0 -167
package/package.json
CHANGED
|
@@ -1,65 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepagents",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Deep Agents - a library for building controllable AI agents with LangGraph",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"
|
|
8
|
-
"dist/**/*"
|
|
9
|
-
],
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
7
|
+
"type": "module",
|
|
13
8
|
"repository": {
|
|
14
9
|
"type": "git",
|
|
15
|
-
"url": "git
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"dev": "node --import tsx src/examples/research/agent.ts",
|
|
20
|
-
"test": "jest"
|
|
10
|
+
"url": "git+https://github.com/langchain-ai/deepagentsjs.git"
|
|
21
11
|
},
|
|
22
12
|
"keywords": [
|
|
23
|
-
"langchain",
|
|
24
|
-
"langgraph",
|
|
25
|
-
"agents",
|
|
26
|
-
"llm",
|
|
27
13
|
"ai",
|
|
28
|
-
"
|
|
14
|
+
"agents",
|
|
15
|
+
"langgraph",
|
|
16
|
+
"langchain",
|
|
17
|
+
"typescript",
|
|
18
|
+
"llm"
|
|
29
19
|
],
|
|
30
|
-
"author": "
|
|
20
|
+
"author": "LangChain",
|
|
31
21
|
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/langchain-ai/deepagentsjs/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/langchain-ai/deepagentsjs#readme",
|
|
32
26
|
"dependencies": {
|
|
33
|
-
"@langchain/anthropic": "^0.
|
|
34
|
-
"@langchain/
|
|
35
|
-
"@langchain/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
27
|
+
"@langchain/anthropic": "^1.0.0",
|
|
28
|
+
"@langchain/core": "^1.0.0",
|
|
29
|
+
"@langchain/langgraph": "^1.0.0",
|
|
30
|
+
"fast-glob": "^3.3.3",
|
|
31
|
+
"langchain": "^1.0.4",
|
|
32
|
+
"micromatch": "^4.0.8",
|
|
33
|
+
"zod": "^4.1.11"
|
|
39
34
|
},
|
|
40
35
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
36
|
+
"@changesets/cli": "^2.29.7",
|
|
37
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
38
|
+
"@eslint/js": "^9.19.0",
|
|
39
|
+
"@langchain/langgraph-checkpoint": "^0.0.13",
|
|
40
|
+
"@langchain/openai": "^1.0.0",
|
|
41
|
+
"@langchain/tavily": "^0.1.4",
|
|
42
|
+
"@tsconfig/recommended": "^1.0.10",
|
|
43
|
+
"@types/micromatch": "^4.0.10",
|
|
44
|
+
"@types/node": "^22.13.5",
|
|
45
|
+
"@types/uuid": "^10.0.0",
|
|
46
|
+
"@vitest/ui": "^2.1.8",
|
|
47
|
+
"dotenv": "^17.2.1",
|
|
48
|
+
"eslint": "^9.19.0",
|
|
49
|
+
"eslint-config-prettier": "^8.8.0",
|
|
50
|
+
"eslint-plugin-import": "^2.27.5",
|
|
51
|
+
"eslint-plugin-no-instanceof": "^1.0.1",
|
|
52
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
53
|
+
"globals": "^15.0.0",
|
|
54
|
+
"prettier": "^3.6.2",
|
|
55
|
+
"tsdown": "^0.15.12",
|
|
56
|
+
"tsx": "^4.20.5",
|
|
57
|
+
"typescript": "^5.9.2",
|
|
58
|
+
"typescript-eslint": "^8.22.0",
|
|
59
|
+
"uuid": "^11.0.5",
|
|
60
|
+
"vitest": "^2.1.8"
|
|
50
61
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
"files": [
|
|
63
|
+
"dist/**/*"
|
|
64
|
+
],
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsdown",
|
|
67
|
+
"dev": "tsc --watch",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"lint": "eslint src/**/*.ts examples/**/*.ts",
|
|
70
|
+
"lint:fix": "eslint src/**/*.ts examples/**/*.ts --fix",
|
|
71
|
+
"format": "prettier --write \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
|
|
72
|
+
"format:check": "prettier --check \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"test:watch": "vitest",
|
|
75
|
+
"test:ui": "vitest --ui",
|
|
76
|
+
"test:coverage": "vitest run --coverage",
|
|
77
|
+
"start": "node dist/index.js",
|
|
78
|
+
"release": "pnpm build && changeset publish"
|
|
64
79
|
}
|
|
65
|
-
}
|
|
80
|
+
}
|
package/dist/graph.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { StructuredTool } from "@langchain/core/tools";
|
|
2
|
-
import { LanguageModelLike } from "@langchain/core/language_models/base";
|
|
3
|
-
import { SubAgent } from "./subAgent.js";
|
|
4
|
-
import { DeepAgentState } from "./state.js";
|
|
5
|
-
export interface CreateDeepAgentOptions {
|
|
6
|
-
tools: StructuredTool[];
|
|
7
|
-
instructions: string;
|
|
8
|
-
model?: string | LanguageModelLike;
|
|
9
|
-
subagents?: SubAgent[];
|
|
10
|
-
stateSchema?: typeof DeepAgentState;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Create a deep agent.
|
|
14
|
-
*
|
|
15
|
-
* This agent will by default have access to a tool to write todos (write_todos),
|
|
16
|
-
* and then four file editing tools: write_file, ls, read_file, edit_file.
|
|
17
|
-
*
|
|
18
|
-
* @param options Configuration options for the deep agent
|
|
19
|
-
* @returns A LangGraph agent
|
|
20
|
-
*/
|
|
21
|
-
export declare function createDeepAgent(options: CreateDeepAgentOptions): import("@langchain/langgraph").CompiledStateGraph<import("@langchain/langgraph").StateType<{
|
|
22
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[]>;
|
|
23
|
-
todos: import("@langchain/langgraph").BinaryOperatorAggregate<import("./state.js").Todo[], import("./state.js").Todo[]>;
|
|
24
|
-
files: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
|
|
25
|
-
}>, import("@langchain/langgraph").UpdateType<{
|
|
26
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[]>;
|
|
27
|
-
todos: import("@langchain/langgraph").BinaryOperatorAggregate<import("./state.js").Todo[], import("./state.js").Todo[]>;
|
|
28
|
-
files: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
|
|
29
|
-
}>, any, {
|
|
30
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/langgraph").Messages>;
|
|
31
|
-
} & {
|
|
32
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[]>;
|
|
33
|
-
todos: import("@langchain/langgraph").BinaryOperatorAggregate<import("./state.js").Todo[], import("./state.js").Todo[]>;
|
|
34
|
-
files: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
|
|
35
|
-
}, {
|
|
36
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/langgraph").Messages>;
|
|
37
|
-
structuredResponse: {
|
|
38
|
-
(): import("@langchain/langgraph").LastValue<Record<string, any>>;
|
|
39
|
-
(annotation: import("@langchain/langgraph").SingleReducer<Record<string, any>, Record<string, any>>): import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, any>, Record<string, any>>;
|
|
40
|
-
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
41
|
-
};
|
|
42
|
-
} & {
|
|
43
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[], import("@langchain/core/messages", { with: { "resolution-mode": "import" } }).BaseMessage[]>;
|
|
44
|
-
todos: import("@langchain/langgraph").BinaryOperatorAggregate<import("./state.js").Todo[], import("./state.js").Todo[]>;
|
|
45
|
-
files: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
|
|
46
|
-
}, import("@langchain/langgraph").StateDefinition>;
|
package/dist/graph.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDeepAgent = createDeepAgent;
|
|
4
|
-
const prebuilt_1 = require("@langchain/langgraph/prebuilt");
|
|
5
|
-
const subAgent_js_1 = require("./subAgent.js");
|
|
6
|
-
const state_js_1 = require("./state.js");
|
|
7
|
-
const model_js_1 = require("./model.js");
|
|
8
|
-
const tools_js_1 = require("./tools.js");
|
|
9
|
-
const BASE_PROMPT = `You have access to a number of standard tools
|
|
10
|
-
|
|
11
|
-
## \`write_todos\`
|
|
12
|
-
|
|
13
|
-
You have access to the \`write_todos\` tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
14
|
-
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
15
|
-
|
|
16
|
-
It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
|
|
17
|
-
|
|
18
|
-
## \`task\`
|
|
19
|
-
|
|
20
|
-
- When doing web search, prefer to use the \`task\` tool in order to reduce context usage.`;
|
|
21
|
-
/**
|
|
22
|
-
* Create a deep agent.
|
|
23
|
-
*
|
|
24
|
-
* This agent will by default have access to a tool to write todos (write_todos),
|
|
25
|
-
* and then four file editing tools: write_file, ls, read_file, edit_file.
|
|
26
|
-
*
|
|
27
|
-
* @param options Configuration options for the deep agent
|
|
28
|
-
* @returns A LangGraph agent
|
|
29
|
-
*/
|
|
30
|
-
function createDeepAgent(options) {
|
|
31
|
-
const { tools, instructions, model, subagents = [], stateSchema = state_js_1.DeepAgentState, } = options;
|
|
32
|
-
const prompt = instructions + BASE_PROMPT;
|
|
33
|
-
const builtInTools = [tools_js_1.writeTodos, tools_js_1.writeFile, tools_js_1.readFile, tools_js_1.ls, tools_js_1.editFile];
|
|
34
|
-
//TODO: lookup for model that has better tool calling capabilities
|
|
35
|
-
const actualModel = model || (0, model_js_1.getLocalLMStudio)() || (0, model_js_1.getDefaultModel)();
|
|
36
|
-
const taskTool = (0, subAgent_js_1.createTaskTool)([...tools, ...builtInTools], instructions, subagents, actualModel, stateSchema);
|
|
37
|
-
const allTools = [taskTool, ...builtInTools, ...tools];
|
|
38
|
-
return (0, prebuilt_1.createReactAgent)({
|
|
39
|
-
llm: actualModel,
|
|
40
|
-
tools: allTools,
|
|
41
|
-
messageModifier: prompt,
|
|
42
|
-
stateSchema,
|
|
43
|
-
});
|
|
44
|
-
}
|
package/dist/model.d.ts
DELETED
package/dist/model.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultModel = getDefaultModel;
|
|
4
|
-
exports.getLocalLMStudio = getLocalLMStudio;
|
|
5
|
-
const anthropic_1 = require("@langchain/anthropic");
|
|
6
|
-
const openai_1 = require("@langchain/openai");
|
|
7
|
-
function getDefaultModel() {
|
|
8
|
-
return new anthropic_1.ChatAnthropic({
|
|
9
|
-
modelName: "claude-3-5-sonnet-20241022",
|
|
10
|
-
maxTokens: 64000,
|
|
11
|
-
temperature: 0,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function getLocalLMStudio() {
|
|
15
|
-
process.env.OPENAI_API_KEY = "lm-studio";
|
|
16
|
-
return new openai_1.ChatOpenAI({
|
|
17
|
-
modelName: "mlx-community/llama-3.2-3b-instruct:2",
|
|
18
|
-
openAIApiKey: "lm-studio",
|
|
19
|
-
configuration: {
|
|
20
|
-
baseURL: "http://localhost:1234/v1",
|
|
21
|
-
},
|
|
22
|
-
maxTokens: 512,
|
|
23
|
-
temperature: 0.3,
|
|
24
|
-
});
|
|
25
|
-
}
|
package/dist/prompts.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const WRITE_TODOS_DESCRIPTION = "Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.\nIt also helps the user understand the progress of the task and overall progress of their requests.\n\n## When to Use This Tool\nUse this tool proactively in these scenarios:\n\n1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions\n2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations\n3. User explicitly requests todo list - When the user directly asks you to use the todo list\n4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)\n5. After receiving new instructions - Immediately capture user requirements as todos\n6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time\n7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation\n\n## When NOT to Use This Tool\n\nSkip using this tool when:\n1. There is only a single, straightforward task\n2. The task is trivial and tracking it provides no organizational benefit\n3. The task can be completed in less than 3 trivial steps\n4. The task is purely conversational or informational\n\nNOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.\n\n## Task States and Management\n\n1. **Task States**: Use these states to track progress:\n - pending: Task not yet started\n - in_progress: Currently working on (limit to ONE task at a time)\n - completed: Task finished successfully\n\n2. **Task Management**:\n - Update task status in real-time as you work\n - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)\n - Only have ONE task in_progress at any time\n - Complete current tasks before starting new ones\n - Remove tasks that are no longer relevant from the list entirely\n\n3. **Task Completion Requirements**:\n - ONLY mark a task as completed when you have FULLY accomplished it\n - If you encounter errors, blockers, or cannot finish, keep the task as in_progress\n - When blocked, create a new task describing what needs to be resolved\n - Never mark a task as completed if:\n - There are unresolved issues or errors\n - Work is partial or incomplete\n - You encountered blockers that prevent completion\n - You couldn't find necessary resources or dependencies\n - Quality standards haven't been met\n\n4. **Task Breakdown**:\n - Create specific, actionable items\n - Break complex tasks into smaller, manageable steps\n - Use clear, descriptive task names\n\nWhen in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.";
|
|
2
|
-
export declare const TASK_DESCRIPTION_PREFIX = "Launch a new agent to handle complex, multi-step tasks autonomously. \n\nAvailable agent types and the tools they have access to:\n- general-purpose: General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. (Tools: *)\n{other_agents}\n";
|
|
3
|
-
export declare const TASK_DESCRIPTION_SUFFIX = "When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.\n\nWhen to use the Agent tool:\n- When you are instructed to execute custom slash commands. Use the Agent tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description=\"Check the file\", prompt=\"/check-file path/to/file.py\")\n\nWhen NOT to use the Agent tool:\n- If you want to read a specific file path, use the Read or Glob tool instead of the Agent tool, to find the match more quickly\n- If you are searching for a specific term or definition within a known location, use the Glob tool instead, to find the match more quickly\n- If you are searching for content within a specific file or set of 2-3 files, use the Read tool instead of the Agent tool, to find the match more quickly\n- Other tasks that are not related to the agent descriptions above\n\nUsage notes:\n1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\n2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.\n3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.\n4. The agent's outputs should generally be trusted\n5. Clearly tell the agent whether you expect it to create content, perform analysis, or just do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent\n6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.";
|
|
4
|
-
export declare const EDIT_DESCRIPTION = "Performs exact string replacements in files. \n\nUsage:\n- You must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.\n- ALWAYS prefer editing existing files. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if old_string is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use replace_all to change every instance of old_string. \n- Use replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.";
|
|
5
|
-
export declare const TOOL_DESCRIPTION = "Reads a file from the local filesystem. You can access any file directly by using this tool.\nAssume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\n\nUsage:\n- The file_path parameter must be an absolute path, not a relative path\n- By default, it reads up to 2000 lines starting from the beginning of the file\n- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\n- Any lines longer than 2000 characters will be truncated\n- Results are returned using cat -n format, with line numbers starting at 1\n- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful. \n- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.";
|
package/dist/prompts.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOOL_DESCRIPTION = exports.EDIT_DESCRIPTION = exports.TASK_DESCRIPTION_SUFFIX = exports.TASK_DESCRIPTION_PREFIX = exports.WRITE_TODOS_DESCRIPTION = void 0;
|
|
4
|
-
exports.WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
5
|
-
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
6
|
-
|
|
7
|
-
## When to Use This Tool
|
|
8
|
-
Use this tool proactively in these scenarios:
|
|
9
|
-
|
|
10
|
-
1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
11
|
-
2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
12
|
-
3. User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
13
|
-
4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
14
|
-
5. After receiving new instructions - Immediately capture user requirements as todos
|
|
15
|
-
6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
|
|
16
|
-
7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
|
|
17
|
-
|
|
18
|
-
## When NOT to Use This Tool
|
|
19
|
-
|
|
20
|
-
Skip using this tool when:
|
|
21
|
-
1. There is only a single, straightforward task
|
|
22
|
-
2. The task is trivial and tracking it provides no organizational benefit
|
|
23
|
-
3. The task can be completed in less than 3 trivial steps
|
|
24
|
-
4. The task is purely conversational or informational
|
|
25
|
-
|
|
26
|
-
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
|
|
27
|
-
|
|
28
|
-
## Task States and Management
|
|
29
|
-
|
|
30
|
-
1. **Task States**: Use these states to track progress:
|
|
31
|
-
- pending: Task not yet started
|
|
32
|
-
- in_progress: Currently working on (limit to ONE task at a time)
|
|
33
|
-
- completed: Task finished successfully
|
|
34
|
-
|
|
35
|
-
2. **Task Management**:
|
|
36
|
-
- Update task status in real-time as you work
|
|
37
|
-
- Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
|
|
38
|
-
- Only have ONE task in_progress at any time
|
|
39
|
-
- Complete current tasks before starting new ones
|
|
40
|
-
- Remove tasks that are no longer relevant from the list entirely
|
|
41
|
-
|
|
42
|
-
3. **Task Completion Requirements**:
|
|
43
|
-
- ONLY mark a task as completed when you have FULLY accomplished it
|
|
44
|
-
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
|
|
45
|
-
- When blocked, create a new task describing what needs to be resolved
|
|
46
|
-
- Never mark a task as completed if:
|
|
47
|
-
- There are unresolved issues or errors
|
|
48
|
-
- Work is partial or incomplete
|
|
49
|
-
- You encountered blockers that prevent completion
|
|
50
|
-
- You couldn't find necessary resources or dependencies
|
|
51
|
-
- Quality standards haven't been met
|
|
52
|
-
|
|
53
|
-
4. **Task Breakdown**:
|
|
54
|
-
- Create specific, actionable items
|
|
55
|
-
- Break complex tasks into smaller, manageable steps
|
|
56
|
-
- Use clear, descriptive task names
|
|
57
|
-
|
|
58
|
-
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.`;
|
|
59
|
-
exports.TASK_DESCRIPTION_PREFIX = `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
60
|
-
|
|
61
|
-
Available agent types and the tools they have access to:
|
|
62
|
-
- general-purpose: General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. (Tools: *)
|
|
63
|
-
{other_agents}
|
|
64
|
-
`;
|
|
65
|
-
exports.TASK_DESCRIPTION_SUFFIX = `When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
66
|
-
|
|
67
|
-
When to use the Agent tool:
|
|
68
|
-
- When you are instructed to execute custom slash commands. Use the Agent tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
|
|
69
|
-
|
|
70
|
-
When NOT to use the Agent tool:
|
|
71
|
-
- If you want to read a specific file path, use the Read or Glob tool instead of the Agent tool, to find the match more quickly
|
|
72
|
-
- If you are searching for a specific term or definition within a known location, use the Glob tool instead, to find the match more quickly
|
|
73
|
-
- If you are searching for content within a specific file or set of 2-3 files, use the Read tool instead of the Agent tool, to find the match more quickly
|
|
74
|
-
- Other tasks that are not related to the agent descriptions above
|
|
75
|
-
|
|
76
|
-
Usage notes:
|
|
77
|
-
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
78
|
-
2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
|
|
79
|
-
3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
80
|
-
4. The agent's outputs should generally be trusted
|
|
81
|
-
5. Clearly tell the agent whether you expect it to create content, perform analysis, or just do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
|
|
82
|
-
6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.`;
|
|
83
|
-
exports.EDIT_DESCRIPTION = `Performs exact string replacements in files.
|
|
84
|
-
|
|
85
|
-
Usage:
|
|
86
|
-
- You must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.
|
|
87
|
-
- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.
|
|
88
|
-
- ALWAYS prefer editing existing files. NEVER write new files unless explicitly required.
|
|
89
|
-
- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
|
|
90
|
-
- The edit will FAIL if old_string is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use replace_all to change every instance of old_string.
|
|
91
|
-
- Use replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.`;
|
|
92
|
-
exports.TOOL_DESCRIPTION = `Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
93
|
-
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
94
|
-
|
|
95
|
-
Usage:
|
|
96
|
-
- The file_path parameter must be an absolute path, not a relative path
|
|
97
|
-
- By default, it reads up to 2000 lines starting from the beginning of the file
|
|
98
|
-
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
|
|
99
|
-
- Any lines longer than 2000 characters will be truncated
|
|
100
|
-
- Results are returned using cat -n format, with line numbers starting at 1
|
|
101
|
-
- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
102
|
-
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`;
|
package/dist/state.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseMessage } from "@langchain/core/messages";
|
|
2
|
-
export interface Todo {
|
|
3
|
-
content: string;
|
|
4
|
-
status: "pending" | "in_progress" | "completed";
|
|
5
|
-
}
|
|
6
|
-
export interface Files {
|
|
7
|
-
[fileName: string]: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function fileReducer(left: Files | null, right: Files | null): Files | null;
|
|
10
|
-
export declare const DeepAgentState: import("@langchain/langgraph").AnnotationRoot<{
|
|
11
|
-
messages: import("@langchain/langgraph").BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
|
|
12
|
-
todos: import("@langchain/langgraph").BinaryOperatorAggregate<Todo[], Todo[]>;
|
|
13
|
-
files: import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, string>, Record<string, string>>;
|
|
14
|
-
}>;
|
|
15
|
-
export type DeepAgentStateType = typeof DeepAgentState.State;
|
package/dist/state.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeepAgentState = void 0;
|
|
4
|
-
exports.fileReducer = fileReducer;
|
|
5
|
-
const langgraph_1 = require("@langchain/langgraph");
|
|
6
|
-
function fileReducer(left, right) {
|
|
7
|
-
if (!left) {
|
|
8
|
-
return right;
|
|
9
|
-
}
|
|
10
|
-
if (!right) {
|
|
11
|
-
return left;
|
|
12
|
-
}
|
|
13
|
-
return { ...left, ...right };
|
|
14
|
-
}
|
|
15
|
-
exports.DeepAgentState = langgraph_1.Annotation.Root({
|
|
16
|
-
messages: (0, langgraph_1.Annotation)({
|
|
17
|
-
reducer: (currentState, updateValue) => currentState.concat(updateValue),
|
|
18
|
-
default: () => [],
|
|
19
|
-
}),
|
|
20
|
-
todos: (0, langgraph_1.Annotation)({
|
|
21
|
-
reducer: (currentState, updateValue) => updateValue || currentState,
|
|
22
|
-
default: () => [],
|
|
23
|
-
}),
|
|
24
|
-
files: (0, langgraph_1.Annotation)({
|
|
25
|
-
reducer: (currentState, updateValue) => ({
|
|
26
|
-
...currentState,
|
|
27
|
-
...updateValue,
|
|
28
|
-
}),
|
|
29
|
-
default: () => ({}),
|
|
30
|
-
}),
|
|
31
|
-
});
|
package/dist/subAgent.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type StructuredTool } from "@langchain/core/tools";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { DeepAgentState } from "./state.js";
|
|
4
|
-
import { ToolMessage } from "@langchain/core/messages";
|
|
5
|
-
import { LanguageModelLike } from "@langchain/core/language_models/base";
|
|
6
|
-
export interface SubAgent {
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
prompt: string;
|
|
10
|
-
tools?: string[];
|
|
11
|
-
}
|
|
12
|
-
export declare function createTaskTool(tools: StructuredTool[], instructions: string, subagents: SubAgent[], model: LanguageModelLike, stateAnnotation?: typeof DeepAgentState): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
13
|
-
description: z.ZodString;
|
|
14
|
-
subagent_type: z.ZodString;
|
|
15
|
-
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
description: string;
|
|
17
|
-
subagent_type: string;
|
|
18
|
-
}, {
|
|
19
|
-
description: string;
|
|
20
|
-
subagent_type: string;
|
|
21
|
-
}>, {
|
|
22
|
-
description: string;
|
|
23
|
-
subagent_type: string;
|
|
24
|
-
}, {
|
|
25
|
-
description: string;
|
|
26
|
-
subagent_type: string;
|
|
27
|
-
}, string | {
|
|
28
|
-
files: any;
|
|
29
|
-
messages: ToolMessage[];
|
|
30
|
-
}>;
|
package/dist/subAgent.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTaskTool = createTaskTool;
|
|
4
|
-
const tools_1 = require("@langchain/core/tools");
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const prebuilt_1 = require("@langchain/langgraph/prebuilt");
|
|
7
|
-
const messages_1 = require("@langchain/core/messages");
|
|
8
|
-
const prompts_js_1 = require("./prompts.js");
|
|
9
|
-
function createTaskTool(tools, instructions, subagents, model, stateAnnotation) {
|
|
10
|
-
const agents = {
|
|
11
|
-
"general-purpose": (0, prebuilt_1.createReactAgent)({
|
|
12
|
-
llm: model,
|
|
13
|
-
tools,
|
|
14
|
-
messageModifier: instructions,
|
|
15
|
-
stateSchema: stateAnnotation,
|
|
16
|
-
}),
|
|
17
|
-
};
|
|
18
|
-
const toolsByName = tools.reduce((tools, tool) => {
|
|
19
|
-
const toolName = tool.name ?? tool.description ?? "unknown_tool";
|
|
20
|
-
tools[toolName] = tool;
|
|
21
|
-
return tools;
|
|
22
|
-
}, {});
|
|
23
|
-
for (const agent of subagents) {
|
|
24
|
-
let agentTools;
|
|
25
|
-
if (agent.tools) {
|
|
26
|
-
agentTools = agent.tools.map((t) => toolsByName[t]);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
agentTools = tools;
|
|
30
|
-
}
|
|
31
|
-
agents[agent.name] = (0, prebuilt_1.createReactAgent)({
|
|
32
|
-
llm: model,
|
|
33
|
-
tools: agentTools,
|
|
34
|
-
messageModifier: agent.prompt,
|
|
35
|
-
stateSchema: stateAnnotation,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
const otherAgentsString = subagents
|
|
39
|
-
.map((agent) => `- ${agent.name}: ${agent.description}`)
|
|
40
|
-
.join("\\n");
|
|
41
|
-
return (0, tools_1.tool)(async (input, config) => {
|
|
42
|
-
const { description, subagent_type } = input;
|
|
43
|
-
const state = config?.configurable?.state;
|
|
44
|
-
if (!(subagent_type in agents)) {
|
|
45
|
-
return `Error: invoked agent of type ${subagent_type}, the only allowed types are [${Object.keys(agents)
|
|
46
|
-
.map((k) => `\`${k}\``)
|
|
47
|
-
.join(", ")}]`;
|
|
48
|
-
}
|
|
49
|
-
const subAgent = agents[subagent_type];
|
|
50
|
-
const newState = {
|
|
51
|
-
...state,
|
|
52
|
-
messages: [new messages_1.HumanMessage({ content: description })],
|
|
53
|
-
};
|
|
54
|
-
const result = await subAgent.invoke(newState);
|
|
55
|
-
return {
|
|
56
|
-
files: result.files || {},
|
|
57
|
-
messages: [
|
|
58
|
-
new messages_1.ToolMessage({
|
|
59
|
-
content: result.messages[result.messages.length - 1].content,
|
|
60
|
-
tool_call_id: config?.configurable?.tool_call_id || "",
|
|
61
|
-
}),
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
}, {
|
|
65
|
-
name: "task",
|
|
66
|
-
description: prompts_js_1.TASK_DESCRIPTION_PREFIX.replace("{other_agents}", otherAgentsString) + prompts_js_1.TASK_DESCRIPTION_SUFFIX,
|
|
67
|
-
schema: zod_1.z.object({
|
|
68
|
-
description: zod_1.z.string(),
|
|
69
|
-
subagent_type: zod_1.z.string(),
|
|
70
|
-
}),
|
|
71
|
-
});
|
|
72
|
-
}
|
package/dist/tools.d.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { Todo } from "./state.js";
|
|
3
|
-
import { ToolMessage } from "@langchain/core/messages";
|
|
4
|
-
export declare const writeTodos: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
5
|
-
todos: z.ZodArray<z.ZodObject<{
|
|
6
|
-
content: z.ZodString;
|
|
7
|
-
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
status: "pending" | "in_progress" | "completed";
|
|
10
|
-
content: string;
|
|
11
|
-
}, {
|
|
12
|
-
status: "pending" | "in_progress" | "completed";
|
|
13
|
-
content: string;
|
|
14
|
-
}>, "many">;
|
|
15
|
-
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
todos: {
|
|
17
|
-
status: "pending" | "in_progress" | "completed";
|
|
18
|
-
content: string;
|
|
19
|
-
}[];
|
|
20
|
-
}, {
|
|
21
|
-
todos: {
|
|
22
|
-
status: "pending" | "in_progress" | "completed";
|
|
23
|
-
content: string;
|
|
24
|
-
}[];
|
|
25
|
-
}>, {
|
|
26
|
-
todos: Todo[];
|
|
27
|
-
}, {
|
|
28
|
-
todos: {
|
|
29
|
-
status: "pending" | "in_progress" | "completed";
|
|
30
|
-
content: string;
|
|
31
|
-
}[];
|
|
32
|
-
}, {
|
|
33
|
-
todos: Todo[];
|
|
34
|
-
messages: ToolMessage[];
|
|
35
|
-
}>;
|
|
36
|
-
export declare const ls: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string[]>;
|
|
37
|
-
export declare const readFile: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
38
|
-
file_path: z.ZodString;
|
|
39
|
-
offset: z.ZodOptional<z.ZodNumber>;
|
|
40
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
file_path: string;
|
|
43
|
-
offset?: number | undefined;
|
|
44
|
-
limit?: number | undefined;
|
|
45
|
-
}, {
|
|
46
|
-
file_path: string;
|
|
47
|
-
offset?: number | undefined;
|
|
48
|
-
limit?: number | undefined;
|
|
49
|
-
}>, {
|
|
50
|
-
file_path: string;
|
|
51
|
-
offset?: number;
|
|
52
|
-
limit?: number;
|
|
53
|
-
}, {
|
|
54
|
-
file_path: string;
|
|
55
|
-
offset?: number | undefined;
|
|
56
|
-
limit?: number | undefined;
|
|
57
|
-
}, string>;
|
|
58
|
-
export declare const writeFile: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
59
|
-
file_path: z.ZodString;
|
|
60
|
-
content: z.ZodString;
|
|
61
|
-
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
content: string;
|
|
63
|
-
file_path: string;
|
|
64
|
-
}, {
|
|
65
|
-
content: string;
|
|
66
|
-
file_path: string;
|
|
67
|
-
}>, {
|
|
68
|
-
file_path: string;
|
|
69
|
-
content: string;
|
|
70
|
-
}, {
|
|
71
|
-
content: string;
|
|
72
|
-
file_path: string;
|
|
73
|
-
}, {
|
|
74
|
-
files: Record<string, string>;
|
|
75
|
-
messages: ToolMessage[];
|
|
76
|
-
}>;
|
|
77
|
-
export declare const editFile: import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
78
|
-
file_path: z.ZodString;
|
|
79
|
-
old_string: z.ZodString;
|
|
80
|
-
new_string: z.ZodString;
|
|
81
|
-
replace_all: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
-
}, "strip", z.ZodTypeAny, {
|
|
83
|
-
file_path: string;
|
|
84
|
-
old_string: string;
|
|
85
|
-
new_string: string;
|
|
86
|
-
replace_all?: boolean | undefined;
|
|
87
|
-
}, {
|
|
88
|
-
file_path: string;
|
|
89
|
-
old_string: string;
|
|
90
|
-
new_string: string;
|
|
91
|
-
replace_all?: boolean | undefined;
|
|
92
|
-
}>, {
|
|
93
|
-
file_path: string;
|
|
94
|
-
old_string: string;
|
|
95
|
-
new_string: string;
|
|
96
|
-
replace_all?: boolean;
|
|
97
|
-
}, {
|
|
98
|
-
file_path: string;
|
|
99
|
-
old_string: string;
|
|
100
|
-
new_string: string;
|
|
101
|
-
replace_all?: boolean | undefined;
|
|
102
|
-
}, string | {
|
|
103
|
-
files: Record<string, string>;
|
|
104
|
-
messages: ToolMessage[];
|
|
105
|
-
}>;
|