Skip to content

ai-assistant: docs/skills: Add skills proposal#886

Open
illume wants to merge 1 commit into
headlamp-k8s:mainfrom
illume:docs/ai-assistant-skills-proposal
Open

ai-assistant: docs/skills: Add skills proposal#886
illume wants to merge 1 commit into
headlamp-k8s:mainfrom
illume:docs/ai-assistant-skills-proposal

Conversation

@illume

@illume illume commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Adds docs/skills/skills-proposal.md — the design proposal for the skills subsystem: how skill YAML files are structured, loaded from local paths, HTTP endpoints, and zip archives, and injected into the assistant system prompt.

Assisted by Copilot.

Part of the ai-assistant skills documentation series.

@illume illume requested a review from Copilot July 8, 2026 11:48
@illume illume force-pushed the docs/ai-assistant-skills-proposal branch from b6c4516 to 3fb6440 Compare July 8, 2026 11:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a comprehensive design proposal documenting a “skills subsystem” for the Headlamp AI Assistant, covering skill types (prompt/MCP/tool), sources (local/Git/Helm), security considerations (STRIDE), and routing strategies.

Changes:

  • Introduces a new skills design proposal document describing formats, loading/distribution, and trust model.
  • Documents an MVP plan (local prompt skills + SKILL.md metadata + UI) and phased roadmap for Git/MCP/tool skills.
  • Describes skill routing approaches (keyword vs embeddings vs LLM router) and proposed best practices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


1. **Progressive loading (agentskills.io pattern).** The [agentskills.io specification](https://agentskills.io/specification) recommends that agents read only the skill `name` and `description` fields until a skill is triggered. Full content is loaded on demand. This is the most important pattern — it means routing can operate on metadata alone without reading multi-KB skill bodies.

2. **Limit injected skills to 3–5 per query.** Research and production experience consistently show that LLMs perform best with a focused set of instructions. The [LangChain agents guide](https://docs.langchain.com/oss/python/langchain/agents) recommends limiting tools to the most relevant subset. Our `SkillRouterConfig.maxSkills` defaults to 5.
Comment on lines +779 to +782
### Current implementation: `SkillRouter`

The current implementation (`ai-common/src/skills/SkillRouter.ts`) uses **keyword/TF matching** — the simplest approach that requires zero external dependencies:

Comment on lines +800 to +809
### Integration (completed)

The skills system is fully wired into the LLM pipeline:

1. **`SkillManager.getRoutedSkillsPromptText(query, config, routerConfig?)`** — Async method that loads enabled skills, routes them for the query using the configured strategy (embedding or keyword), and returns formatted prompt text.
2. **`LangChainManager.setSkillManager(skillManager, skillsConfig)`** — Configures skills on the LLM manager. Once set, both `userSend()` and `userSendStream()` automatically compute routed skills per-message and inject them into the system prompt.
3. **`EmbeddingRouter`** — Embedding-based router using LangChain's `Embeddings` abstraction. Uses cosine similarity on skill metadata vectors. Falls back to keyword routing (`SkillRouter`) on failure.
4. **`SkillManager.setEmbeddingRouter(router)`** — Strategy pattern: pass an `EmbeddingRouter` for semantic routing, or `null` to use keyword-only routing.

Skills are routed **per-message** (not globally) so each query gets the most relevant skills injected. Errors in skill loading or routing never block the main LLM call.
Comment on lines +707 to +708
- **[LangGraph.js: ToolNode](https://langchain-ai.github.io/langgraphjs/reference/classes/langgraph.prebuilt.ToolNode.html)** — The prebuilt node for executing tool calls in a LangGraph agent, with parallel execution and error handling. Important because Headlamp's `ToolOrchestrator` performs similar grouping of read-only vs write tools.
- **[@langchain/mcp-adapters](https://www.npmjs.com/package/@langchain/mcp-adapters)** — The adapter that bridges MCP servers to LangChain tools. Important because this is the exact package Headlamp uses — MCP skills ultimately flow through this adapter.

The embedding-based router is implemented in `EmbeddingRouter.ts` using LangChain's `Embeddings` abstraction:

**Required packages:** The `EmbeddingRouter` uses `@langchain/core`'s `Embeddings` abstraction, which is already a dependency of `ai-common`. No additional packages are needed for the core embedding routing. The optional `@langchain/community` package would only be needed for advanced vector store integrations (e.g., HNSWLib, FAISS) if the in-memory approach becomes insufficient at scale.
Comment on lines +297 to +314
// skills/cost-analyzer/CostAnalyzerTool.ts
import { ToolBase } from '@headlamp-k8s/ai/langchain';
import { z } from 'zod';

export class CostAnalyzerTool extends ToolBase {
readonly config = {
name: 'cost_analyzer',
description: 'Analyze Kubernetes resource costs',
schema: z.object({
namespace: z.string().optional(),
}),
};

async handler(args: { namespace?: string }) {
// ... implementation
return { content: 'Cost analysis results...' };
}
}
@illume illume force-pushed the docs/ai-assistant-skills-proposal branch from 3fb6440 to 840b518 Compare July 8, 2026 11:52
@illume illume requested review from ashu8912 and Copilot July 8, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +779 to +782
### Current implementation: `SkillRouter`

The current implementation (`ai-common/src/skills/SkillRouter.ts`) uses **keyword/TF matching** — the simplest approach that requires zero external dependencies:

Comment on lines +800 to +809
### Integration (completed)

The skills system is fully wired into the LLM pipeline:

1. **`SkillManager.getRoutedSkillsPromptText(query, config, routerConfig?)`** — Async method that loads enabled skills, routes them for the query using the configured strategy (embedding or keyword), and returns formatted prompt text.
2. **`LangChainManager.setSkillManager(skillManager, skillsConfig)`** — Configures skills on the LLM manager. Once set, both `userSend()` and `userSendStream()` automatically compute routed skills per-message and inject them into the system prompt.
3. **`EmbeddingRouter`** — Embedding-based router using LangChain's `Embeddings` abstraction. Uses cosine similarity on skill metadata vectors. Falls back to keyword routing (`SkillRouter`) on failure.
4. **`SkillManager.setEmbeddingRouter(router)`** — Strategy pattern: pass an `EmbeddingRouter` for semantic routing, or `null` to use keyword-only routing.

Skills are routed **per-message** (not globally) so each query gets the most relevant skills injected. Errors in skill loading or routing never block the main LLM call.
Comment on lines +811 to +813
### Embedding-based routing with LangChain (implemented)

The embedding-based router is implemented in `EmbeddingRouter.ts` using LangChain's `Embeddings` abstraction:
Design proposal for the skills subsystem.

Recommends three skill types loaded into the assistant system prompt:

- Prompt skills (Markdown documents): default type, suitable for community
  contributions, loaded from Git repos, Helm values, or local directories.
- MCP skills (MCP server endpoints): expose external tools as skills.
- Tool skills (TypeScript classes): extend the assistant with custom code.

MCP and tool skills require explicit admin approval before activation. Prompt
skills are sandboxed to the system prompt and cannot call code.

Documents the YAML schema for skill definitions, the `SkillLoader` I/O adapters
(filesystem, HTTP, zip), `SkillConfigManager` persistence, and the proposed
Headlamp UI for managing skill sources.

Signed-off-by: René Dudfield <renedudfield@microsoft.com>
Co-authored-by: Ashu Ghildiyal <aghildiyal@microsoft.com>
Signed-off-by: Ashu Ghildiyal <aghildiyal@microsoft.com>
@illume illume force-pushed the docs/ai-assistant-skills-proposal branch from 840b518 to 5640c73 Compare July 8, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants