Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/curly-ants-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@voltagent/core": patch
---

Fix workspace skill prompt injection and guidance for skill access tools.

- Change activated skill prompt injection to include metadata only (`name`, `id`, `description`) instead of embedding full `SKILL.md` instruction bodies.
- Clarify workspace skills system prompt so agents use workspace skill tools for skill access and avoid sandbox commands like `execute_command`, `ls /skills`, or `cat /skills/...`.
51 changes: 51 additions & 0 deletions packages/core/src/workspace/skills/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,57 @@ Analyze the files and summarize findings.`;
});
});

describe("WorkspaceSkills prompt generation", () => {
it("injects only activated skill metadata without full instructions", async () => {
const timestamp = new Date().toISOString();
const workspace = new Workspace({
filesystem: {
files: {
"/skills/data/SKILL.md": {
content: `---
name: Data Analyst
description: Analyze CSV data
---
INSTRUCTIONS_SHOULD_NOT_APPEAR
Run deep analysis and produce charts.`.split("\n"),
created_at: timestamp,
modified_at: timestamp,
},
},
},
skills: {
rootPaths: ["/skills"],
autoDiscover: false,
},
});

await workspace.skills?.discoverSkills();
await workspace.skills?.activateSkill("Data Analyst");

const prompt = await workspace.skills?.buildPrompt({
includeAvailable: false,
includeActivated: true,
});

expect(prompt).toContain("Activated skills:");
expect(prompt).toContain("- Data Analyst (/skills/data) - Analyze CSV data");
expect(prompt).not.toContain("INSTRUCTIONS_SHOULD_NOT_APPEAR");
});

it("includes explicit guidance to use workspace skill tools", () => {
const workspace = new Workspace({
skills: {
rootPaths: ["/skills"],
},
});

const instructions = workspace.skills?.getInstructions();
expect(instructions).toContain("Access skills with workspace skill tools only.");
expect(instructions).toContain("Do not use sandbox commands");
expect(instructions).toContain("workspace_read_skill_script");
});
});

describe("WorkspaceSkills file access", () => {
it("allows listed reference files and blocks others", async () => {
const timestamp = new Date().toISOString();
Expand Down
35 changes: 22 additions & 13 deletions packages/core/src/workspace/skills/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const DEFAULT_MAX_PROMPT_CHARS = 12000;

const SKILLS_SYSTEM_PROMPT = `You can manage workspace skills.

Important:
- Access skills with workspace skill tools only.
- Do not use sandbox commands (for example: execute_command, ls /skills, cat /skills/...) to inspect skills.
- Use dedicated skill read tools for references, scripts, and assets.

Use these tools:
- workspace_list_skills: list available skills
- workspace_search_skills: search skill instructions
- workspace_read_skill: read skill instructions
Expand Down Expand Up @@ -918,7 +924,10 @@ export class WorkspaceSkills {
const skills = Array.from(this.skillsById.values()).slice(0, maxAvailable);
if (skills.length > 0) {
const lines = skills.map((skill) => {
const description = skill.description ? ` - ${skill.description}` : "";
const descriptionText = skill.description
? truncateText(skill.description, maxInstructionChars)
: "";
const description = descriptionText ? ` - ${descriptionText}` : "";
return `- ${skill.name} (${skill.id})${description}`;
});
sections.push(`Available skills:\n${lines.join("\n")}`);
Expand All @@ -928,18 +937,18 @@ export class WorkspaceSkills {
if (includeActivated) {
const activeIds = Array.from(this.activeSkills).slice(0, maxActivated);
if (activeIds.length > 0) {
const entries: string[] = [];
for (const id of activeIds) {
const skill = await this.loadSkill(id, { context: options.context });
if (!skill) {
continue;
}
const header = `${skill.name} (${skill.id})`;
const body = truncateText(skill.instructions || "", maxInstructionChars);
entries.push(`${header}\n${body}`);
}
if (entries.length > 0) {
sections.push(`Activated skills:\n${entries.join("\n\n")}`);
const lines = activeIds
.map((id) => this.skillsById.get(id))
.filter((skill): skill is WorkspaceSkillMetadata => Boolean(skill))
.map((skill) => {
const descriptionText = skill.description
? truncateText(skill.description, maxInstructionChars)
: "";
const description = descriptionText ? ` - ${descriptionText}` : "";
return `- ${skill.name} (${skill.id})${description}`;
});
if (lines.length > 0) {
sections.push(`Activated skills:\n${lines.join("\n")}`);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/workspaces/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const agent = new Agent({
```

The injected prompt is wrapped in `<workspace_skills>` tags and can include both available and activated skills.
It includes skill metadata (name, id, description). To read full `SKILL.md` instructions, use `workspace_read_skill`.

## Skill tools

Expand Down