[PR #585] feat(quickjs): implement interpreter libraries for deterministic workflows with composable code libraries #582

Open
opened 2026-06-05 17:23:50 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/585
Author: @colifran
Created: 6/4/2026
Status: 🔄 Open

Base: mainHead: colifran/interp-libs


📝 Commits (10+)

  • 7c15156 add InterpreterLibrary interface and implement loadLibrary
  • d1bddf5 implement module resolution for libraries
  • d5bc675 middleware wiring
  • 903e208 add swarm impl files, implement swarm interp library, expose middleware for swarm subagents, include default middleware for swarm subagents
  • 542535a tests, fixes, restore langchain-core version
  • 633c005 example
  • c7511c3 remove charts
  • 6abda67 add changeset
  • c46737c fix example
  • 2334a88 format

📊 Changes

45 files changed (+6341 additions, -62 deletions)

View changed files

.changeset/late-terms-warn.md (+6 -0)
examples/repl/interpreter-libraries/.env.example (+2 -0)
examples/repl/interpreter-libraries/libraries/evaluator/INSTRUCTIONS.md (+94 -0)
examples/repl/interpreter-libraries/libraries/evaluator/index.ts (+254 -0)
examples/repl/interpreter-libraries/run.ts (+173 -0)
📝 examples/tsconfig.json (+1 -1)
📝 libs/deepagents/src/backends/composite.test.ts (+11 -6)
📝 libs/deepagents/src/backends/state.test.ts (+7 -5)
📝 libs/deepagents/src/backends/store.test.ts (+2 -2)
📝 libs/deepagents/src/index.ts (+6 -0)
📝 libs/deepagents/src/middleware/fs.test.ts (+15 -11)
📝 libs/deepagents/src/middleware/fs.ts (+1 -1)
📝 libs/deepagents/src/middleware/index.ts (+3 -0)
📝 libs/deepagents/src/middleware/subagents.ts (+2 -1)
📝 libs/deepagents/src/stream.test.ts (+2 -2)
📝 libs/providers/quickjs/package.json (+3 -2)
📝 libs/providers/quickjs/src/index.ts (+5 -0)
libs/providers/quickjs/src/libraries/swarm/INSTRUCTIONS.md (+288 -0)
libs/providers/quickjs/src/libraries/swarm/__tests__/batching.test.ts (+353 -0)
libs/providers/quickjs/src/libraries/swarm/__tests__/executor.test.ts (+328 -0)

...and 25 more files

📄 Description

Summary

Adds interpreter libraries to @langchain/quickjs which are pre-loaded modules that agents can import inside the QuickJS sandbox. Libraries bundle tools, dependencies, and documentation behind a simple module interface, with progressive disclosure (agent sees a one-liner; full docs load on demand via readFile).

Ships swarm as the first built-in library: table-based parallel fan-out with auto-batching, structured output, and context isolation. Swarm subagents now support middleware configuration, with patch-tool-calls and anthropic prompt caching injected by default to help with cost control.

Includes an example (examples/repl/interpreter-libraries/) that wires up swarm with a custom evaluator library to run a multi-pass tech stack comparison across three specialized subagents.

Also fixes two pre-existing CI failures unrelated to this feature:

  • stream.test.ts asserted tool output text against sub.messages, which only yields AI messages — fixed to check actual AI message content
  • Evicted tool results were written without a file extension, so read_file treated them as binary and produced document blocks the Anthropic API rejects. Added .txt extension

Tests

  • Unit tests for swarm table operations including glob parsing (newline-separated paths, no-match/error status strings)
  • Unit tests for library loading (loadLibrary)
  • Updated eviction path assertions across fs.test.ts, state.test.ts, store.test.ts, composite.test.ts
  • Integration tested via examples/repl/interpreter-libraries/run.ts (multi-library agent with swarm + custom evaluator)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/585 **Author:** [@colifran](https://github.com/colifran) **Created:** 6/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `colifran/interp-libs` --- ### 📝 Commits (10+) - [`7c15156`](https://github.com/langchain-ai/deepagentsjs/commit/7c151567a393017287200ea7c251747036ad502f) add InterpreterLibrary interface and implement loadLibrary - [`d1bddf5`](https://github.com/langchain-ai/deepagentsjs/commit/d1bddf5c2ef921936767977bd6af14e38b4467e7) implement module resolution for libraries - [`d5bc675`](https://github.com/langchain-ai/deepagentsjs/commit/d5bc675e13000e2e8705a2c4c376dfa506894286) middleware wiring - [`903e208`](https://github.com/langchain-ai/deepagentsjs/commit/903e2082144566d1207d004ce33c88a63bf1bed2) add swarm impl files, implement swarm interp library, expose middleware for swarm subagents, include default middleware for swarm subagents - [`542535a`](https://github.com/langchain-ai/deepagentsjs/commit/542535a54c6c331fad7f04ef9efbfcf1866fefe2) tests, fixes, restore langchain-core version - [`633c005`](https://github.com/langchain-ai/deepagentsjs/commit/633c005f89dd36f13916a45349af884a2e50f0bb) example - [`c7511c3`](https://github.com/langchain-ai/deepagentsjs/commit/c7511c3a7d3b30b6daf57d2eb6fb0e314acf3f54) remove charts - [`6abda67`](https://github.com/langchain-ai/deepagentsjs/commit/6abda67ef06e9e2aa2b82c769c48326533339fcc) add changeset - [`c46737c`](https://github.com/langchain-ai/deepagentsjs/commit/c46737c7fb15cb65b07268b8985e9ed9a4c6c180) fix example - [`2334a88`](https://github.com/langchain-ai/deepagentsjs/commit/2334a8800d515c98bad8f00f8fef4c287514e0a0) format ### 📊 Changes **45 files changed** (+6341 additions, -62 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/late-terms-warn.md` (+6 -0) ➕ `examples/repl/interpreter-libraries/.env.example` (+2 -0) ➕ `examples/repl/interpreter-libraries/libraries/evaluator/INSTRUCTIONS.md` (+94 -0) ➕ `examples/repl/interpreter-libraries/libraries/evaluator/index.ts` (+254 -0) ➕ `examples/repl/interpreter-libraries/run.ts` (+173 -0) 📝 `examples/tsconfig.json` (+1 -1) 📝 `libs/deepagents/src/backends/composite.test.ts` (+11 -6) 📝 `libs/deepagents/src/backends/state.test.ts` (+7 -5) 📝 `libs/deepagents/src/backends/store.test.ts` (+2 -2) 📝 `libs/deepagents/src/index.ts` (+6 -0) 📝 `libs/deepagents/src/middleware/fs.test.ts` (+15 -11) 📝 `libs/deepagents/src/middleware/fs.ts` (+1 -1) 📝 `libs/deepagents/src/middleware/index.ts` (+3 -0) 📝 `libs/deepagents/src/middleware/subagents.ts` (+2 -1) 📝 `libs/deepagents/src/stream.test.ts` (+2 -2) 📝 `libs/providers/quickjs/package.json` (+3 -2) 📝 `libs/providers/quickjs/src/index.ts` (+5 -0) ➕ `libs/providers/quickjs/src/libraries/swarm/INSTRUCTIONS.md` (+288 -0) ➕ `libs/providers/quickjs/src/libraries/swarm/__tests__/batching.test.ts` (+353 -0) ➕ `libs/providers/quickjs/src/libraries/swarm/__tests__/executor.test.ts` (+328 -0) _...and 25 more files_ </details> ### 📄 Description ### Summary Adds interpreter libraries to @langchain/quickjs which are pre-loaded modules that agents can import inside the QuickJS sandbox. Libraries bundle tools, dependencies, and documentation behind a simple module interface, with progressive disclosure (agent sees a one-liner; full docs load on demand via readFile). Ships swarm as the first built-in library: table-based parallel fan-out with auto-batching, structured output, and context isolation. Swarm subagents now support middleware configuration, with patch-tool-calls and anthropic prompt caching injected by default to help with cost control. Includes an example (examples/repl/interpreter-libraries/) that wires up swarm with a custom evaluator library to run a multi-pass tech stack comparison across three specialized subagents. Also fixes two pre-existing CI failures unrelated to this feature: - stream.test.ts asserted tool output text against sub.messages, which only yields AI messages — fixed to check actual AI message content - Evicted tool results were written without a file extension, so read_file treated them as binary and produced document blocks the Anthropic API rejects. Added .txt extension ### Tests - Unit tests for swarm table operations including glob parsing (newline-separated paths, no-match/error status strings) - Unit tests for library loading (loadLibrary) - Updated eviction path assertions across fs.test.ts, state.test.ts, store.test.ts, composite.test.ts - Integration tested via examples/repl/interpreter-libraries/run.ts (multi-library agent with swarm + custom evaluator) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:23:50 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#582