mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-24 09:35:05 +00:00
tweak: adjust skill presentation to be a little less token heavy (#17098)
This commit is contained in:
@@ -64,7 +64,9 @@ export namespace SystemPrompt {
|
|||||||
return [
|
return [
|
||||||
"Skills provide specialized instructions and workflows for specific tasks.",
|
"Skills provide specialized instructions and workflows for specific tasks.",
|
||||||
"Use the skill tool to load a skill when a task matches its description.",
|
"Use the skill tool to load a skill when a task matches its description.",
|
||||||
list.length === 0 ? "No skills are currently available." : "\n" + Skill.fmt(list),
|
// the agents seem to ingest the information about skills a bit better if we present a more verbose
|
||||||
|
// version of them here and a less verbose version in tool description, rather than vice versa.
|
||||||
|
Skill.fmt(list, { verbose: true }),
|
||||||
].join("\n")
|
].join("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,17 +196,23 @@ export namespace Skill {
|
|||||||
return list.filter((skill) => PermissionNext.evaluate("skill", skill.name, agent.permission).action !== "deny")
|
return list.filter((skill) => PermissionNext.evaluate("skill", skill.name, agent.permission).action !== "deny")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fmt(list: Info[]) {
|
export function fmt(list: Info[], opts: { verbose: boolean }) {
|
||||||
return [
|
if (list.length === 0) {
|
||||||
"<available_skills>",
|
return "No skills are currently available."
|
||||||
...list.flatMap((skill) => [
|
}
|
||||||
` <skill>`,
|
if (opts.verbose) {
|
||||||
` <name>${skill.name}</name>`,
|
return [
|
||||||
` <description>${skill.description}</description>`,
|
"<available_skills>",
|
||||||
` <location>${pathToFileURL(skill.location).href}</location>`,
|
...list.flatMap((skill) => [
|
||||||
` </skill>`,
|
` <skill>`,
|
||||||
]),
|
` <name>${skill.name}</name>`,
|
||||||
"</available_skills>",
|
` <description>${skill.description}</description>`,
|
||||||
].join("\n")
|
` <location>${pathToFileURL(skill.location).href}</location>`,
|
||||||
|
` </skill>`,
|
||||||
|
]),
|
||||||
|
"</available_skills>",
|
||||||
|
].join("\n")
|
||||||
|
}
|
||||||
|
return ["## Available Skills", ...list.flatMap((skill) => `- **${skill.name}**: ${skill.description}`)].join("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const SkillTool = Tool.define("skill", async (ctx) => {
|
|||||||
"The following skills provide specialized sets of instructions for particular tasks",
|
"The following skills provide specialized sets of instructions for particular tasks",
|
||||||
"Invoke this tool to load a skill when a task matches one of the available skills listed below:",
|
"Invoke this tool to load a skill when a task matches one of the available skills listed below:",
|
||||||
"",
|
"",
|
||||||
Skill.fmt(list),
|
Skill.fmt(list, { verbose: false }),
|
||||||
].join("\n")
|
].join("\n")
|
||||||
|
|
||||||
const examples = list
|
const examples = list
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ description: Skill for tool tests.
|
|||||||
fn: async () => {
|
fn: async () => {
|
||||||
const tool = await SkillTool.init()
|
const tool = await SkillTool.init()
|
||||||
const skillPath = path.join(tmp.path, ".opencode", "skill", "tool-skill", "SKILL.md")
|
const skillPath = path.join(tmp.path, ".opencode", "skill", "tool-skill", "SKILL.md")
|
||||||
expect(tool.description).toContain(`<location>${pathToFileURL(skillPath).href}</location>`)
|
expect(tool.description).toContain(`**tool-skill**: Skill for tool tests.`)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user