Skip to content

Commit 6367c48

Browse files
committed
addressed comments (tools)
1 parent fb8eab9 commit 6367c48

2 files changed

Lines changed: 166 additions & 96 deletions

File tree

docs/design/agent-skills/agent-skills-spike.md

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**The problem**: Lightspeed Core has no mechanism for extending agent capabilities with specialized instructions or domain knowledge. Users cannot package reusable workflows, troubleshooting guides, or domain expertise into portable, discoverable units that the LLM can use on demand.
66

7-
**The recommendation**: Implement the [Agent Skills open standard](https://agentskills.io) with filesystem-based discovery. Config specifies paths to skill directories; skill metadata (name, description) is read from `SKILL.md` frontmatter at startup. The LLM sees a skill catalog (name + description) in the system prompt and can request full instructions on demand via a dedicated tool.
7+
**The recommendation**: Implement the [Agent Skills open standard](https://agentskills.io) with filesystem-based discovery. Config specifies paths to skill directories; skill metadata (name, description) is read from `SKILL.md` frontmatter at startup. The LLM discovers available skills via a `list_skills` tool and loads full instructions on demand via an `activate_skill` tool. The system prompt contains behavioral instructions for how to use these tools, not the skill catalog itself.
88

99
**PoC validation**: Not applicable for this spike. The feature is well-defined by the agentskills.io specification and has been implemented by 30+ agent products including Claude Code, GitHub Copilot, Cursor, and OpenAI Codex.
1010

@@ -63,22 +63,48 @@ Architecture-level and implementation-level decisions.
6363

6464
| Option | Description |
6565
|--------|-------------|
66-
| A | System prompt injection (skill catalog in system prompt, LLM decides) |
67-
| B | Dedicated tool (register `activate_skill` tool, LLM calls to load) |
66+
| A | System prompt catalog (skill catalog embedded in system prompt, LLM decides) |
67+
| B | Tool-based discovery (`list_skills` tool returns catalog, `activate_skill` loads instructions) |
6868
| C | Per-request parameter (client specifies which skills to activate) |
69+
| D | Hybrid (catalog in system prompt if < N skills, tool-based discovery otherwise) |
6970

70-
**Recommendation**: **A** (System prompt injection) for the catalog, combined with **B** (dedicated tool) for loading full instructions. The system prompt contains the skill catalog (name + description, ~50-100 tokens per skill). When the LLM decides a skill is relevant, it calls the `activate_skill` tool to load the full instructions.
71+
**Recommendation**: **B** (Tool-based discovery). This approach separates behavioral instructions from skill inventory:
72+
73+
1. **System prompt** contains behavioral instructions only:
74+
- How to discover skills (`list_skills`)
75+
- How to activate skills (`activate_skill`)
76+
- Requirement to load full instructions before proceeding
77+
78+
2. **`list_skills` tool** returns the skill catalog (name + description for each skill)
79+
80+
3. **`activate_skill` tool** loads full `SKILL.md` instructions when the LLM decides a skill is relevant
81+
82+
**Rationale**: This pattern follows Google ADK's proven approach and provides a clean evolution path:
83+
84+
| Phase | `list_skills` behavior | Scales to |
85+
|-------|------------------------|-----------|
86+
| Phase 1 (initial) | Returns full catalog | ~20 skills |
87+
| Phase 2 (future) | Accepts optional `query` param for keyword/semantic search | 100+ skills |
88+
89+
The phase 2 extension requires only a tool implementation change, not an architectural change. The system prompt instructions and `activate_skill` tool remain unchanged.
90+
91+
**Alternative considered**: Option A (system prompt catalog) was considered but rejected because:
92+
- Token cost grows linearly with skill count (~50-100 tokens/skill)
93+
- Risk of overwhelming the model context with large skill catalogs
94+
- No clean evolution path to search-based discovery
95+
96+
Option D (hybrid) remains viable for deployments with predictable skill counts, but adds complexity. Teams can revisit if phase 2 search proves unreliable for small catalogs.
7197

7298
### Decision 6: Skill context management
7399

74100
| Option | Description |
75101
|--------|-------------|
76102
| A | Always loaded (all skills' full instructions in every request) |
77-
| B | Catalog + on-demand (only name/description upfront, full content loaded when LLM requests) |
103+
| B | Progressive disclosure (catalog via tool, full content loaded when LLM requests) |
78104

79-
**Recommendation**: **B** (Catalog + on-demand). This follows the agentskills.io progressive disclosure pattern:
80-
1. **Catalog** (~50-100 tokens/skill) - name + description always in system prompt
81-
2. **Instructions** (<5000 tokens) - full `SKILL.md` body loaded via tool when needed
105+
**Recommendation**: **B** (Progressive disclosure). This follows the agentskills.io pattern:
106+
1. **Catalog** (~50-100 tokens/skill) - name + description returned by `list_skills` tool
107+
2. **Instructions** (<5000 tokens) - full `SKILL.md` body loaded via `activate_skill` tool when needed
82108
3. **Resources** (on-demand) - `references/` files loaded via file-read tool when referenced
83109

84110
This keeps the base context small while giving the LLM access to specialized knowledge on demand.
@@ -146,37 +172,39 @@ Follow the MCP server config pattern (ModelContextProtocolServer class, line 468
146172

147173
<!-- type: Task -->
148174
<!-- key: LCORE-???? -->
149-
### LCORE-???? Implement skill catalog injection
175+
### LCORE-???? Implement list_skills tool
150176

151-
**Description**: Inject the skill catalog (name + description for each skill) into the system prompt so the LLM knows what skills are available.
177+
**Description**: Register a `list_skills` tool that the LLM can call to discover available skills. Returns the skill catalog (name + description for each configured skill).
152178

153179
**Scope**:
154180

155-
- Create `src/utils/skills.py` module
156-
- Implement `build_skill_catalog()` function that formats skills as XML/structured text
157-
- Modify `get_system_prompt()` in `src/utils/prompts.py` to append skill catalog
158-
- Add behavioral instructions telling the LLM how to use skills
181+
- Create `src/utils/skills.py` module with skill catalog management
182+
- Add `list_skills` tool registration in `prepare_tools()` in `src/utils/responses.py`
183+
- Implement tool handler that returns formatted skill catalog (name + description)
184+
- Modify `get_system_prompt()` in `src/utils/prompts.py` to add behavioral instructions for skill discovery and activation
159185

160186
**Acceptance criteria**:
161187

162-
- System prompt includes skill catalog when skills are configured
163-
- Catalog format includes name, description, and path for each skill
164-
- Catalog is omitted when no skills are configured
165-
- Unit tests verify catalog formatting and system prompt injection
188+
- LLM can call `list_skills()` to get the catalog of available skills
189+
- Tool returns name and description for each configured skill
190+
- Tool returns empty list when no skills are configured
191+
- System prompt includes behavioral instructions (how to use `list_skills` and `activate_skill`)
192+
- Unit tests verify tool registration, catalog formatting, and system prompt instructions
166193

167194
**Agentic tool instruction**:
168195

169196
```text
170-
Read the "System prompt injection" section in docs/design/agent-skills/agent-skills.md.
171-
Key files: src/utils/prompts.py (get_system_prompt function),
197+
Read the "Tool-based discovery" section in docs/design/agent-skills/agent-skills.md.
198+
Key files: src/utils/responses.py (prepare_tools function, line 204),
199+
src/utils/prompts.py (get_system_prompt function),
172200
src/utils/skills.py (new module).
173201
```
174202

175203
<!-- type: Task -->
176204
<!-- key: LCORE-???? -->
177205
### LCORE-???? Implement activate_skill tool
178206

179-
**Description**: Register a `activate_skill` tool that the LLM can call to load full skill instructions when it decides a skill is relevant.
207+
**Description**: Register an `activate_skill` tool that the LLM can call to load full skill instructions when it decides a skill is relevant. This complements `list_skills` by providing the detailed instructions for a specific skill.
180208

181209
**Scope**:
182210

@@ -190,7 +218,8 @@ src/utils/skills.py (new module).
190218
- LLM can call `activate_skill(name="skill-name")` to load skill instructions
191219
- Tool returns full `SKILL.md` body content (after frontmatter)
192220
- Tool returns skill directory path so LLM can resolve relative references
193-
- Tool returns error if skill name is invalid
221+
- Tool returns list of available reference files if `references/` directory exists
222+
- Tool returns error if skill name is invalid or not found in catalog
194223
- Unit tests cover tool registration and invocation
195224

196225
**Agentic tool instruction**:
@@ -319,11 +348,11 @@ The agentskills.io spec recommends a three-tier loading strategy:
319348

320349
| Tier | What's loaded | When | Token cost |
321350
|------|---------------|------|------------|
322-
| 1. Catalog | Name + description | Session start | ~50-100 tokens/skill |
323-
| 2. Instructions | Full SKILL.md body | When skill is activated | <5000 tokens (recommended) |
324-
| 3. Resources | References, assets | When instructions reference them | Varies |
351+
| 1. Catalog | Name + description | LLM calls `list_skills` | ~50-100 tokens/skill |
352+
| 2. Instructions | Full SKILL.md body | LLM calls `activate_skill` | <5000 tokens (recommended) |
353+
| 3. Resources | References, assets | LLM reads reference files | Varies |
325354

326-
This keeps base context small while giving the LLM access to specialized knowledge on demand.
355+
This keeps base context small while giving the LLM access to specialized knowledge on demand. The system prompt contains only behavioral instructions (~200 tokens) regardless of skill count.
327356

328357
### Adoption
329358

@@ -354,14 +383,23 @@ OpenAI's SDK already includes `LocalSkill` and `Skill` types in its responses mo
354383
| GitHub Copilot | Filesystem scan | System prompt + tool | Yes |
355384
| Cursor | Filesystem scan | System prompt + tool | Yes |
356385
| OpenAI Codex | API-based | API-based | Yes |
386+
| Google ADK | `list_skills` tool | `load_skill` + `load_skill_resource` tools | Yes (`run_skill_script`) |
387+
388+
**Note**: Google ADK's approach aligns with our recommendation. Their system prompt contains behavioral instructions (how to use the tools), not the skill catalog itself. The `list_skills` tool returns the catalog on demand.
357389

358390
### Alternative designs considered
359391

360392
**Full config-based definitions**: Rejected in favor of filesystem-based with config paths. Inlining full skill definitions (name, description, instructions) in `lightspeed-stack.yaml` would bloat the config CR in k8s deployments and couple skill content updates to config changes. Instead, config specifies paths and skill metadata is read from `SKILL.md` files.
361393

362394
**Inline content**: Rejected in favor of path-based. Inline content would clutter the YAML config for multi-skill deployments and doesn't support reference files.
363395

364-
**Always-loaded instructions**: Rejected in favor of catalog + on-demand. Loading all skill instructions upfront wastes context tokens and doesn't scale to many skills.
396+
**Always-loaded instructions**: Rejected in favor of progressive disclosure. Loading all skill instructions upfront wastes context tokens and doesn't scale to many skills.
397+
398+
**System prompt catalog injection**: Rejected in favor of tool-based discovery (`list_skills`). Embedding the skill catalog directly in the system prompt:
399+
- Increases token cost linearly with skill count (~50-100 tokens/skill)
400+
- Risks overwhelming the model context with large skill catalogs
401+
- Provides no clean evolution path to search-based discovery
402+
The tool-based approach keeps the system prompt constant (behavioral instructions only) and allows phase 2 extension to semantic search without architectural changes.
365403

366404
## Appendix B: Reference sources
367405

0 commit comments

Comments
 (0)