[PR #500] [MERGED] feat(quickjs): add swarm task tool #515

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/500
Author: @colifran
Created: 5/1/2026
Status: Merged
Merged: 5/19/2026
Merged by: @colifran

Base: mainHead: colifran/swarm-skill


📝 Commits (10+)

  • 32d8c61 implement required ptc tools for skills
  • 241e825 extend task tool with response schema
  • fe08fe5 implement swarm types, interpolation, and filtering
  • 91bb88e implement swarm table logic and tests
  • ac80231 implement swarm executor and batching
  • 4955463 implement swarm skill entry point and SKILLS.md for swarm
  • 3913083 bug fixes
  • fbee3c1 bug fixes and skill tuning
  • 27a5aee linting
  • 7e1b7c3 per session swarm table partitioning, active rules in skills prompt

📊 Changes

16 files changed (+2074 additions, -47 deletions)

View changed files

.changeset/old-mice-travel.md (+6 -0)
📝 libs/deepagents/src/middleware/skills.test.ts (+68 -2)
📝 libs/deepagents/src/middleware/skills.ts (+28 -8)
📝 libs/providers/quickjs/src/index.ts (+9 -0)
📝 libs/providers/quickjs/src/middleware.test.ts (+99 -0)
📝 libs/providers/quickjs/src/middleware.ts (+46 -2)
📝 libs/providers/quickjs/src/session.test.ts (+26 -6)
📝 libs/providers/quickjs/src/session.ts (+91 -13)
📝 libs/providers/quickjs/src/skills.test.ts (+22 -7)
📝 libs/providers/quickjs/src/skills.ts (+4 -4)
libs/providers/quickjs/src/tools/swarm-task.test.ts (+920 -0)
libs/providers/quickjs/src/tools/swarm-task.ts (+574 -0)
📝 libs/providers/quickjs/src/transform.test.ts (+48 -1)
📝 libs/providers/quickjs/src/transform.ts (+41 -4)
📝 libs/providers/quickjs/src/types.ts (+1 -0)
📝 pnpm-lock.yaml (+91 -0)

📄 Description

Summary

Adds the swarm task tool to @langchain/quickjs and fixes skill module loading for the agentskills.io spec, enabling parallel subagent dispatch from inside the QuickJS code interpreter.

Swarm task tool (tools/swarm-task.ts) is a PTC-only tool that bridges the code interpreter to the host runtime for subagent dispatch. It supports two modes:

  1. Direct model calls with structured output (invoke mode) for classification/extraction tasks
  2. Full agentic loops with tools (agent mode) for multi-step reasoning. It handles schema normalization, model variant caching with TTL-based sweeping, and structured output binding.

Spec-compliant entrypoint resolution — loadSkill() now resolves the entrypoint from metadata.entrypoint (the agentskills.io extension point) first, falling back to the legacy top-level module field. This lets skills use spec-compliant frontmatter without a top-level module key.

Subdirectory entrypoint support — the QuickJS module normalizer now uses the entrypoint's directory (not the skill root) when resolving relative imports from a bare specifier. This fixes import { ... } from "./sibling.js" when the entrypoint lives in a subdirectory like scripts/index.ts.

Supporting changes include wiring skills metadata through the middleware and session layers, extending the transform pipeline to strip import type/export type declarations, adding requiredPtcTools validation, and session improvements (extractToolText, stripLineNumbers, sessionId).

The swarm skill itself (table management, batching, filtering, interpolation) is distributed separately and not included here.

Tests

  • 41 tests for the swarm task tool covering both dispatch modes, schema normalization, variant caching and TTL sweeping, error handling, and edge cases around model binding
  • 3 new tests for entrypoint resolution (metadata.entrypoint preferred over module, subdirectory relative imports)

🔄 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/500 **Author:** [@colifran](https://github.com/colifran) **Created:** 5/1/2026 **Status:** ✅ Merged **Merged:** 5/19/2026 **Merged by:** [@colifran](https://github.com/colifran) **Base:** `main` ← **Head:** `colifran/swarm-skill` --- ### 📝 Commits (10+) - [`32d8c61`](https://github.com/langchain-ai/deepagentsjs/commit/32d8c619bde4aacfdd9006f435f868d9b824ff66) implement required ptc tools for skills - [`241e825`](https://github.com/langchain-ai/deepagentsjs/commit/241e8250f6b5e384dda70504c74f24c393ec6680) extend task tool with response schema - [`fe08fe5`](https://github.com/langchain-ai/deepagentsjs/commit/fe08fe5ee4c9622717af02406cc535d70d089f68) implement swarm types, interpolation, and filtering - [`91bb88e`](https://github.com/langchain-ai/deepagentsjs/commit/91bb88e2654e532407a50a5ba5408ae7108bc430) implement swarm table logic and tests - [`ac80231`](https://github.com/langchain-ai/deepagentsjs/commit/ac802319394bc0b10b64d50016e3afbf948efb63) implement swarm executor and batching - [`4955463`](https://github.com/langchain-ai/deepagentsjs/commit/49554638e0dade2f229085103db73fcf4438d95c) implement swarm skill entry point and SKILLS.md for swarm - [`3913083`](https://github.com/langchain-ai/deepagentsjs/commit/3913083a3e39e8dbbcf575f84722151a0b1d473e) bug fixes - [`fbee3c1`](https://github.com/langchain-ai/deepagentsjs/commit/fbee3c137e84e50c92417b29009171400b5c680e) bug fixes and skill tuning - [`27a5aee`](https://github.com/langchain-ai/deepagentsjs/commit/27a5aeeb4dfb24af96d879774551691b98e687f6) linting - [`7e1b7c3`](https://github.com/langchain-ai/deepagentsjs/commit/7e1b7c3a15a9f732d820e7685724971645e6f51e) per session swarm table partitioning, active rules in skills prompt ### 📊 Changes **16 files changed** (+2074 additions, -47 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/old-mice-travel.md` (+6 -0) 📝 `libs/deepagents/src/middleware/skills.test.ts` (+68 -2) 📝 `libs/deepagents/src/middleware/skills.ts` (+28 -8) 📝 `libs/providers/quickjs/src/index.ts` (+9 -0) 📝 `libs/providers/quickjs/src/middleware.test.ts` (+99 -0) 📝 `libs/providers/quickjs/src/middleware.ts` (+46 -2) 📝 `libs/providers/quickjs/src/session.test.ts` (+26 -6) 📝 `libs/providers/quickjs/src/session.ts` (+91 -13) 📝 `libs/providers/quickjs/src/skills.test.ts` (+22 -7) 📝 `libs/providers/quickjs/src/skills.ts` (+4 -4) ➕ `libs/providers/quickjs/src/tools/swarm-task.test.ts` (+920 -0) ➕ `libs/providers/quickjs/src/tools/swarm-task.ts` (+574 -0) 📝 `libs/providers/quickjs/src/transform.test.ts` (+48 -1) 📝 `libs/providers/quickjs/src/transform.ts` (+41 -4) 📝 `libs/providers/quickjs/src/types.ts` (+1 -0) 📝 `pnpm-lock.yaml` (+91 -0) </details> ### 📄 Description ### Summary Adds the swarm task tool to @langchain/quickjs and fixes skill module loading for the agentskills.io spec, enabling parallel subagent dispatch from inside the QuickJS code interpreter. Swarm task tool (tools/swarm-task.ts) is a PTC-only tool that bridges the code interpreter to the host runtime for subagent dispatch. It supports two modes: 1. Direct model calls with structured output (invoke mode) for classification/extraction tasks 2. Full agentic loops with tools (agent mode) for multi-step reasoning. It handles schema normalization, model variant caching with TTL-based sweeping, and structured output binding. Spec-compliant entrypoint resolution — loadSkill() now resolves the entrypoint from metadata.entrypoint (the agentskills.io extension point) first, falling back to the legacy top-level module field. This lets skills use spec-compliant frontmatter without a top-level module key. Subdirectory entrypoint support — the QuickJS module normalizer now uses the entrypoint's directory (not the skill root) when resolving relative imports from a bare specifier. This fixes import { ... } from "./sibling.js" when the entrypoint lives in a subdirectory like scripts/index.ts. Supporting changes include wiring skills metadata through the middleware and session layers, extending the transform pipeline to strip import type/export type declarations, adding requiredPtcTools validation, and session improvements (extractToolText, stripLineNumbers, __sessionId__). The swarm skill itself (table management, batching, filtering, interpolation) is distributed separately and not included here. ### Tests - 41 tests for the swarm task tool covering both dispatch modes, schema normalization, variant caching and TTL sweeping, error handling, and edge cases around model binding - 3 new tests for entrypoint resolution (metadata.entrypoint preferred over module, subdirectory relative imports) --- <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:31 -04:00
yindo closed this issue 2026-06-05 17:23:31 -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#515