Skip to content

[bug] No pre-flight validation before tool execution despite tool.execute.before hooks #33076

Closed as not planned

Description

Description

opencode's tool.execute.before hook infrastructure exists (packages/opencode/src/session/tools.ts L54-L69) but has no built-in pre-flight safety validation. The hook is only wired for plugin triggering, not for safety checks.

This means:

Expected behavior

Add a built-in pre-flight validation layer to the tool.execute.before hook that checks all tool invocations for destructive or unsafe operations before execution.

Code location

https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/session/tools.ts#L54-L69

Environment

OpenCode Desktop 1.17.8, Windows 11


About the duplicate flag: This issue covers ALL tools and proposes a centralized safety architecture in the tool.execute.before hook. #33062 (edit silently deletes symbols) is a narrower bug report about one specific missing validation in the edit tool. This issue is the meta-level design for where safety checks should live and how they should be routed. If #33062 is fixed, this issue (and the rest of the missing validations) remain.

Activity

  1. github-actions commented on Jun 20, 2026

    @github-actions
    Contributor

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

    If you believe this is a distinct issue covering the broader pre-flight validation architecture rather than any single tool, please clarify how it differs from #33062 and consider narrowing the scope to a single reproducible problem.

  2. Necmttn commented on Jun 21, 2026

    @Necmttn

    Pre-flight safety should be a verdict-producing layer, not only plugin callbacks. A built-in guard can evaluate normalized tool intents and return allow|warn|block with rule id, reason, affected paths/commands, and whether the user can override.

    Start with narrow invariants: empty Write over existing file, destructive Bash patterns, write without prior read for governed files, and workspace escape. Persist the verdict receipt so later audits can tell whether a dangerous action was blocked, warned, or never inspected.


    Generated with ax.

  3. rekram1-node commented on Jun 22, 2026

    @rekram1-node
    Contributor

    STOP SPAMMING 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