[GH-ISSUE #481] feat: QdrantSkillsMiddleware — vector-retrieved skills for semantic search at scale #261

Closed
opened 2026-06-05 17:21:20 -04:00 by yindo · 1 comment
Owner

Originally created by @inamdarmihir on GitHub (Apr 22, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/481

Summary

Skills are currently loaded from flat files and injected wholesale into the
system prompt. This works well at small scale but hits context-window limits
as the skills library grows.

Problem

createSkillsMiddleware() calls listSkillsFromBackend() and injects all
skill names + descriptions into every model call. With hundreds (or thousands)
of skills this:

  • bloats the context window on every turn
  • increases token cost linearly with skills count
  • degrades retrieval signal (model must reason over long skill lists)

Proposed Solution

Add a QdrantSkillsMiddleware that:

  1. Indexes skill metadata (name + description) as Qdrant vectors on first
    load (or via a separate indexing step)
  2. Replaces the wrapModelCall injection with a semantic search: given the
    current conversation turn, query Qdrant for the top-k most relevant skills
  3. Injects only those top-k skills into the system prompt — keeping the
    progressive disclosure UX identical but scoping it to relevant skills only

This extends, not replaces, the existing middleware contract
(MiddlewareHandler) and backend protocol (BackendProtocolV2), so all
existing backends remain compatible.

Design Notes

  • New package: libs/qdrant-skills/ (or an option on the existing middleware)
  • Depends on @qdrant/js-client-rest and an embeddings provider
  • Falls back to full-list injection when Qdrant is unavailable
  • Indexing is lazy: happens once in beforeAgent, keyed by skill path + mtime

Alternatives Considered

  • In-process fuzzy/keyword search — no semantic understanding
  • Larger context windows — treats symptoms, not the root cause

Checklist

  • New unit tests for index build + top-k retrieval
  • Eval suite entry (extending evals/skills/)
  • README / JSDoc updated
Originally created by @inamdarmihir on GitHub (Apr 22, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/481 ## Summary Skills are currently loaded from flat files and injected wholesale into the system prompt. This works well at small scale but hits context-window limits as the skills library grows. ## Problem `createSkillsMiddleware()` calls `listSkillsFromBackend()` and injects **all** skill names + descriptions into every model call. With hundreds (or thousands) of skills this: - bloats the context window on every turn - increases token cost linearly with skills count - degrades retrieval signal (model must reason over long skill lists) ## Proposed Solution Add a `QdrantSkillsMiddleware` that: 1. **Indexes** skill metadata (name + description) as Qdrant vectors on first load (or via a separate indexing step) 2. **Replaces the `wrapModelCall` injection** with a semantic search: given the current conversation turn, query Qdrant for the top-k most relevant skills 3. **Injects only those top-k skills** into the system prompt — keeping the progressive disclosure UX identical but scoping it to relevant skills only This extends, not replaces, the existing middleware contract (`MiddlewareHandler`) and backend protocol (`BackendProtocolV2`), so all existing backends remain compatible. ## Design Notes - New package: `libs/qdrant-skills/` (or an option on the existing middleware) - Depends on `@qdrant/js-client-rest` and an embeddings provider - Falls back to full-list injection when Qdrant is unavailable - Indexing is lazy: happens once in `beforeAgent`, keyed by skill path + mtime ## Alternatives Considered - In-process fuzzy/keyword search — no semantic understanding - Larger context windows — treats symptoms, not the root cause ## Checklist - [ ] New unit tests for index build + top-k retrieval - [ ] Eval suite entry (extending `evals/skills/`) - [ ] README / JSDoc updated
yindo closed this issue 2026-06-05 17:21:20 -04:00
Author
Owner
<!-- gh-comment-id:4324852890 --> @hntrl commented on GitHub (Apr 27, 2026): See https://github.com/langchain-ai/deepagentsjs/pull/482#pullrequestreview-4178717871
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#261