feat(core): add structured skills prompt context API#1065
feat(core): add structured skills prompt context API#1065
Conversation
🦋 Changeset detectedLatest commit: cb9813f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughThis PR adds a new public API workspace.skills.getPromptContext(...) that returns structured prompt metadata (available and activated skills), exposes related types, refactors buildPrompt(...) to consume that context, updates schemas and docs, and adds tests covering the new prompt-context behavior. Changes
Sequence Diagram(s)mermaid Caller->>Workspace: getPromptContext(options) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying voltagent with
|
| Latest commit: |
cb9813f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b8482f7e.voltagent.pages.dev |
| Branch Preview URL: | https://feat-workspace-skills-prompt.voltagent.pages.dev |
Diluka
left a comment
There was a problem hiding this comment.
voltagent/packages/core/src/workspace/skills/types.ts
Lines 39 to 50 in 61463a4
I feel this modification is unnecessary; I'll just assemble it myself. I'll add documentation comments to the return value, and if possible, for more ambiguous properties, I'll add an example in the documentation comments so that everyone knows what these properties mean.
|
These are the results I got from having Codex test them.
{
"id": "/skills/playwright-cli",
"name": "playwright-cli",
"description": "Automates browser interactions for web testing...",
"path": "/skills/playwright-cli/SKILL.md",
"root": "/skills/playwright-cli"
}
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/server-core/src/schemas/agent.schemas.ts`:
- Around line 99-110: Update the Zod schema field descriptions for references,
scripts, and assets in the agent schemas so they match the TypeScript interface
by explicitly stating they are "relative to `root`"; locate the
z.array(z.string()).optional().describe(...) entries for the references,
scripts, and assets fields and modify their describe(...) text to include the
phrase "relative to `root`" while keeping the existing examples (e.g., "Readable
files under `references/` relative to `root` (for example
`references/running-code.md`)").
| references: z | ||
| .array(z.string()) | ||
| .optional() | ||
| .describe("Readable files under `references/` (for example `references/running-code.md`)"), | ||
| scripts: z | ||
| .array(z.string()) | ||
| .optional() | ||
| .describe("Readable scripts under `scripts/` (for example `scripts/run.sh`)"), | ||
| assets: z | ||
| .array(z.string()) | ||
| .optional() | ||
| .describe("Readable assets under `assets/` (for example `assets/input.csv`)"), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find packages/core/src/workspace/skills -type f -name "*.ts" | head -20Repository: VoltAgent/voltagent
Length of output: 199
🏁 Script executed:
rg -n --type=ts -C5 'references|scripts|assets' packages/core/src/workspace/skills/ --max-count=30Repository: VoltAgent/voltagent
Length of output: 24194
🏁 Script executed:
# Also check the actual agent.schemas.ts file to see the exact examples given
sed -n '90,115p' packages/server-core/src/schemas/agent.schemas.tsRepository: VoltAgent/voltagent
Length of output: 1256
Add "relative to root" clarification to references, scripts, and assets descriptions for consistency with the source-of-truth TypeScript interface.
The descriptions in lines 99-110 use relative-path examples (references/running-code.md, scripts/run.sh, assets/input.csv), which are correct. However, the TypeScript interface in packages/core/src/workspace/skills/types.ts (lines 93-108) explicitly documents these fields as "relative to root", while the Zod schema descriptions omit this detail. This creates a documentation inconsistency that will propagate into OpenAPI specs and tool definitions.
✏️ Suggested description updates
references: z
.array(z.string())
.optional()
- .describe("Readable files under `references/` (for example `references/running-code.md`)"),
+ .describe("Readable files under `references/`, relative to `root` (for example `references/running-code.md`)"),
scripts: z
.array(z.string())
.optional()
- .describe("Readable scripts under `scripts/` (for example `scripts/run.sh`)"),
+ .describe("Readable scripts under `scripts/`, relative to `root` (for example `scripts/run.sh`)"),
assets: z
.array(z.string())
.optional()
- .describe("Readable assets under `assets/` (for example `assets/input.csv`)"),
+ .describe("Readable assets under `assets/`, relative to `root` (for example `assets/input.csv`)"),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| references: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable files under `references/` (for example `references/running-code.md`)"), | |
| scripts: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable scripts under `scripts/` (for example `scripts/run.sh`)"), | |
| assets: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable assets under `assets/` (for example `assets/input.csv`)"), | |
| references: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable files under `references/`, relative to `root` (for example `references/running-code.md`)"), | |
| scripts: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable scripts under `scripts/`, relative to `root` (for example `scripts/run.sh`)"), | |
| assets: z | |
| .array(z.string()) | |
| .optional() | |
| .describe("Readable assets under `assets/`, relative to `root` (for example `assets/input.csv`)"), |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/server-core/src/schemas/agent.schemas.ts` around lines 99 - 110,
Update the Zod schema field descriptions for references, scripts, and assets in
the agent schemas so they match the TypeScript interface by explicitly stating
they are "relative to `root`"; locate the
z.array(z.string()).optional().describe(...) entries for the references,
scripts, and assets fields and modify their describe(...) text to include the
phrase "relative to `root`" while keeping the existing examples (e.g., "Readable
files under `references/` relative to `root` (for example
`references/running-code.md`)").
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
buildPrompt()output directly.What is the new behavior?
workspace.skills.getPromptContext(...)to return structured skill metadata for prompt composition.buildPrompt()was refactored to reuse the new structured context path while preserving existing output behavior.id,name,description,path, andactive..changeset/yellow-cars-smile.mdfixes (issue)
Notes for reviewers
Validation run:
pnpm --filter @voltagent/core test:single -- src/workspace/skills/index.spec.tspnpm --filter @voltagent/core typecheckFiles changed in this PR:
packages/core/src/workspace/index.tspackages/core/src/workspace/skills/index.tspackages/core/src/workspace/skills/types.tspackages/core/src/workspace/skills/index.spec.tswebsite/docs/workspaces/skills.md.changeset/yellow-cars-smile.mdSummary by CodeRabbit
Release Notes
New Features
getPromptContext()API to retrieve structured skill metadata including availability status, descriptions, paths, and activation information for each skill.Documentation