langchain-ai / langchain-ai/deepagentsjs

Memory leak with dynamic sub agent middleware

Open
#831 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.6k
Forks
272
Avg merge
1d 13h
Merged PRs (30d)
38

Description

Hi,

I've implemented the dymanic middleware in my harness earlier, at https://github.com/avoidwork/madz/blob/main/src/agent/deepAgents.js#L249

In the past 2 days, with DeepSeek-V4-Flash running in madz, I've had crippling memory leaks - it looks like a more capable LLM has found a significant issue in the lib/middleware - it looks like it just keeps spawning - I haven't done a proper RCA yet though; I just woke up + got a coffee + found this:

Image

Image

Memory usage was flat before I added the dynamic middleware with DeepSeek-V4-Flash. I also want to point out I don't see this memory leak manifest with other LLMs like the Qwen family - I think DeepSeek-V4-Flash is simply doing something "better" which has found an edge case in the lib.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the memory growth with the dynamic middleware and DeepSeek-V4-Flash, then compare it with the Qwen behavior described in the issue. Inspect lib/middleware alongside the linked harness entry point at src/agent/deepAgents.js#L249. Done means identifying the repeated spawning or retention path and confirming that memory remains stable after the fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.