|
17 | 17 | from __future__ import annotations |
18 | 18 |
|
19 | 19 | from typing import Any |
| 20 | +from typing import TYPE_CHECKING |
20 | 21 |
|
21 | 22 | from google.genai import types |
22 | 23 |
|
|
29 | 30 | from .base_toolset import BaseToolset |
30 | 31 | from .tool_context import ToolContext |
31 | 32 |
|
| 33 | +if TYPE_CHECKING: |
| 34 | + from ..models.llm_request import LlmRequest |
| 35 | + |
32 | 36 | DEFAULT_SKILL_SYSTEM_INSTRUCTION = """You can use specialized 'skills' to help you with complex tasks. You MUST use the skill tools to interact with these skills. |
33 | 37 |
|
34 | 38 | Skills are folders of instructions and resources that extend your capabilities for specialized tasks. Each skill folder contains: |
|
38 | 42 |
|
39 | 43 | This is very important: |
40 | 44 |
|
41 | | -1. Use the `list_skills` tool to discover available skills. |
42 | | -2. If a skill seems relevant to the current user query, you MUST use the `load_skill` tool with `name="<SKILL_NAME>"` to read its full instructions before proceeding. |
43 | | -3. Once you have read the instructions, follow them exactly as documented before replying to the user. For example, If the instruction lists multiple steps, please make sure you complete all of them in order. |
44 | | -4. The `load_skill_resource` tool is for viewing files within a skill's directory (e.g., `references/*`, `assets/*`). Do NOT use other tools to access these files. |
| 45 | +1. If a skill seems relevant to the current user query, you MUST use the `load_skill` tool with `name="<SKILL_NAME>"` to read its full instructions before proceeding. |
| 46 | +2. Once you have read the instructions, follow them exactly as documented before replying to the user. For example, If the instruction lists multiple steps, please make sure you complete all of them in order. |
| 47 | +3. The `load_skill_resource` tool is for viewing files within a skill's directory (e.g., `references/*`, `assets/*`). Do NOT use other tools to access these files. |
45 | 48 | """ |
46 | 49 |
|
47 | 50 |
|
@@ -241,3 +244,11 @@ def _get_skill(self, name: str) -> models.Skill | None: |
241 | 244 | def _list_skills(self) -> list[models.Frontmatter]: |
242 | 245 | """Lists the frontmatter of all available skills.""" |
243 | 246 | return [s.frontmatter for s in self._skills.values()] |
| 247 | + |
| 248 | + async def process_llm_request( |
| 249 | + self, *, tool_context: ToolContext, llm_request: LlmRequest |
| 250 | + ) -> None: |
| 251 | + """Processes the outgoing LLM request to include available skills.""" |
| 252 | + skill_frontmatters = self._list_skills() |
| 253 | + skills_xml = prompt.format_skills_as_xml(skill_frontmatters) |
| 254 | + llm_request.append_instructions([skills_xml]) |
0 commit comments