Skip to content

[FEATURE]: Let plugins filter model-visible Skills per session #46798

Open

Description

@Slimzeo

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

We are building a third-party plugin called hev that organizes OpenCode's already-discovered native Skills into user-defined Environments and binds one Environment to each OpenCode session. The plugin does not install, parse, or load Skill bodies. It only decides which native Skills the model should automatically see for the current session.

Today, plugins can contribute Skill sources, but they cannot filter the resolved, model-visible Skill catalog at runtime. Static agent permissions cannot represent a plugin-owned session-to-Environment binding. Post-processing the system prompt would also be fragile because the model-facing skill tool could bypass it.

Could the V2 plugin Skill API provide a session-scoped visibility hook, conceptually like this?

ctx.skill.visibility(async (event) => {
  const allowed = await environmentSkills(event.sessionID)
  event.skills = event.skills.filter((skill) => allowed.has(skill.name))
})

The hook would receive the current session ID, agent ID, and resolved Skill list. Its result would be used consistently by both Skill guidance (<available_skills>) and the model-facing skill tool. This extension point could also support other plugins that manage Skill profiles, workspaces, or context budgets.

Compatibility boundaries:

  • When no visibility hook is registered, current behavior remains unchanged.
  • OpenCode continues to own native Skill discovery, permissions, and body loading.
  • The hook only controls model-visible Skills; explicit user invocation such as /skill-name remains available.
  • Plugins own their session policy; no persisted OpenCode setting or HTTP API is required.
  • No hev-specific concept needs to enter OpenCode core.

This is related to #11972 and #33336, but distinct: those cover static frontmatter or agent-permission behavior, while this request enables dynamic, plugin-owned, per-session catalog selection.

Would this plugin extension point fit the project direction, and should an implementation currently target dev or v2? I would be happy to contribute it after design approval.

Activity

  1. changed the title [-]Support session-scoped skill visibility in plugins[/-] [+][FEATURE]: Support session-scoped skill visibility in plugins[/+] on Sep 2, 2026
  2. changed the title [-][FEATURE]: Support session-scoped skill visibility in plugins[/-] [+][FEATURE]: Let plugins filter model-visible Skills per session[/+] on Sep 2, 2026
  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed proposal! In short, you're asking for a session-scoped plugin hook that filters which already-discovered skills the model sees, applied the same way to <available_skills> and to the skill tool, while /skill-name keeps working. Maintainers will consider it.

    On your branch question: v2 now lives on dev. The v2 branch was promoted to dev, so that's the base for any work.

    In the meantime, you may be able to do most of this today with per-session permissions. Both the skill guidance (Skill.available, which filters by the skill permission) and the skill tool (permission.assert({ action: "skill", resources: [skill.id], sessionID })) check the same ruleset: the agent's rules plus Session.Info.permissions, which are evaluated last. A plugin can write that ruleset with ctx.session.update. Here is a rough sketch; it type-checks against the plugin package but I haven't tested it end to end:

    import { define } from "@opencode/plugin"
    
    export default define({
      id: "hev.skill-visibility",
      setup: async (ctx) => {
        // Call this when a session is bound to an Environment, or when skills reload
        const apply = async (sessionID: string, allowed: Set<string>) => {
          const session = await ctx.session.get({ sessionID: sessionID as any })
          // keep unrelated rules, drop the skill deny rules this plugin wrote earlier
          const kept = (session.permissions ?? []).filter((r) => !(r.action === "skill" && r.effect === "deny"))
          const denied = (await ctx.skill.list({}))
            .filter((skill) => !allowed.has(skill.name))
            .map((skill) => ({ action: "skill", resource: skill.id, effect: "deny" as const }))
          await ctx.session.update({ sessionID: session.id, permissions: [...kept, ...denied] })
        }
      },
    })

    It uses only deny rules, so it never re-allows a skill that an agent's config denies. Its limits are the reasons a real hook would still help:

    • Session permissions are a single persisted ruleset that gets replaced as a whole, so the plugin has to merge it with other rules.
    • The deny rules go stale when skills are added or reloaded, so the plugin must re-apply them.
    • The existing permission.evaluate hook only affects tool calls. It can't hide entries from <available_skills>.

    Related issues:

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions