Skip to content

fix(skills): load installed skills via sandbox carve-out and deterministic activation - #571

Merged
edenreich merged 6 commits into
mainfrom
fix/skills-loading-569
Jun 1, 2026
Merged

edenreich merged 6 commits into
mainfrom
fix/skills-loading-569

Conversation

@edenreich

@edenreich edenreich commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #569 — installed skills were unusable when the agent ran outside the project directory (notably the @infer CI bot, which installs to ~/.infer/skills/). Two compounding defects, both addressed:

  1. Sandbox blocked the only path to a skill's instructions. buildSkillsInfo() tells the model to Read each SKILL.md, but ~/.infer/skills/ is outside the default Read sandbox, so the Read was denied.
  2. Activation was non-deterministic. The SKILL.md body is discarded at startup (progressive disclosure) and there was no explicit trigger, so whether a skill was ever applied depended on the model opportunistically deciding to Read a file it couldn't read.

Changes

  • Sandbox carve-out (config/config.go): ValidatePathInSandbox now allows read access to ~/.infer/skills and ./.infer/skills when agent.skills.enabled, mirroring the existing ~/.claude carve-out. This unblocks the model's on-demand Read of SKILL.md and references/*.md. checkProtectedPaths still runs first, so protected files under the skills dir remain denied.
  • Deterministic activation (internal/agent/agent_utils.go): a new buildActiveSkillInfo() scans user messages for an explicit invocation (/<name> or "use the <name> skill") and injects the invoked skill's metadata (description + path) into the system prompt as an ACTIVE SKILL pointer instructing the agent to read and follow it. This works in every mode (chat, infer agent, channels, heartbeat) since all funnel through addSystemPrompt. The SKILL.md body stays progressive-disclosure — read on demand via the Read tool (now reachable thanks to the carve-out), not inlined.
  • Chat routing (internal/handlers/chat_message_processor.go): /<known-skill> input is routed to the agent (which then flags the skill active) instead of dead-ending as "Unknown shortcut".
  • A lightweight Get(name) lookup was added to domain.SkillsService (used by both the agent matcher and the chat router).

Design note

Activation detection is centralized in the agent rather than duplicated across entry points, because addSystemPrompt is the single funnel for all run modes. Per maintainer review, the full body is not injected — only a deterministic pointer + metadata; the body remains progressive-disclosure via Read.

Tests

  • config: carve-out allows both scopes when enabled, rejects when disabled, rejects lookalike sibling dirs, and protected paths still block.
  • skills: Get hit/miss + scope precedence.
  • agent: trigger matrix — slash, phrase (case-insensitive), adjacent /foo /bar, two-skill plural header, dedupe across messages, unknown token ignored, assistant-message ignored, nil service.
  • handlers: /skill routes as a message; non-skill /xyz still hits the shortcut path.
  • task test + task lint green.

Follow-up

  • A matching [DOCS] ticket for inference-gateway/docs (skills activation + sandbox behavior) should accompany this PR.

…istic activation

Installed skills were unusable when the agent ran outside the project
directory (e.g. the @infer CI bot installs to ~/.infer/skills): the Read
sandbox blocked the only path to a skill's SKILL.md, and activation was
left entirely to the model.

- Sandbox: allow read access to ~/.infer/skills and ./.infer/skills when
  agent.skills.enabled, mirroring the existing ~/.claude carve-out. This
  unblocks the model's on-demand Read of SKILL.md (and references/*.md).
- Deterministic activation: on explicit invocation ("/<name>" or "use the
  <name> skill") inject the invoked skill's metadata (description + path)
  as an ACTIVE SKILL pointer, so the agent reliably knows to read and apply
  it regardless of mode (chat, agent, channels, heartbeat). The SKILL.md
  body stays progressive-disclosure, read on demand via the Read tool.
- Chat: route "/<known-skill>" input to the agent instead of dead-ending
  as "Unknown shortcut".

Closes #569
@edenreich
edenreich force-pushed the fix/skills-loading-569 branch from 6bf4706 to 3bd0c5d Compare June 1, 2026 18:18
Comment thread internal/agent/agent_utils.go Resolved
Comment thread internal/agent/agent_utils.go Resolved
Comment thread internal/ui/inputsyntax/inputsyntax.go Resolved
Comment thread internal/ui/inputsyntax/inputsyntax.go Resolved
@edenreich
edenreich merged commit 18a9287 into main Jun 1, 2026
@edenreich
edenreich deleted the fix/skills-loading-569 branch June 1, 2026 20:08
edenreich added a commit that referenced this pull request Jun 1, 2026
Resolve conflict in internal/agent/agent_utils.go: keep both this branch's
GitHub gh-CLI guidance (buildGitHubGuidanceInfo) and main's deterministic
skill activation (buildActiveSkillInfo, #571) in buildContextInfo. Thread
messages through buildSystemPromptText so BuildSystemPrompt() passes nil for
a fresh session (no active skill yet).
inference-gateway-releaser Bot pushed a commit that referenced this pull request Jun 1, 2026
## [0.117.0](v0.116.0...v0.117.0) (2026-06-01)

### 🚀 Features

* add GitHub issue references autocomplete and inline expansion ([#574](#574)) ([5056c9d](5056c9d)), closes [#N](https://github.com/inference-gateway/cli/issues/N) [#573](#573)

### 🐛 Bug Fixes

* **skills:** load installed skills via sandbox carve-out and deterministic activation ([#571](#571)) ([18a9287](18a9287)), closes [#569](#569)

### ♻️ Code Refactoring

* **system-prompt:** add available tools info to system prompt ([a913728](a913728))
* remove built-in Github tool in favor of the gh CLI ([#572](#572)) ([4c74997](4c74997))
* **config:** remove inline redundant comment ([c389929](c389929))
* system prompt - reduce tokens ([0be4b3a](0be4b3a))

### 👷 CI/CD

* centralize infer.yml + bump infer CLI and sync .infer config ([#567](#567)) ([c0369de](c0369de))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.117.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jun 1, 2026
edenreich added a commit that referenced this pull request Jun 2, 2026
…ditionally (#578)

Resolves #577

## Summary

Follow-up to #569 / #571 (shipped in v0.117.0). The sandbox carve-out
for `~/.infer/skills` and `./.infer/skills` was conditional on
`c.Agent.Skills.Enabled` being true at `ValidatePathInSandbox` time.
When that flag is not set — running with default config, before `infer
config agent skills enable` has run, or when the
`INFER_AGENT_SKILLS_ENABLED` override has not reached the validator —
the carve-out silently did not fire and reads of `SKILL.md` were denied
with `outside configured sandbox directories`.

Skills directories are a well-known, read-only allowlist under
`~/.infer/`. Gating their **sandbox visibility** on a runtime feature
flag re-introduces the failure mode #569 was meant to remove.

## Changes

1. **DefaultConfig()**: Include `./.infer/skills` and `~/.infer/skills`
in `Sandbox.Directories` unconditionally (no flag gating).
2. **ValidatePathInSandbox()**: Remove the
`c.Agent.Skills.Enabled`-gated `isWithinSkillsDir` branch from the
`carveOut` expression. The `tmp/plans` carve-out is preserved as it is
orthogonal.
3. **checkProtectedPaths()**: Add `isWithinSkillsDir()` short-circuit at
the top so that the broader `.infer/` protected-path pattern does not
deny readable skills files. Skills dirs are fully trusted.
4. **Tests**: Rewrite `TestValidatePathInSandbox_SkillsCarveOut` to
verify that skills reads succeed with `DefaultConfig()` and
`Skills.Enabled=false`, that `~/.infer/config.yaml` and
`conversations.db` remain protected, and that `skills-evil` sibling dirs
are still rejected.

## Why this is better

- One source of truth for *what is readable*: `Sandbox.Directories`. No
second runtime predicate to keep in sync.
- `agent.skills.enabled` goes back to meaning exactly "load skill
metadata into the prompt and offer them to the agent" — purely about
discovery/loading, no sandbox semantics.
- No env-var plumbing required from `infer-action` or any other
consumer.
- Behavior is identical across `chat`, `infer agent`, channels, and
heartbeat — no per-mode flag drift.

## Follow-up

Once this lands and a new CLI is cut:
- `inference-gateway/infer-action` — bump `inputs.version.default` in
`action.yml` to the new CLI release.
- `inference-gateway/.github` — bump `cli-version` default in the
centralized infer workflow.

---------

Co-authored-by: {"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/users/users#get-the-authenticated-user","status":"403"} <{"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/users/users#get-the-authenticated-user","status":"403"}+{"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/users/users#get-the-authenticated-user","status":"403"}@users.noreply.github.com>
Co-authored-by: Eden Reich <[email protected]>
inference-gateway-releaser Bot pushed a commit that referenced this pull request Jun 2, 2026
## [0.117.1](v0.117.0...v0.117.1) (2026-06-02)

### 🐛 Bug Fixes

* **sandbox:** move skills dirs into default Sandbox.Directories unconditionally ([#578](#578)) ([e67222e](e67222e)), closes [#577](#577) [#569](#569) [#571](#571) [#569](#569)

### 👷 CI/CD

* **infer:** centralize infer.yml + bump infer CLI and sync .infer config ([#575](#575)) ([bcf7ca4](bcf7ca4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Agent can't load installed skills: ~/.infer/skills is outside the Read sandbox and activation is non-deterministic

1 participant