-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Make memory write guidance configurable and support bounded, progressive loading #6502
Copy link
Copy link
Open
Labels
org:internalIssue or pull request created by a member of the `langchain-ai` GitHub organization.Issue or pull request created by a member of the `langchain-ai` GitHub organization.package:deepagentsChanges related to the `deepagents` SDK and agent harness.Changes related to the `deepagents` SDK and agent harness.priority:backlogNot currently planned/prioritized work, often affecting a limited feature or set of users.Not currently planned/prioritized work, often affecting a limited feature or set of users.topic:memoryAgent memory and persistent context.Agent memory and persistent context.topic:performancePerformance, resource usage, and cost optimization.Performance, resource usage, and cost optimization.
Description
Activity
Metadata
Metadata
Assignees
Labels
org:internalIssue or pull request created by a member of the `langchain-ai` GitHub organization.Issue or pull request created by a member of the `langchain-ai` GitHub organization.package:deepagentsChanges related to the `deepagents` SDK and agent harness.Changes related to the `deepagents` SDK and agent harness.priority:backlogNot currently planned/prioritized work, often affecting a limited feature or set of users.Not currently planned/prioritized work, often affecting a limited feature or set of users.topic:memoryAgent memory and persistent context.Agent memory and persistent context.topic:performancePerformance, resource usage, and cost optimization.Performance, resource usage, and cost optimization.
Submission checklist
Area (Required)
Feature description
An agent using
MemoryMiddlewareaccumulated learnings inAGENTS.mdover a couple of weeks; the file reportedly grew to >200k tokens and was injected into the system prompt on every run. The operator moved details into skills and shortened the hot file, which should reduce context and latency. This was the pre-MDA Content Studio instance, not a Managed Deep Agents deployment. Reported trace (access may be limited): https://smith.langchain.com/o/ebbaf2eb-769b-4505-aca2-d11de10372a4/projects/p/9b0ca8d8-6aed-4afd-ae8d-17dec2350417?trace_id=01a0c119-56c0-7723-84c0-a90b5fb83e6d&run_id=01a0c119-56c0-7723-84c0-a90b5fb83e6dThis is consistent with the SDK's current behavior:
MEMORY_SYSTEM_PROMPTsays learning is a top priority and encourages promptly callingedit_fileeven for implicit preferences and discovered patterns.MemoryMiddlewareloads every configured source in full, then inserts its contents into the system message for each model call, with no size or token-budget limit. Repeated small writes to always-loadedAGENTS.mdcan therefore cause escalating per-call prompt cost and latency, eventually reaching model context limits. This is a feedback loop, not just a large-file read problem.Note:
MemoryMiddleware(system_prompt=...)already supports a custom prompt (andNonedisables prompt injection); SDK callers can also supply middleware directly. The ask is not to add an identical parameter. Instead, make it easier to configure a less eager memory-writing policy in the high-levelcreate_deep_agent(memory=...)path (or reconsider the default), and give applications a scalable alternative to always injecting all configured memory.Proposed solution (optional)
system_promptoverride and dcode'smemory.auto_savebehavior could inform the design.AGENTS.md.Related work: #5720 covers a context-budget/liveness boundary and source ownership; #4202 proposes semantic retrieval instead of whole-file loading; #2460 discussed the over-prioritized memory prompt; merged #4700 added a prompt-level
memory.auto_saveswitch in dcode. This issue focuses on the combination experienced by an SDK-backed agent, including high-level prompt-policy ergonomics and progressive loading. If maintainers prefer, it can be folded into those existing issues.Additional context (optional)
The shared trace link was supplied by the affected operator. Its project returned 403 through the configured LangSmith integration, so the >200k-token size, latency impact, and post-cleanup improvement are reported observations, not independently verified trace measurements here.