Skip to content

Commit 605e311

Browse files
dqbdchristian-bromannwuchangmingnhuang-lchntrl
authored
feat: rewrite deep agents on top of createAgent (#42)
* feat: migrate to createAgent API and middleware architecture BREAKING CHANGE: Major refactor from custom LangGraph implementation to new langchain createAgent API **Architecture Migration:** - Replace createReactAgent with createAgent API from langchain package - Migrate from custom state management to middleware-based architecture - Remove custom DeepAgentState and model configuration in favor of built-in patterns **Package Updates:** - Upgrade to @langchain/anthropic@alpha, @langchain/langgraph@next - Add langchain package as main dependency with createAgent support - Update @langchain/core to local development version **Code Reorganization:** - Move tools from src/tools.ts to modular middleware pattern (src/middleware/) - Simplify type definitions in src/types.ts with Zod schema validation - Refactor src/subAgent.ts to use createAgent with middleware integration - Update src/graph.ts and src/index.ts for new API patterns **Removed Files:** - src/state.ts: Custom state management no longer needed - src/model.ts: Default model configuration handled by createAgent - src/interrupt.ts: Interrupt handling integrated into middleware **New Middleware System:** - src/middleware/fs.ts: File system operations middleware - src/middleware/todo.ts: Todo management middleware - src/middleware/index.ts: Middleware exports and configuration **Configuration:** - Fix tsconfig.json extends path for @tsconfig/recommended - Update examples/research/research-agent.ts for new API - Upgrade TypeScript ESLint and other dev dependencies This migration provides a more maintainable architecture with better separation of concerns and aligns with the latest LangChain patterns for agent development. * consolidate imports * progress * push remaining update * fix ci * cr * fix * add anthropicPromptCachingMiddleware * prettier * prettier * allow sub agents to have middleware * prettier * Merge pull request #37 from wuchangming/cb/createAgent-migration feat: Add a name property value to ToolMessage * fix types * First stab at porting deepagents * Cleanup * wip: middleware review * Fix to work on LSD * Use Zod 4 * Revert "Use Zod 4" This reverts commit 2292cd2. * fix: use store from runnable config * Exclude `jumpTo` from subgraph state * Auto-infer filesystem middleware * Include `strict` in tests * Further cleanup of test files * Remove any, remove only * Fix invalid types for filesystem * Fix invalid condition * Fix file system tests, make those concurrent * Replace _getType with type * Remove Annotation * Cleanup rest of test files * Bump to 1.0.0 * Use PNPM * Fix scripts * Build using tsdown * Bump to 1.0.0-beta.1 * Update CI * Update again * Fix formatting * Add stub prettierrc for VSCode * Add pluggable filesystem * linting * Full test coverage * Add coerce option * Bump to 1.0.0-beta.2 * Bump to 1.0.0-beta.3 * Add windows to matrix * Address comments * Add examples * tweak prompt * Linting * Remove checkpointer=False * Add missing env files * Update README * add missing dev deps * add lockfile * Fix broken test * Normalize paths for linux * Fix tests to be OS agnostic * Normalize for glob search --------- Co-authored-by: Christian Bromann <git@bromann.dev> Co-authored-by: Wu Changming <wuchangmingnice@163.com> Co-authored-by: Nick Huang <nick@langchain.dev> Co-authored-by: Hunter Lovell <hunter@hntrl.io>
1 parent 3a830fa commit 605e311

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+13232
-3423
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ jobs:
2626
- uses: actions/checkout@v4
2727
- name: Enable Corepack
2828
run: corepack enable
29-
- name: Use Node.js 18.x
29+
- name: Install pnpm
30+
uses: pnpm/action-setup@v4
31+
with:
32+
version: 10
33+
- name: Use Node.js
3034
uses: actions/setup-node@v3
3135
with:
32-
node-version: 18.x
33-
cache: "yarn"
36+
node-version-file: .nvmrc
37+
cache: "pnpm"
3438
- name: Install dependencies
35-
run: yarn install --immutable --mode=skip-build
39+
run: pnpm install
3640
- name: Check formatting
37-
run: yarn format:check
41+
run: pnpm format:check
3842

3943
lint:
4044
name: Check linting
@@ -43,15 +47,19 @@ jobs:
4347
- uses: actions/checkout@v4
4448
- name: Enable Corepack
4549
run: corepack enable
46-
- name: Use Node.js 18.x
50+
- name: Install pnpm
51+
uses: pnpm/action-setup@v4
52+
with:
53+
version: 10
54+
- name: Use Node.js
4755
uses: actions/setup-node@v3
4856
with:
49-
node-version: 18.x
50-
cache: "yarn"
57+
node-version-file: .nvmrc
58+
cache: "pnpm"
5159
- name: Install dependencies
52-
run: yarn install --immutable --mode=skip-build
60+
run: pnpm install
5361
- name: Check linting
54-
run: yarn run lint
62+
run: pnpm run lint
5563

5664
build:
5765
name: Build
@@ -60,32 +68,19 @@ jobs:
6068
- uses: actions/checkout@v4
6169
- name: Enable Corepack
6270
run: corepack enable
63-
- name: Use Node.js 18.x
64-
uses: actions/setup-node@v3
71+
- name: Install pnpm
72+
uses: pnpm/action-setup@v4
6573
with:
66-
node-version: 18.x
67-
cache: "yarn"
68-
- name: Install dependencies
69-
run: yarn install --immutable --mode=skip-build
70-
- name: Build
71-
run: yarn build
72-
73-
build-examples:
74-
name: Build examples
75-
runs-on: ubuntu-latest
76-
steps:
77-
- uses: actions/checkout@v4
78-
- name: Enable Corepack
79-
run: corepack enable
80-
- name: Use Node.js 18.x
74+
version: 10
75+
- name: Use Node.js
8176
uses: actions/setup-node@v3
8277
with:
83-
node-version: 18.x
84-
cache: "yarn"
78+
node-version-file: .nvmrc
79+
cache: "pnpm"
8580
- name: Install dependencies
86-
run: yarn install --immutable --mode=skip-build
87-
- name: Build examples
88-
run: yarn build:examples
81+
run: pnpm install
82+
- name: Build
83+
run: pnpm build
8984

9085
readme-spelling:
9186
name: Check README spelling

.github/workflows/unit-tests.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@ jobs:
2020
name: Unit Tests
2121
strategy:
2222
matrix:
23-
os: [ubuntu-latest]
24-
node-version: [18.x, 20.x]
23+
os: [ubuntu-latest, windows-latest]
24+
node-version: [22.x, 24.x]
2525
runs-on: ${{ matrix.os }}
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v5
2828
- name: Enable Corepack
2929
run: corepack enable
30+
- name: Install pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
version: 10
3034
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@v3
35+
uses: actions/setup-node@v4
3236
with:
3337
node-version: ${{ matrix.node-version }}
34-
cache: "yarn"
38+
cache: "pnpm"
3539
- name: Install dependencies
36-
run: yarn install --immutable --mode=skip-build
40+
run: pnpm install
3741
- name: Build project
38-
run: yarn build
42+
run: pnpm build
3943
- name: Run tests
40-
run: yarn test
44+
run: pnpm test
45+
env:
46+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
47+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.x

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"[javascript]": {
5+
"editor.defaultFormatter": "esbenp.prettier-vscode"
6+
},
7+
"[typescript]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
}
10+
}

0 commit comments

Comments
 (0)