Skip to content

Commit b2adc50

Browse files
committed
updated tickets
1 parent 6367c48 commit b2adc50

2 files changed

Lines changed: 243 additions & 54 deletions

File tree

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

Lines changed: 114 additions & 22 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 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.
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, loads full instructions on demand via an `activate_skill` tool, and retrieves reference files via a `load_skill_resource` 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

@@ -64,7 +64,7 @@ Architecture-level and implementation-level decisions.
6464
| Option | Description |
6565
|--------|-------------|
6666
| 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) |
67+
| B | Tool-based discovery (`list_skills` tool returns catalog, `activate_skill` loads instructions, `load_skill_resource` loads reference files) |
6868
| C | Per-request parameter (client specifies which skills to activate) |
6969
| D | Hybrid (catalog in system prompt if < N skills, tool-based discovery otherwise) |
7070

@@ -73,12 +73,15 @@ Architecture-level and implementation-level decisions.
7373
1. **System prompt** contains behavioral instructions only:
7474
- How to discover skills (`list_skills`)
7575
- How to activate skills (`activate_skill`)
76+
- How to load reference files (`load_skill_resource`)
7677
- Requirement to load full instructions before proceeding
7778

7879
2. **`list_skills` tool** returns the skill catalog (name + description for each skill)
7980

8081
3. **`activate_skill` tool** loads full `SKILL.md` instructions when the LLM decides a skill is relevant
8182

83+
4. **`load_skill_resource` tool** loads files from the skill's `references/` subdirectory when needed
84+
8285
**Rationale**: This pattern follows Google ADK's proven approach and provides a clean evolution path:
8386

8487
| Phase | `list_skills` behavior | Scales to |
@@ -105,7 +108,7 @@ Option D (hybrid) remains viable for deployments with predictable skill counts,
105108
**Recommendation**: **B** (Progressive disclosure). This follows the agentskills.io pattern:
106109
1. **Catalog** (~50-100 tokens/skill) - name + description returned by `list_skills` tool
107110
2. **Instructions** (<5000 tokens) - full `SKILL.md` body loaded via `activate_skill` tool when needed
108-
3. **Resources** (on-demand) - `references/` files loaded via file-read tool when referenced
111+
3. **Resources** (on-demand) - `references/` files loaded via `load_skill_resource` tool when referenced
109112

110113
This keeps the base context small while giving the LLM access to specialized knowledge on demand.
111114

@@ -181,14 +184,14 @@ Follow the MCP server config pattern (ModelContextProtocolServer class, line 468
181184
- Create `src/utils/skills.py` module with skill catalog management
182185
- Add `list_skills` tool registration in `prepare_tools()` in `src/utils/responses.py`
183186
- 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
187+
- Modify `get_system_prompt()` in `src/utils/prompts.py` to add behavioral instructions for skill discovery, activation, and resource loading
185188

186189
**Acceptance criteria**:
187190

188191
- LLM can call `list_skills()` to get the catalog of available skills
189192
- Tool returns name and description for each configured skill
190193
- Tool returns empty list when no skills are configured
191-
- System prompt includes behavioral instructions (how to use `list_skills` and `activate_skill`)
194+
- System prompt includes behavioral instructions (how to use `list_skills`, `activate_skill`, and `load_skill_resource`)
192195
- Unit tests verify tool registration, catalog formatting, and system prompt instructions
193196

194197
**Agentic tool instruction**:
@@ -232,28 +235,63 @@ src/utils/skills.py.
232235

233236
<!-- type: Task -->
234237
<!-- key: LCORE-???? -->
235-
### LCORE-???? Add skill reference file access
238+
### LCORE-???? Implement load_skill_resource tool
236239

237-
**Description**: Enable the LLM to read files from the skill's `references/` subdirectory when skill instructions reference them.
240+
**Description**: Register a `load_skill_resource` tool that the LLM can call to load files from a skill's `references/` subdirectory. This is the third skill tool, complementing `list_skills` and `activate_skill`.
238241

239242
**Scope**:
240243

241-
- Ensure existing file-read tool can access skill reference directories
244+
- Add `load_skill_resource` tool registration in `prepare_tools()` in `src/utils/responses.py`
245+
- Implement tool handler that reads files from skill `references/` directories
242246
- Add path validation to restrict access to configured skill directories only
243-
- Document the pattern for skill authors to reference files
247+
- Return file content wrapped in structured tags
244248

245249
**Acceptance criteria**:
246250

247-
- LLM can read files from `<skill-path>/references/` using existing file-read capability
251+
- LLM can call `load_skill_resource(skill_name="skill-name", path="references/guide.md")` to load a reference file
252+
- Tool returns file content for valid paths within the skill's directory
253+
- Tool returns error if skill name is invalid or path is outside skill directory
248254
- Access is restricted to configured skill directories (no arbitrary filesystem access)
249-
- Skill instructions can use relative paths like `references/troubleshooting-guide.md`
250255
- Integration test verifies reference file access works end-to-end
251256

252257
**Agentic tool instruction**:
253258

254259
```text
255-
Read the "Reference file access" section in docs/design/agent-skills/agent-skills.md.
256-
Key files: src/utils/responses.py, existing file-read tool implementation.
260+
Read the "load_skill_resource tool" section in docs/design/agent-skills/agent-skills.md.
261+
Key files: src/utils/responses.py (prepare_tools function, line 204),
262+
src/utils/skills.py.
263+
```
264+
265+
<!-- type: Task -->
266+
<!-- key: LCORE-???? -->
267+
### LCORE-???? Wire skill tools into request flow
268+
269+
**Description**: Integrate the three skill tools (`list_skills`, `activate_skill`, `load_skill_resource`) into the request processing flow. This includes tool registration, invocation handling, and context management.
270+
271+
**Scope**:
272+
273+
- Register all three skill tools when skills are configured
274+
- Add tool invocation routing in the response handler to dispatch skill tool calls
275+
- Integrate skill behavioral instructions into `get_system_prompt()`
276+
- Implement `SkillTracker` for per-conversation activation deduplication
277+
- Ensure skill content (`<skill_content>`, `<skill_resource>` tags) is protected from context compaction
278+
279+
**Acceptance criteria**:
280+
281+
- All three skill tools are registered when skills are configured in `lightspeed-stack.yaml`
282+
- Tool invocations are correctly routed to their handlers in `src/utils/skills.py`
283+
- System prompt includes behavioral instructions when skills are configured
284+
- Duplicate skill activations within a conversation return a note instead of re-injecting content
285+
- Skill content in conversation context is preserved during compaction
286+
- Integration test verifies end-to-end flow: list → activate → load_resource
287+
288+
**Agentic tool instruction**:
289+
290+
```text
291+
Read the "Skill tools" and "Context management" sections in docs/design/agent-skills/agent-skills.md.
292+
Key files: src/utils/responses.py (prepare_tools, response handling),
293+
src/utils/prompts.py (get_system_prompt),
294+
src/utils/skills.py (tool handlers, SkillTracker).
257295
```
258296

259297
<!-- type: Story -->
@@ -284,27 +322,81 @@ Reference the agentskills.io specification for SKILL.md format details.
284322

285323
<!-- type: Task -->
286324
<!-- key: LCORE-???? -->
287-
### LCORE-???? Add integration and E2E tests for skills
325+
### LCORE-???? Add integration tests for skills
288326

289-
**Description**: Add integration tests and E2E tests to verify the skills feature works correctly end-to-end.
327+
**Description**: Add integration tests to verify skill loading, catalog injection, and tool invocation with mocked LLM responses.
290328

291329
**Scope**:
292330

293-
- Integration tests: skill loading, catalog injection, tool invocation with mocked LLM
294-
- E2E tests: full flow with real LLM, verify skill activation and usage
331+
- Test skill configuration loading and validation
332+
- Test catalog generation with skills injected
333+
- Test tool invocation handling with mocked LLM
295334

296335
**Acceptance criteria**:
297336

298337
- Integration tests cover skill configuration, catalog generation, and tool handling
299-
- E2E tests verify a configured skill can be discovered and used by the LLM
300338
- Tests use example skills from `examples/skills/`
339+
- Tests mock LLM responses to verify tool invocation flow
340+
341+
**Agentic tool instruction**:
342+
343+
```text
344+
Read the "Testing" section in docs/design/agent-skills/agent-skills.md.
345+
Key test files: tests/integration/endpoints/.
346+
Follow existing integration test patterns in the codebase.
347+
```
348+
349+
<!-- type: Task -->
350+
<!-- key: LCORE-???? -->
351+
### LCORE-???? Add E2E feature file for skills
352+
353+
**Description**: Write Gherkin feature file(s) defining E2E test scenarios for the skills feature.
354+
355+
**Scope**:
356+
357+
- Define feature file with scenarios for skill discovery and usage
358+
- Cover skill activation via conversation
359+
- Include scenarios for skill tool invocation
360+
361+
**Acceptance criteria**:
362+
363+
- Feature file(s) created in `tests/e2e/features/`
364+
- Scenarios cover skill discovery, activation, and usage
365+
- Scenarios use example skills from `examples/skills/`
366+
- Feature file follows existing Gherkin patterns in the codebase
367+
368+
**Agentic tool instruction**:
369+
370+
```text
371+
Read the "Testing" section in docs/design/agent-skills/agent-skills.md.
372+
Key test files: tests/e2e/features/*.feature.
373+
Follow existing feature file patterns in the codebase.
374+
```
375+
376+
<!-- type: Task -->
377+
<!-- key: LCORE-???? -->
378+
### LCORE-???? Implement E2E step definitions for skills
379+
380+
**Description**: Implement the step definitions to support the skills E2E feature file scenarios.
381+
382+
**Scope**:
383+
384+
- Implement step definitions for skill-related Gherkin steps
385+
- Handle skill configuration setup in test environment
386+
- Verify skill tool invocation and responses
387+
388+
**Acceptance criteria**:
389+
390+
- Step definitions implemented in `tests/e2e/features/steps/`
391+
- All scenarios in the skills feature file pass
392+
- Steps follow existing step definition patterns in the codebase
301393

302394
**Agentic tool instruction**:
303395

304396
```text
305397
Read the "Testing" section in docs/design/agent-skills/agent-skills.md.
306-
Key test files: tests/integration/endpoints/, tests/e2e/features/.
307-
Follow existing test patterns in the codebase.
398+
Key test files: tests/e2e/features/steps/.
399+
Follow existing step definition patterns using behave framework.
308400
```
309401

310402
## Background sections
@@ -350,7 +442,7 @@ The agentskills.io spec recommends a three-tier loading strategy:
350442
|------|---------------|------|------------|
351443
| 1. Catalog | Name + description | LLM calls `list_skills` | ~50-100 tokens/skill |
352444
| 2. Instructions | Full SKILL.md body | LLM calls `activate_skill` | <5000 tokens (recommended) |
353-
| 3. Resources | References, assets | LLM reads reference files | Varies |
445+
| 3. Resources | References, assets | LLM calls `load_skill_resource` | Varies |
354446

355447
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.
356448

@@ -385,7 +477,7 @@ OpenAI's SDK already includes `LocalSkill` and `Skill` types in its responses mo
385477
| OpenAI Codex | API-based | API-based | Yes |
386478
| Google ADK | `list_skills` tool | `load_skill` + `load_skill_resource` tools | Yes (`run_skill_script`) |
387479

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.
480+
**Note**: Google ADK's approach aligns with our recommendation. They use three tools: `list_skills` returns the catalog, `load_skill` loads instructions, and `load_skill_resource` loads reference files. Their system prompt contains behavioral instructions (how to use the tools), not the skill catalog itself.
389481

390482
### Alternative designs considered
391483

0 commit comments

Comments
 (0)