Skip to content

feat(core): add structured skills prompt context API#1065

Open
omeraplak wants to merge 2 commits intomainfrom
feat/workspace-skills-prompt-context
Open

feat(core): add structured skills prompt context API#1065
omeraplak wants to merge 2 commits intomainfrom
feat/workspace-skills-prompt-context

Conversation

@omeraplak
Copy link
Member

@omeraplak omeraplak commented Feb 13, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

  • Workspace skills only expose buildPrompt() output directly.
  • There is no dedicated structured context API to assemble custom skills prompt sections from normalized skill metadata.

What is the new behavior?

  • Added 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.
  • Returned prompt context now includes normalized metadata such as id, name, description, path, and active.
  • Added tests for the new prompt context and prompt generation flow.
  • Added docs for custom prompt assembly usage.
  • Added changeset:
    • .changeset/yellow-cars-smile.md

fixes (issue)

  • N/A

Notes for reviewers

Validation run:

  • pnpm --filter @voltagent/core test:single -- src/workspace/skills/index.spec.ts
  • pnpm --filter @voltagent/core typecheck

Files changed in this PR:

  • packages/core/src/workspace/index.ts
  • packages/core/src/workspace/skills/index.ts
  • packages/core/src/workspace/skills/types.ts
  • packages/core/src/workspace/skills/index.spec.ts
  • website/docs/workspaces/skills.md
  • .changeset/yellow-cars-smile.md

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced getPromptContext() API to retrieve structured skill metadata including availability status, descriptions, paths, and activation information for each skill.
    • Enhanced prompt building with optimized context handling and improved data reusability.
  • Documentation

    • Added detailed examples demonstrating how to use the new prompt context API for implementing custom skill prompt formatting.

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: cb9813f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

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

@joggrbot

This comment has been minimized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Type definitions & exports
packages/core/src/workspace/skills/types.ts, packages/core/src/workspace/index.ts
Added types: WorkspaceSkillMetadata, WorkspaceSkillsPromptSkill, WorkspaceSkillsPromptContext, and WorkspaceSkillsPromptContextOptions. Re-exported prompt types from workspace index to expand public API surface.
Skills API implementation
packages/core/src/workspace/skills/index.ts
Added getPromptContext(options) (supports optional refresh) returning available/activated skill lists; refactored buildPrompt() to accept/use the prompt context; introduced toPromptSkill() mapping and truncation logic for descriptions.
Tests
packages/core/src/workspace/skills/index.spec.ts
Added tests asserting getPromptContext() returns structured prompt context (available and activated arrays with expected fields) after discovery and activation.
Schemas
packages/server-core/src/schemas/agent.schemas.ts
Enhanced WorkspaceSkillMetadataSchema with human-readable .describe(...) text for each field (no shape changes).
Documentation
website/docs/workspaces/skills.md
Added examples showing how to use workspace.skills.getPromptContext(...) for custom prompt formatting and how to disable auto prompt injection.
Changeset
.changeset/yellow-cars-smile.md
Release notes describing the new getPromptContext() API and buildPrompt refactor.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Caller
participant Workspace as Workspace.skills
participant Discovery as SkillDiscovery
participant Store as SkillStore
participant Builder as PromptBuilder

Caller->>Workspace: getPromptContext(options)
alt options.refresh == true
Workspace->>Discovery: discoverSkills()
Discovery->>Store: update skill metadata
Store-->>Workspace: skills list
else
Workspace->>Store: ensureDiscovered()
Store-->>Workspace: skills list
end
Workspace->>Workspace: map to promptContext (available, activated)
Workspace-->>Caller: WorkspaceSkillsPromptContext
Caller->>Builder: buildPrompt(promptContext, options)
Builder->>PromptBuilder: build sections from promptContext.available & activated
Builder-->>Caller: prompt string

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 New context hops into view,
Available and active, tidy and true.
I nibble metadata, short and sweet,
Prompts lined up, a crunchy treat.
Hooray — structured skills ready to chew!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(core): add structured skills prompt context API' directly and clearly describes the main change—adding a new structured prompt context API for skills.
Description check ✅ Passed The PR description follows the template, includes current behavior, new behavior, test/doc/changeset confirmation, validation commands, and a clear summary of changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/workspace-skills-prompt-context

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 13, 2026

Deploying voltagent with  Cloudflare Pages  Cloudflare Pages

Latest commit: cb9813f
Status: ✅  Deploy successful!
Preview URL: https://b8482f7e.voltagent.pages.dev
Branch Preview URL: https://feat-workspace-skills-prompt.voltagent.pages.dev

View logs

Copy link
Contributor

@Diluka Diluka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export type WorkspaceSkillMetadata = {
id: string;
name: string;
description?: string;
version?: string;
tags?: string[];
path: string;
root: string;
references?: string[];
scripts?: string[];
assets?: string[];
};

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.

@Diluka
Copy link
Contributor

Diluka commented Feb 14, 2026

These are the results I got from having Codex test them.

  • id: string Unique identifier (commonly /<root>/<skill-name>)
  • name: string Skill name
  • description?: string Description
  • version?: string Version (from SKILL.md frontmatter)
  • tags?: string[] Tags (frontmatter)
  • path: string Full path to SKILL.md
  • root: string Root directory path of the skill
  • references?: string[] List of readable files under references/
  • scripts?: string[] List of readable scripts under scripts/
  • assets?: string[] List of resources under assets/
{
  "id": "/skills/playwright-cli",
  "name": "playwright-cli",
  "description": "Automates browser interactions for web testing...",
  "path": "/skills/playwright-cli/SKILL.md",
  "root": "/skills/playwright-cli"
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`)").

Comment on lines +99 to +110
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`)"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find packages/core/src/workspace/skills -type f -name "*.ts" | head -20

Repository: VoltAgent/voltagent

Length of output: 199


🏁 Script executed:

rg -n --type=ts -C5 'references|scripts|assets' packages/core/src/workspace/skills/ --max-count=30

Repository: 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.ts

Repository: 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.

Suggested change
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`)").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants