Skip to content

FEATURE: Plugin API - per-agent tool visibility filtering #24953

Closed as not planned

Description

@Qiiks

Problem

When a plugin registers tools via Hooks.tool in the plugin API, all tools are globally visible to every agent in the LLM context. There is no mechanism to scope tool visibility to specific agents.

This creates issues for plugins that want to register domain-specific tools (e.g., security assessment tools, admin tools, privileged operations) that should only be accessible by a designated agent - not by every agent the user switches to.

Example Use Case

A security plugin registers security scanning tools. These should only be visible to a cybersec agent. When the user switches to sisysphus (general coding), those tools should not appear in the LLM's tool context at all - they should not even be suggested.

Current Limitations

  • AgentConfig.tools only controls execution permission, not LLM context visibility
  • tool.execute.before can block execution but the tools are still visible and suggested by the LLM
  • System prompt injection discourages use but does not hide the tools
  • oh-my-openagent's disabled_tools only filters its own internal tool list, not OpenCode core's plugin tool registry

Proposed Solution

Option A - New hook: Add a tool.definition hook that receives agent/session context:

"tool.definition"?: (input: {
    toolID: string;
    sessionID: string;
    agent: string;
}, output: {
    description: string;
    parameters: any;
    hidden?: boolean;
}) => Promise<void>;

This would allow plugins to dynamically hide tools per-agent by setting hidden: true.

Option B - Expand AgentConfig.tools to have a visibility-only mode where tools set to false are stripped from context entirely, not just blocked at execution time.

Option C - Allow the config hook to specify per-agent tool context filtering beyond just execution permission.

Workaround

Currently using a 3-layer defense:

  1. tool.execute.before throws error blocking execution for non-allowed agents
  2. experimental.chat.system.transform injects a restriction notice
  3. AgentConfig.tools whitelist set to false for non-allowed agents

But the tools still appear in the LLM's function-calling context, wasting tokens and occasionally causing the LLM to attempt usage even with system prompt discouragement. True per-agent tool hiding requires OpenCode core changes.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 29, 2026
  2. github-actions commented on Apr 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. practicusai commented on Jun 23, 2026

    @practicusai

    This would be a fantastic feature.. FYI; we tried gutting "tool.definition" description and parameters, but parameters cannot be altered, only the description.

  5. github-actions commented on Aug 23, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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