Skip to content

Commit 2a1ce6b

Browse files
authored
tweak: adjust skill presentation to be a little less token heavy (anomalyco#17098)
1 parent 238c0b8 commit 2a1ce6b

4 files changed

Lines changed: 23 additions & 15 deletions

File tree

packages/opencode/src/session/system.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export namespace SystemPrompt {
6464
return [
6565
"Skills provide specialized instructions and workflows for specific tasks.",
6666
"Use the skill tool to load a skill when a task matches its description.",
67-
list.length === 0 ? "No skills are currently available." : "\n" + Skill.fmt(list),
67+
// the agents seem to ingest the information about skills a bit better if we present a more verbose
68+
// version of them here and a less verbose version in tool description, rather than vice versa.
69+
Skill.fmt(list, { verbose: true }),
6870
].join("\n")
6971
}
7072
}

packages/opencode/src/skill/skill.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,23 @@ export namespace Skill {
196196
return list.filter((skill) => PermissionNext.evaluate("skill", skill.name, agent.permission).action !== "deny")
197197
}
198198

199-
export function fmt(list: Info[]) {
200-
return [
201-
"<available_skills>",
202-
...list.flatMap((skill) => [
203-
` <skill>`,
204-
` <name>${skill.name}</name>`,
205-
` <description>${skill.description}</description>`,
206-
` <location>${pathToFileURL(skill.location).href}</location>`,
207-
` </skill>`,
208-
]),
209-
"</available_skills>",
210-
].join("\n")
199+
export function fmt(list: Info[], opts: { verbose: boolean }) {
200+
if (list.length === 0) {
201+
return "No skills are currently available."
202+
}
203+
if (opts.verbose) {
204+
return [
205+
"<available_skills>",
206+
...list.flatMap((skill) => [
207+
` <skill>`,
208+
` <name>${skill.name}</name>`,
209+
` <description>${skill.description}</description>`,
210+
` <location>${pathToFileURL(skill.location).href}</location>`,
211+
` </skill>`,
212+
]),
213+
"</available_skills>",
214+
].join("\n")
215+
}
216+
return ["## Available Skills", ...list.flatMap((skill) => `- **${skill.name}**: ${skill.description}`)].join("\n")
211217
}
212218
}

packages/opencode/src/tool/skill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const SkillTool = Tool.define("skill", async (ctx) => {
2424
"The following skills provide specialized sets of instructions for particular tasks",
2525
"Invoke this tool to load a skill when a task matches one of the available skills listed below:",
2626
"",
27-
Skill.fmt(list),
27+
Skill.fmt(list, { verbose: false }),
2828
].join("\n")
2929

3030
const examples = list

packages/opencode/test/tool/skill.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ description: Skill for tool tests.
4545
fn: async () => {
4646
const tool = await SkillTool.init()
4747
const skillPath = path.join(tmp.path, ".opencode", "skill", "tool-skill", "SKILL.md")
48-
expect(tool.description).toContain(`<location>${pathToFileURL(skillPath).href}</location>`)
48+
expect(tool.description).toContain(`**tool-skill**: Skill for tool tests.`)
4949
},
5050
})
5151
} finally {

0 commit comments

Comments
 (0)