Skip to content

[FEATURE]: Add hidden field to tool.definition hook output for tool suppression #23297

Closed

Description

@M0Rf30

Problem

The tool.definition hook allows plugins to modify tool descriptions and parameters, but cannot remove tools from the LLM's tool list entirely. This means deferred/lazy tool loading plugins (like opencode-tool-search) must still send stub entries for every deferred tool, wasting ~10-20 tokens per tool per turn.

With 180+ tools, that's ~2,000-3,600 tokens of overhead per turn that could be eliminated.

Proposed solution

Add an optional hidden boolean to the tool.definition hook output:

"tool.definition"?: (input: {
    toolID: string;
}, output: {
    description: string;
    parameters: any;
    hidden?: boolean;  // NEW — when true, tool is excluded from the LLM tool list
}) => Promise<void>;

On the Go side, the change is minimal — skip the tool when building the tool list if output.Hidden is true:

// In resolveTools or equivalent:
if hookOutput.Hidden {
    continue
}

Why this matters

Alternatives considered

  • Modifying description to a short stub: Already implemented in opencode-tool-search, but each tool still costs ~10-20 tokens for its name + minimal schema. The hidden field eliminates this entirely.
  • Separate tool.filter hook: More complex; a single boolean field on the existing hook is simpler and sufficient.

Related

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 18, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
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