* feat(sdk): evict large HumanMessages to filesystem
Port of python PR #2183 to JS. Adds a beforeAgent hook to the
FilesystemMiddleware that checks the most recent message. If it is a
HumanMessage whose text content exceeds toolTokenLimitBeforeEvict, the
full content is written to the backend and the message is replaced with
a truncated preview pointing to the file.
Changes:
- Add TOO_LARGE_HUMAN_MSG template for evicted human messages
- Add extractTextFromMessage() to extract text from any message type
- Add buildEvictedHumanContent() to preserve non-text blocks (images)
- Add beforeAgent hook to createFilesystemMiddleware
- Add comprehensive tests for HumanMessage eviction
Co-authored-by: Christian Bromann <christian-bromann@users.noreply.github.com>
* format
* Create angry-jobs-film.md
* refactor: align with final Python PR - tag-based eviction architecture
Rework the HumanMessage eviction to match the final shipped Python PR:
Architecture change:
- beforeAgent: writes large content to backend and TAGS the message
with lc_evicted_to in additional_kwargs (preserving original content
in state for checkpoint persistence)
- wrapModelCall: truncates all tagged messages before sending to model
(model sees preview, state keeps full content)
Key differences from initial port:
- Separate humanMessageTokenLimitBeforeEvict option (default: 50000)
- Original content preserved in state (not replaced)
- Messages tagged with lc_evicted_to for multi-turn truncation
- Path changed from /large_messages/ to /conversation_history/
- Added buildTruncatedHumanMessage helper for model-view truncation
- wrapModelCall now handles truncation of all tagged messages
Tests updated:
- beforeAgent tests verify tagging behavior (original content preserved)
- New wrapModelCall test suite for truncation of tagged messages
- Test for skip already-tagged messages
- Test for mixed tagged/untagged message lists
- Test for non-text block preservation during truncation
Co-authored-by: Christian Bromann <christian-bromann@users.noreply.github.com>
* format
* fix: update beforeAgent to use resolveBackend after main merge
The merge from main replaced getBackend/StateAndStore with
resolveBackend/BackendRuntime. Update the beforeAgent hook to use the
new API.
Co-authored-by: Christian Bromann <christian-bromann@users.noreply.github.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Christian Bromann <christian-bromann@users.noreply.github.com>
* feat(deepagent): add LangSmithSandbox
* Change deepagents version from patch to minor
* format
* fix tests
* format
* make it a patch
* cr
* cr
* fix
* cr
* launch tool, check tool
* update tool and cancel tool
* update and cancel tool tests
* list async subagent jobs tool
* list subagent jobs tool and create middleware
* wire in async subagents
* create and use state schema, update message to messages
* tests
* AsyncSubagent -> AsyncSubAgent
* fix import
* bug fixes
* fix exports
* refactor for sync and async subagents as a single entry point
* fix tool names
* restore processed subagent var name
* fix bug
* adjust tool names and tests
* add createdAt, updatedAt, and checkAt fields
* add a changeset
* job->task
* SubAgent->subagent in docstrings
* update tool names
* use tool runtime
* update naming to match async task naming convention
* remove extra custom middleware added during merge conflicts
* launch_async_task->start_async_task
* buildLaunchTool->buildStartTool
* feat(node-vfs): enhance VfsSandbox to support absolute paths in commands and add related integration tests
- Implemented a method to rewrite absolute paths in commands referencing VFS entries to point to the temporary directory.
- Added integration tests for executing multi-file Node.js projects with both absolute and relative paths.
- Updated existing tests to clarify path usage in commands.
* fix(node-vfs): add changeset for rewriting absolute VFS paths in execute() commands
* fix: ci
---------
Co-authored-by: wangjiangjian.0224 <wangjiangjian.0224@bytedance.com>
* fix(deepagents): reorder middleware so prompt caching and memory run last
Move anthropicPromptCachingMiddleware and memoryMiddleware after all static
and user-supplied middleware so that updates to memory contents do not
invalidate Anthropic prompt caches.
Port of langchain-ai/deepagents#2070.
* cr
* update backend protocol interface, types, and utils
* refactor state backend
* refactor store backend
* clean up
* unit tests
* refactor filesystem
* unit tests
* skip binary files in literal search for filesystem backend
* refactor base sandbox
* base sandbox unit tests
* refactor local shell backend
* refactor composite backend
* composite and local shell backend changes
* refactor fs middleware
* unit tests and fixed issue where createFileData was removed - this would be breaking
* refactor acp filesystem backend
* backend protocol v2
* simplify createFileData
* docstrings
* adapt backend protocol tests
* sandbox protocol v2
* format
* standard tests
* fix tests
* fix tests
* fix tests
* fix node vfs
* lint fix
* empty commit
* fix download files to handle binary
* any backend protocol
* lint
* make backend protocol v2 extend backend protocol
* make backend unknown type for is sandbox backend check
* add changeset
* add max binary file size
* add svg
* separate v1 and v2
* format
* lint
* format
* update glob, ls, read raw return types
* unit test fixes
* fix tests
* restore standard-tests package
* fix integ tests - make standard-tests backward compatible
* remove deleted sandbox adapter
* standard-test refactor for backwards compat
* linting
* fix tests
* type guards and improved guard checks
* store mime type with v2 file data
* make explicit v1 types
* fix locall shell int types
* fix bug
* edge case
* update providers
* lint
* fix repl
* read raw tests
* support string or unint8arrays
* clean comments, docstrings, and fix issue where we were throwing a string
* don't re-wrap uint8arrays
* clean up test names
* fix quickjs
* poison pill and uint8array issues
* add back video and audio support
* bump langgraph-checkpoint version for json plus serializer changes
* fix lock after merge with main
* remove explicit cast
* use instance of Uint8Array for FileDataV2 schema
* update changeset
* update backend protocol interface, types, and utils
* refactor state backend
* refactor store backend
* clean up
* unit tests
* refactor filesystem
* unit tests
* skip binary files in literal search for filesystem backend
* refactor base sandbox
* base sandbox unit tests
* refactor local shell backend
* refactor composite backend
* composite and local shell backend changes
* refactor fs middleware
* unit tests and fixed issue where createFileData was removed - this would be breaking
* refactor acp filesystem backend
* backend protocol v2
* simplify createFileData
* docstrings
* adapt backend protocol tests
* sandbox protocol v2
* format
* standard tests
* fix tests
* fix tests
* fix tests
* fix node vfs
* lint fix
* empty commit
* fix download files to handle binary
* any backend protocol
* lint
* make backend protocol v2 extend backend protocol
* make backend unknown type for is sandbox backend check
* add changeset
* add max binary file size
* add svg
* separate v1 and v2
* format
* lint
* format
* update glob, ls, read raw return types
* unit test fixes
* fix tests
* restore standard-tests package
* fix integ tests - make standard-tests backward compatible
* remove deleted sandbox adapter
* standard-test refactor for backwards compat
* linting
* fix tests
* type guards and improved guard checks
* store mime type with v2 file data
* make explicit v1 types
* fix locall shell int types
* fix bug
* edge case
* update providers
* lint
* fix repl
* read raw tests
* support string or unint8arrays
* clean comments, docstrings, and fix issue where we were throwing a string
* don't re-wrap uint8arrays
* clean up test names
* fix quickjs
* poison pill and uint8array issues
* add back video and audio support
* bump langgraph-checkpoint version for json plus serializer changes
* fix lock after merge with main
* remove explicit cast
* use instance of Uint8Array for FileDataV2 schema
* refactor backend methods
* add changeset
* changesets
* regen lock
* update backend protocol interface, types, and utils
* refactor state backend
* refactor store backend
* clean up
* unit tests
* refactor filesystem
* unit tests
* skip binary files in literal search for filesystem backend
* refactor base sandbox
* base sandbox unit tests
* refactor local shell backend
* refactor composite backend
* composite and local shell backend changes
* refactor fs middleware
* unit tests and fixed issue where createFileData was removed - this would be breaking
* refactor acp filesystem backend
* backend protocol v2
* simplify createFileData
* docstrings
* adapt backend protocol tests
* sandbox protocol v2
* format
* standard tests
* fix tests
* fix tests
* fix tests
* fix node vfs
* lint fix
* empty commit
* fix download files to handle binary
* any backend protocol
* lint
* make backend protocol v2 extend backend protocol
* make backend unknown type for is sandbox backend check
* add changeset
* add max binary file size
* add svg
* separate v1 and v2
* format
* lint
* format
* update glob, ls, read raw return types
* unit test fixes
* fix tests
* restore standard-tests package
* fix integ tests - make standard-tests backward compatible
* remove deleted sandbox adapter
* standard-test refactor for backwards compat
* linting
* fix tests
* fix integ test
* type guards and improved guard checks
* store mime type with v2 file data
* make explicit v1 types
* fix locall shell int types
* fix bug
* edge case
* update providers
* lint
* fix repl
* read raw tests
* support string or unint8arrays
* clean comments, docstrings, and fix issue where we were throwing a string
* don't re-wrap uint8arrays
* clean up test names
* fix quickjs
* poison pill and uint8array issues
* add back video and audio support
* bump langgraph-checkpoint version for json plus serializer changes
* fix lock after merge with main
* remove explicit cast
* use instance of Uint8Array for FileDataV2 schema
* update changeset
* regen lock
* fix(deepagents): move uuid from devDependencies to dependencies
* Move uuid to dependencies from devDependencies
---------
Co-authored-by: Christian Bromann <git@bromann.dev>
* feat(acp): add authMethods to InitializeResponse for ACP registry compliance
The ACP registry CI verifies that agents advertise authentication
methods during initialization. Add configurable `authMethods` to
`DeepAgentsServerOptions` with sensible defaults (Anthropic/OpenAI
env_var methods + agent-type fallback), and expose typed interfaces
for all three ACP auth method types (agent, env_var, terminal).
* Create weak-singers-wash.md
* format
* remove description prop
* improve caching performance
* add changeset
* add check for anthropic models
* use content blocks
* test isAnthropicModel
* update logic to ensure all stable content BEFORE the memory block is cached - not just the system prompt
* fix type check error
* add cache breakpoint after subagent middleware for default and general purpose
* fix: delegate CompositeBackend.id to default sandbox backend
CompositeBackend failed isSandboxBackend check because it lacked the
required id property from SandboxBackendProtocol. Added a get id()
getter that delegates to the default backend's id when it is a sandbox,
or returns an empty string otherwise. This preserves the real sandbox
ID (e.g. from Daytona/Deno/Modal) for external lifecycle operations
like provider.delete({ sandboxId: sandbox.id }).
Fixes#275
* Fix delegation of CompositeBackend.id to sandbox backend
* fix: add truncation to grep/glob/ls tool results
Fixes#272
grep, glob, and ls tools can return hundreds of KB of results, which
can exceed context limits and cause model retries or blank responses.
This adds truncation at the TOOL_RESULT_TOKEN_LIMIT (20K tokens ~80KB)
threshold, consistent with read_file's existing behavior.
Changes:
- Import truncateIfTooLong utility in fs.ts middleware
- Apply truncation to ls, glob, and grep tool results
- Truncate arrays before joining to preserve complete lines
- Add guidance message when results are truncated
The truncation happens in the middleware layer (matching Python's
architecture), not in the backend, so backends return full results
and middleware applies the limit.
* test: add documentation for truncation test coverage
Add note explaining that ls/grep/glob truncation is covered by
existing truncateIfTooLong tests in utils.test.ts (lines 290-314).
Full integration tests would require complex LangGraph context setup.
* test: add integration tests for ls/grep/glob truncation
Add proper integration tests that verify truncation works through the
entire middleware → tool → backend → formatting → truncation pipeline.
- Mock getCurrentTaskInput to enable tool invocation without LangGraph
- Test ls, glob, and grep tools with large result sets (truncated)
- Test ls, glob, and grep tools with small result sets (not truncated)
- Remove unnecessary comments for cleaner test code
These tests verify that the truncation logic added in commit 6e4a2b8
works correctly through the full middleware integration.
* Implement truncation in tool results
Add truncation feature to grep, glob, and ls tool results.
---------
Co-authored-by: Christian Bromann <git@bromann.dev>