Skip to content

Commit f3efcc4

Browse files
authored
feat/adk-skillhub-integration: add ADK Skillhub integration (#634)
Co-authored-by: shanchunhua <shanchunhua@bytedance.com>
1 parent 466d19b commit f3efcc4

11 files changed

Lines changed: 1803 additions & 56 deletions

File tree

‎docs/content/docs/framework/agent/skills.en.mdx‎

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,94 @@
22
title: "Skills"
33
---
44

5-
Skills are reusable "prompt packages" that inject specific domain knowledge, operating procedures, and scripts into an Agent. Instead of stuffing all prompts into `instruction` at once, skills use **progressive prompt loading**: the Agent loads a skill's full content only when needed, which keeps the context length under control and improves execution accuracy.
5+
Skills are reusable "prompt packages" that inject specific domain knowledge, operating procedures, and scripts into an Agent. For local skill loading and execution, the recommended integration is Google ADK's official `load_skill_from_dir` / `SkillToolset` path. VeADK's legacy `Agent(skills=..., skills_mode="local")` local entry point remains compatible, but is deprecated. The `skills_sandbox` and `aio_sandbox` modes keep their existing behavior.
66

7-
VeADK provides three skill execution modes:
7+
## Recommended: ADK SkillToolset
88

9-
| Mode | Description |
10-
| :- | :- |
11-
| `local` | Skills live in a local directory and are loaded and executed locally by the Agent. |
12-
| `skills_sandbox` | Skills are hosted in a cloud Skill Space and executed in a sandbox through the `execute_skills` tool. |
13-
| `aio_sandbox` | All-in-one sandbox mode, suitable for the AgentKit-hosted tool runtime. |
9+
Local skills can be loaded directly by Google ADK and passed to a VeADK Agent as a standard toolset:
1410

15-
When `skills_mode` is not set explicitly, VeADK infers it from the runtime environment: local runs default to `local`; in the AgentKit tool runtime, it automatically selects `skills_sandbox` or `aio_sandbox` based on the tool type.
11+
```python
12+
from google.adk.skills import load_skill_from_dir
13+
from google.adk.tools.skill_toolset import SkillToolset
14+
from veadk import Agent
15+
16+
skill = load_skill_from_dir("/abs/path/to/skills/kb-skill")
17+
agent = Agent(
18+
tools=[SkillToolset(skills=[skill])],
19+
)
20+
```
21+
22+
On this path, skill loading, prompt injection, and tool exposure are handled by ADK. The model sees ADK's official skill tools: `list_skills`, `load_skill`, `load_skill_resource`, and `run_skill_script`. If a skill depends on `scripts/`, configure an appropriate `code_executor` explicitly on the `SkillToolset` or Agent; VeADK does not create a local code executor by default.
23+
24+
Cloud SkillHub / SkillSpace skills should be exposed through VeADK's ADK registry. `search_skills` fetches the remote list live, and `get_skill` downloads and loads a concrete skill only when requested:
25+
26+
```python
27+
from google.adk.tools.skill_toolset import SkillToolset
28+
from veadk import Agent
29+
from veadk.skills import VeSkillRegistry
30+
31+
registry = VeSkillRegistry(skill_source_id=skill_space_id)
32+
agent = Agent(
33+
tools=[SkillToolset(registry=registry)],
34+
)
35+
```
36+
37+
This path does not download every skill at initialization time. The cache only stores concrete downloaded skill versions; remote metadata is fetched again on every search / get, so remote version changes are picked up before loading.
1638

1739
## Skill Directory Structure
1840

19-
A local skill consists of its own directory containing a single `SKILL.md` file:
41+
An ADK local skill consists of its own directory containing a `SKILL.md` file. The frontmatter must include `name` and `description`, and the directory name must match `name`:
2042

2143
<Files>
2244
<Folder name="skills" defaultOpen>
23-
<Folder name="kb_skill" defaultOpen>
45+
<Folder name="kb-skill" defaultOpen>
2446
<File name="SKILL.md" />
47+
<Folder name="references" />
48+
<Folder name="assets" />
49+
<Folder name="scripts" />
2550
</Folder>
2651
</Folder>
2752
</Files>
2853

29-
`SKILL.md` declares `name` and `description` in frontmatter, followed by the skill body:
30-
31-
```markdown title="skills/kb_skill/SKILL.md"
54+
```markdown title="skills/kb-skill/SKILL.md"
3255
---
33-
name: kb_skill
56+
name: kb-skill
57+
description: Query the knowledge base and compose an answer.
3458
---
3559

3660
...body (operating steps, constraints, script descriptions, etc.)
3761
```
3862

39-
<Callout type="warn" title="Naming requirement">
40-
The `name` in `SKILL.md` must match the directory name.
41-
</Callout>
63+
## Deprecated: VeADK Legacy Local Entry
64+
65+
`Agent(skills=..., skills_mode="local")` keeps its legacy behavior, but this local entry point is deprecated. Whether `skills` contains local directories or remote skill sources, once the final mode is `local`, VeADK uses the legacy local loading path: it loads skill metadata, writes the skill list into `instruction`, and mounts the legacy `SkillsToolset`.
66+
67+
The `skills` parameter still supports three skill execution modes. Only the legacy `local` loading and execution path is deprecated:
68+
69+
| Mode | Description |
70+
| :- | :- |
71+
| `local` | Deprecated. Skills are loaded by VeADK's legacy `skills_tool` plus file/Shell helper tools; migrate to ADK `SkillToolset` for local execution. |
72+
| `skills_sandbox` | Skills are hosted in a cloud Skill Space and executed in a sandbox through the `execute_skills` tool. |
73+
| `aio_sandbox` | All-in-one sandbox mode, suitable for the AgentKit-hosted tool runtime. |
74+
75+
When `skills_mode` is not set explicitly, VeADK infers it from the runtime environment: local runs default to `local`; in the AgentKit tool runtime, it automatically selects `skills_sandbox` or `aio_sandbox` based on the tool type.
4276

43-
## Local Mode
77+
### Local Mode
4478

45-
In `local` mode, pass the skill directory path to `skills` and set `skills_mode` to `local`:
79+
In `local` mode, pass the skills root directory path to `skills` and set `skills_mode` to `local`:
4680

4781
```python
4882
from veadk import Agent
4983

5084
agent = Agent(
51-
skills=["/abs/path/to/skills/kb_skill"],
85+
skills=["/abs/path/to/skills"],
5286
skills_mode="local",
5387
)
5488
```
5589

5690
During initialization, the Agent loads each skill's metadata (`name` and `description`) and injects it into the system prompt, guiding the model to invoke the corresponding skill at the right time. In local mode, VeADK also automatically mounts a set of supporting tools (read/write files, edit files, run shell commands, register skills, etc.) for the Agent to use when executing a skill.
5791

58-
## Sandbox Mode
92+
### Sandbox Mode
5993

6094
In `skills_sandbox` mode, skills are hosted in a cloud Skill Space. Pass the cloud skill space identifier to `skills` and add the `execute_skills` tool; the Agent invokes that tool to execute the chosen skill in the sandbox when needed:
6195

@@ -65,27 +99,28 @@ from veadk.tools.builtin_tools.execute_skills import execute_skills
6599

66100
agent = Agent(
67101
skills=[skill_space_id],
102+
skills_mode="skills_sandbox",
68103
tools=[execute_skills],
69104
)
70105
```
71106

72-
## Skill Checklist
107+
### Skill Checklist
73108

74109
A skill can carry a checklist in its definition to constrain the Agent to complete the task step by step. When enabled, the Agent must complete each checklist item while executing the skill, and mark each item as done through the `update_check_list` tool:
75110

76111
```python
77112
from veadk import Agent
78113

79114
agent = Agent(
80-
skills=["/abs/path/to/skills/kb_skill"],
115+
skills=["/abs/path/to/skills"],
81116
skills_mode="local",
82117
enable_skills_checklist=True,
83118
)
84119
```
85120

86121
When a skill defines a checklist, VeADK automatically initializes the state of all checklist items when the skill is invoked, and prompts the model in the system prompt to complete them one by one.
87122

88-
## Dynamically Loading Skills
123+
### Dynamically Loading Skills
89124

90125
With `enable_dynamic_load_skills=True`, new skills can be discovered and loaded at runtime, without declaring all skills up front at Agent initialization:
91126

@@ -102,7 +137,7 @@ agent = Agent(
102137

103138
| Parameter | Type | Description |
104139
| :- | :- | :- |
105-
| `skills` | `list[str]` | The skill list; each element is a local skill directory path or a cloud skill space identifier. |
106-
| `skills_mode` | `"local" \| "skills_sandbox" \| "aio_sandbox"` | Skill execution mode; inferred automatically when omitted. |
107-
| `enable_skills_checklist` | `bool` | Whether to enable the skill checklist; defaults to `False`. |
108-
| `enable_dynamic_load_skills` | `bool` | Whether to enable dynamic loading of skills; defaults to `False`. |
140+
| `skills` | `list[str]` | Skill list; each item is a local skills root path or a cloud skill-space identifier. The legacy local loading path is deprecated when `skills_mode="local"`. |
141+
| `skills_mode` | `"local" \| "skills_sandbox" \| "aio_sandbox"` | Skill execution mode; inferred automatically when omitted. The legacy `local` path is deprecated, while `skills_sandbox` / `aio_sandbox` keep their existing behavior. |
142+
| `enable_skills_checklist` | `bool` | Whether to enable the legacy skill checklist; defaults to `False`. |
143+
| `enable_dynamic_load_skills` | `bool` | Whether to enable dynamic loading for legacy skills; defaults to `False`. |

‎docs/content/docs/framework/agent/skills.mdx‎

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,94 @@
22
title: "技能"
33
---
44

5-
技能(Skills)是一种可复用的「提示词包」,用于为 Agent 注入特定的领域知识、操作流程与脚本。与一次性把所有提示词塞入 `instruction` 不同,技能采用**渐进式加载(progressive prompt loading)**:Agent 仅在需要时才加载某个技能的完整内容,从而控制上下文长度、提升执行准确性。
5+
技能(Skills)是一种可复用的「提示词包」,用于为 Agent 注入特定的领域知识、操作流程与脚本。本地技能加载/执行场景推荐使用 Google ADK 官方的 `load_skill_from_dir` / `SkillToolset` 方式接入;VeADK 旧的 `Agent(skills=..., skills_mode="local")` 本地入口仍保持兼容,但已标记为 deprecated。`skills_sandbox` 与 `aio_sandbox` 模式仍按原方式使用。
66

7-
VeADK 提供三种技能运行模式:
7+
## 推荐:ADK SkillToolset
88

9-
| 模式 | 说明 |
10-
| :- | :- |
11-
| `local` | 技能位于本地目录,直接由 Agent 加载并在本地执行。 |
12-
| `skills_sandbox` | 技能托管在云端技能空间(Skill Space),通过 `execute_skills` 工具在沙箱中执行。 |
13-
| `aio_sandbox` | All-in-one 沙箱模式,适用于 AgentKit 托管的工具运行时。 |
9+
本地技能可直接通过 Google ADK 加载,并作为标准工具集传给 VeADK Agent:
1410

15-
未显式设置 `skills_mode` 时,VeADK 会根据运行环境自动推断:本地运行默认为 `local`;在 AgentKit 工具运行时中,会根据工具类型自动选择 `skills_sandbox` 或 `aio_sandbox`。
11+
```python
12+
from google.adk.skills import load_skill_from_dir
13+
from google.adk.tools.skill_toolset import SkillToolset
14+
from veadk import Agent
15+
16+
skill = load_skill_from_dir("/abs/path/to/skills/kb-skill")
17+
agent = Agent(
18+
tools=[SkillToolset(skills=[skill])],
19+
)
20+
```
21+
22+
这一路径下,技能加载、prompt 注入和工具暴露都由 ADK 处理。模型可见的工具包括 `list_skills`、`load_skill`、`load_skill_resource` 和 `run_skill_script`。如果技能依赖 `scripts/` 执行,请在 `SkillToolset` 或 Agent 上显式配置合适的 `code_executor`;VeADK 不会默认创建本地代码执行器。
23+
24+
云端 SkillHub / SkillSpace 技能推荐通过 VeADK 的 ADK Registry 接入。`search_skills` 会实时拉取远端技能列表,`get_skill` 会在需要某个技能时按需下载并加载:
25+
26+
```python
27+
from google.adk.tools.skill_toolset import SkillToolset
28+
from veadk import Agent
29+
from veadk.skills import VeSkillRegistry
30+
31+
registry = VeSkillRegistry(skill_source_id=skill_space_id)
32+
agent = Agent(
33+
tools=[SkillToolset(registry=registry)],
34+
)
35+
```
36+
37+
该方式不会在初始化阶段全量下载技能;缓存仅用于已下载的具体技能版本。远端 metadata 每次 search / get 都会重新拉取,因此远端版本变化后会按新版本重新下载。
1638

1739
## 技能目录结构
1840

19-
一个本地技能由独立目录构成,目录中包含一个 `SKILL.md` 文件:
41+
一个 ADK 本地技能由独立目录构成,目录中包含一个 `SKILL.md` 文件。`SKILL.md` 必须包含 `name` 与 `description` frontmatter,且目录名必须与 `name` 一致:
2042

2143
<Files>
2244
<Folder name="skills" defaultOpen>
23-
<Folder name="kb_skill" defaultOpen>
45+
<Folder name="kb-skill" defaultOpen>
2446
<File name="SKILL.md" />
47+
<Folder name="references" />
48+
<Folder name="assets" />
49+
<Folder name="scripts" />
2550
</Folder>
2651
</Folder>
2752
</Files>
2853

29-
`SKILL.md` 使用 frontmatter 声明 `name` 与 `description`,其后为技能正文:
30-
31-
```markdown title="skills/kb_skill/SKILL.md"
54+
```markdown title="skills/kb-skill/SKILL.md"
3255
---
33-
name: kb_skill
56+
name: kb-skill
57+
description: 查询知识库并整理答案的技能。
3458
---
3559

3660
...正文部分(操作步骤、约束、脚本说明等)
3761
```
3862

39-
<Callout type="warn" title="命名要求">
40-
`SKILL.md` 中的 `name` 必须与所在目录名保持一致。
41-
</Callout>
63+
## Deprecated:VeADK 旧本地入口
64+
65+
`Agent(skills=..., skills_mode="local")` 会继续保持旧行为,但该本地入口已 deprecated。无论 `skills` 传入本地目录还是远端技能源,只要最终以 `local` 模式执行,VeADK 都会走旧的本地加载路径:加载技能元信息、把技能列表写入 `instruction`,并挂载旧的 `SkillsToolset`。
66+
67+
VeADK `skills` 参数仍支持三种技能运行模式,其中仅 `local` 的旧本地加载/执行路径标记为 deprecated:
68+
69+
| 模式 | 说明 |
70+
| :- | :- |
71+
| `local` | Deprecated。技能由 VeADK 旧 `skills_tool` 和配套文件/Shell 工具加载,建议迁移到 ADK `SkillToolset`。 |
72+
| `skills_sandbox` | 技能托管在云端技能空间(Skill Space),通过 `execute_skills` 工具在沙箱中执行。 |
73+
| `aio_sandbox` | All-in-one 沙箱模式,适用于 AgentKit 托管的工具运行时。 |
74+
75+
未显式设置 `skills_mode` 时,VeADK 会根据运行环境自动推断:本地运行默认为 `local`;在 AgentKit 工具运行时中,会根据工具类型自动选择 `skills_sandbox` 或 `aio_sandbox`。
4276

43-
## 本地模式
77+
### 本地模式
4478

45-
在 `local` 模式下,向 `skills` 传入技能目录的路径,并将 `skills_mode` 设置为 `local`:
79+
在 `local` 模式下,向 `skills` 传入技能根目录的路径,并将 `skills_mode` 设置为 `local`:
4680

4781
```python
4882
from veadk import Agent
4983

5084
agent = Agent(
51-
skills=["/abs/path/to/skills/kb_skill"],
85+
skills=["/abs/path/to/skills"],
5286
skills_mode="local",
5387
)
5488
```
5589

5690
Agent 在初始化时会加载技能元信息(`name` 与 `description`)并将其注入系统提示词,引导模型在合适的时机调用对应技能。本地模式下,VeADK 还会自动挂载一组配套工具(读写文件、编辑文件、执行 Shell 命令、注册技能等),供 Agent 在执行技能时使用。
5791

58-
## 沙箱模式
92+
### 沙箱模式
5993

6094
在 `skills_sandbox` 模式下,技能托管在云端技能空间。向 `skills` 传入云端技能空间标识,并引入 `execute_skills` 工具,Agent 会在需要时调用该工具在沙箱中执行所选技能:
6195

@@ -65,27 +99,28 @@ from veadk.tools.builtin_tools.execute_skills import execute_skills
6599

66100
agent = Agent(
67101
skills=[skill_space_id],
102+
skills_mode="skills_sandbox",
68103
tools=[execute_skills],
69104
)
70105
```
71106

72-
## 技能检查清单(Checklist)
107+
### 技能检查清单(Checklist)
73108

74109
技能可在其定义中携带一份检查清单(checklist),用于约束 Agent 按步骤完成任务。开启后,Agent 在执行技能时需逐项完成检查项,并通过 `update_check_list` 工具将每一项标记为已完成:
75110

76111
```python
77112
from veadk import Agent
78113

79114
agent = Agent(
80-
skills=["/abs/path/to/skills/kb_skill"],
115+
skills=["/abs/path/to/skills"],
81116
skills_mode="local",
82117
enable_skills_checklist=True,
83118
)
84119
```
85120

86121
当某个技能定义了 checklist 时,VeADK 会在该技能被调用时自动初始化所有检查项的状态,并在系统提示词中提示模型逐项完成。
87122

88-
## 动态加载技能
123+
### 动态加载技能
89124

90125
通过 `enable_dynamic_load_skills=True`,可在运行时动态发现并加载新的技能,而无需在 Agent 初始化时一次性声明全部技能:
91126

@@ -102,7 +137,7 @@ agent = Agent(
102137

103138
| 参数 | 类型 | 说明 |
104139
| :- | :- | :- |
105-
| `skills` | `list[str]` | 技能列表,元素为本地技能目录路径或云端技能空间标识。 |
106-
| `skills_mode` | `"local" \| "skills_sandbox" \| "aio_sandbox"` | 技能运行模式,缺省时自动推断。 |
107-
| `enable_skills_checklist` | `bool` | 是否启用技能检查清单,默认 `False`。 |
108-
| `enable_dynamic_load_skills` | `bool` | 是否启用技能的动态加载,默认 `False`。 |
140+
| `skills` | `list[str]` | 技能列表,元素为本地技能根目录路径或云端技能空间标识;当 `skills_mode="local"` 时,该旧本地加载路径已 deprecated。 |
141+
| `skills_mode` | `"local" \| "skills_sandbox" \| "aio_sandbox"` | 技能运行模式,缺省时自动推断;其中 `local` 旧路径已 deprecated,`skills_sandbox` / `aio_sandbox` 仍保持原用法。 |
142+
| `enable_skills_checklist` | `bool` | 是否启用旧技能检查清单,默认 `False`。 |
143+
| `enable_dynamic_load_skills` | `bool` | 是否启用旧技能的动态加载,默认 `False`。 |

0 commit comments

Comments
 (0)