Skip to content

fix(skills): preserve explicit skill context in workflow runs - #107

Merged
william-antoline-boon merged 2 commits into
boonfrom
fix/explicit-skill-restricted-tools
Aug 8, 2026
Merged

william-antoline-boon merged 2 commits into
boonfrom
fix/explicit-skill-restricted-tools

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Authorized /skill <name> commands were rewritten into generic model text, but the selected skill identity was discarded before agent execution. Restricted-tool workflow runs then removed the entire skills prompt, so the model had no access to the selected skill instructions.

Why This Change Was Made

  • carry the authorized explicit skill identity through queueing and both embedded and CLI-backed runners
  • retain only the selected skill prompt for restricted-tool runs
  • separate normal prompt-visible skills from user-invocable command skills so hidden skills are not exposed during ordinary runs
  • reload runtime-only command skill data after a cold session resume and strip it from persisted session state
  • split collect-mode batches when their selected skills differ

User Impact

Manual workflow runs can execute the selected skill with its SKILL.md context instead of returning a generic capability refusal. Normal chat runs continue to expose only model-visible skills.

Paired transport and producer changes:

Deployment order: OpenClaw first, anychat second, boon-core producer last.

Evidence

  • focused Vitest: 569 tests passed across skill loading, session persistence, queueing, auto-reply, embedded runner, and CLI runner surfaces
  • production TypeScript check passed
  • test TypeScript check passed
  • targeted oxlint passed
  • oxfmt check passed
  • full pnpm build passed

Summary by cubic

Fixes loss of explicit /skill <name> context during runs. The selected skill is now preserved and validated end-to-end, and restricted-tool runs use minimal prompts while keeping the selected skill’s prompt.

  • Bug Fixes

    • Carry the selected skill across queueing, auto-reply, embedded runs, and CLI runs via explicitSkillName.
    • Reload and validate the explicit command skill before CLI prep, including sandbox workspace support; reject runs when the skill is unavailable.
    • Restricted-tool runs switch to minimal prompts but keep the selected skill’s prompt; embedded tools snapshot narrows to the selected skill.
  • Refactors

    • Split runtime skills into prompt-visible resolvedSkills and user-invocable commandSkills; strip both from session persistence and hydrate both on resume.
    • Add a prompt policy helper to enforce restricted-tool rules without losing the selected skill’s context.
    • CLI skills plugin now selects materialized skills via a dedicated selector and updates fingerprinting to include explicitSkillName and pluginSkills.

Written for commit f748f44. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 38 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread src/agents/cli-runner/prepare.ts Resolved
Comment thread src/skills/loading/workspace.ts Resolved
Comment thread src/agents/cli-runner/prepare.ts Resolved

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved.

Traced the full 38-file diff. Solid, well-scoped fix for the dropped /skill context in restricted-tool workflow runs.

Correctness / architecture

  • The resolvedSkills (prompt-visible) vs commandSkills (user-invocable) split is the right shape — an explicit skill is resolved only from commandSkills/filterUserInvocableSkillEntries, never from the prompt-visible list. resolveRunPromptPolicy cleanly extracts the restricted-tool prompt rule and keeps the selected skill's prompt while stripping the general catalog.
  • Cold-resume path handled: resolveEmbeddedRunSkillEntries forces a reload when the persisted snapshot lacks the explicit skill, and hydrateRuntimeSkills rebuilds both lists.

Security

  • Authorization double-gated: handleInlineActions sets explicitSkillName only after the isAuthorizedSender check (unauthorized senders return early, no leak), and resolveExplicitSkillForRun refuses any userInvocable:false skill. Confirmed by the 'does not authorize from prompt-visible snapshot' + 'non-user-invocable' tests.
  • Persistence-stripping extended to commandSkills in stripPersistedSkillsCache — no sessions.json bloat and no SKILL.md body leak (tests assert both fields absent on disk).

Tests

  • Every new branch has a targeted test across skill loading, prompt policy, session persistence, queue collect-split, embedded + CLI runners. 569 focused Vitest pass; prod/test TS, oxlint, oxfmt, full build all green per the PR evidence.

No blocking issues. Nice clean refactor that reduces debt rather than adding it.

@william-antoline-boon
william-antoline-boon merged commit bb5823a into boon Aug 8, 2026
3 checks passed
@william-antoline-boon
william-antoline-boon deleted the fix/explicit-skill-restricted-tools branch August 8, 2026 18:23
william-antoline-boon added a commit that referenced this pull request Aug 9, 2026
* fix(test): mock the real skills/loading/workspace.js exports, not a hand-picked subset

attempt.spawn-workspace.context-engine.test.ts (and its sibling spawn-workspace
test) fail with:

  [vitest] No "resolveExplicitSkillForRun" export is defined on the
  "../../../skills/loading/workspace.js" mock.

#107 added resolveExplicitSkillForRun to src/skills/loading/workspace.ts and
attempt.ts now calls it directly, but the test-support mock for that module
was a hand-written full replacement exporting only resolveSkillsPromptForRun
-- any other real export throws when called under test.

Switch the mock to vi.importActual + spread (matching the existing pattern
used one mock up, for ../../workspace.js) so it tracks the module's real
export surface and only overrides what the test actually needs to control.

Verified: both spawn-workspace test files pass (124/124).

* release: 2026.6.11-boon.15

Version-bump release carrying the 1 commit merged onto boon since
boon.14: #107 (ENG-17282, preserve explicit skill context in
workflow runs).

Bumps gateway + slack + msteams + diagnostics-prometheus to
2026.6.11-boon.15 in lockstep (9 files).

* fix(deps): pin nanoid off HIGH advisories (GHSA-2v37-7h3g-55p8, GHSA-28wg-ghj8-5hjv)

pnpm-audit-prod flags 2 HIGH advisories in the production dependency graph:
- [email protected] (postcss>vite>vitest chain, reached via
  @openclaw/qa-lab's @copilotkit/aimock dependency) — GHSA-2v37-7h3g-55p8,
  non-secure generator can loop indefinitely when size is zero, fixed <3.3.17.
- [email protected] (node-llama-cpp, an optionalDependency of
  @openclaw/llama-cpp-provider) — GHSA-28wg-ghj8-5hjv, same generator-loop
  class, fixed >=5.1.16.

Range-scoped pnpm overrides (nanoid@3 / nanoid@5), matching the existing
undici@7 / undici@8 precedent in this file, rather than a single global
nanoid override — postcss's toolchain needs nanoid's CJS-era ^3 API while
node-llama-cpp resolves the ESM-only 5.x line, so a global override would
force one chain onto an incompatible major.

Both patched versions were published 2026-08-07T16:41:06Z, inside the repo's
2880-min minimumReleaseAge window as of this fix, so they need an explicit
minimumReleaseAgeExclude entry (same pattern as the other pinned CVE-fix
versions already in that list).

Regenerated extensions/llama-cpp/npm-shrinkwrap.json (the only extension
shrinkwrap that pins nanoid) via generate-npm-shrinkwrap.mjs.

Verified: node scripts/pre-commit/pnpm-audit-prod.mjs --audit-level=high
-> "No high or higher advisories found for production dependencies."
Also verified test/package-manager-config.test.ts +
test/plugin-npm-package-manifest.test.ts (21/21) — the npm-shrinkwrap
generation path that the earlier (reverted) 'parent>child' selector syntax
crashed with EINVALIDTAGNAME is exercised cleanly by this range-selector
form.
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.

1 participant