Skip to content

feat(opencode): add isReadOnly and isDestructive flags to tool interface#20297

Open
AndresCdo wants to merge 3 commits intoanomalyco:devfrom
AndresCdo:feat/tool-safety-metadata
Open

feat(opencode): add isReadOnly and isDestructive flags to tool interface#20297
AndresCdo wants to merge 3 commits intoanomalyco:devfrom
AndresCdo:feat/tool-safety-metadata

Conversation

@AndresCdo
Copy link
Copy Markdown

Issue for this PR

Closes #20296

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds optional isReadOnly and isDestructive metadata flags to the Tool.Def interface. These flags enable the permission system, auto-approval classifiers, and UI to make smarter decisions about tool behavior without analyzing tool internals at runtime.

Annotated 11 built-in tools:

Tool Flag Rationale
read isReadOnly: true Only reads file contents
glob isReadOnly: true Only matches file patterns
grep isReadOnly: true Only searches file contents
list isReadOnly: true Only lists directory contents
webfetch isReadOnly: true Only fetches URL content
codesearch isReadOnly: true Only queries external API
write isDestructive: true Creates/overwrites files
edit isDestructive: true Modifies file contents
apply_patch isDestructive: true Applies patches to files
multiedit isDestructive: true Multiple file modifications
todowrite isReadOnly: false Modifies session state

Tools not annotated: bash (dynamic — can be read-only or destructive depending on command), task, websearch, skill, lsp, plan_exit, plan_enter, question, invalid, batch — these have complex or context-dependent behavior.

How did you verify your code works?

  • bun typecheck passes (zero errors in changed files)
  • Changes are purely additive: optional fields with no behavioral change
  • 12 files changed, +15 lines total
  • No API changes, no breaking changes

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

AndresCdo and others added 3 commits March 31, 2026 11:03
Add optional isReadOnly and isDestructive metadata to Tool.Def
interface. Applied to 11 built-in tools:

Read-only: read, glob, grep, list, webfetch, codesearch
Destructive: write, edit, apply_patch, multiedit
Neutral: todowrite (isReadOnly: false)

These flags enable permission systems and auto-approval classifiers
to make smarter decisions without analyzing tool behavior at runtime.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add isReadOnly and isDestructive flags to tool interface

1 participant