fix(core): skip the session_move hint when execute is denied by Yun-0000 · Pull Request #57809 · anomalyco/opencode · GitHub
Skip to content

fix(core): skip the session_move hint when execute is denied - #57809

Open
Yun-0000 wants to merge 1 commit into
anomalyco:devfrom
Yun-0000:denied-execute-hint
Open

Yun-0000 wants to merge 1 commit into
anomalyco:devfrom
Yun-0000:denied-execute-hint

Conversation

@Yun-0000

@Yun-0000 Yun-0000 commented Oct 21, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #57711

Type of change

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

What does this PR do?

A deny-all execute rule removes the execute tool, but opencode.tools still tells the model to call tools.opencode.session_move through it. The same hint is added on compaction and generate.

The hint is skipped when the request does not offer execute. A narrower deny still offers the tool, so the hint stays.

How did you verify your code works?

Bun 1.4.2.

Before: allow * plus deny execute * left execute out of the snapshot, and primary, compaction, and generate still included the hint.

After: those three requests omit the hint. Allow-all, and a deny limited to resource secret, still offer execute and keep the hint.

Passed, from packages/core:

  • bun run test test/tool-opencode.test.ts: 3 pass
  • bun typecheck: pass

Passed on push: bun run check (oxlint, ast-grep, sdk docs, turbo typecheck 34/34).

Passed on this head: check-compliance, check-standards, add-contributor-label. test, typecheck, and nix-eval are not in the check list and did not fail. Combined status is pending with 0 statuses. The issue's opencode-drive script and the full packages/core suite were not run.

Screenshots / recordings

Not a UI change.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #57720, #56038

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix works. With the #57711 reproduction (allow *, deny execute, simulated model), the main request on the base leaves out execute but still carries the tools.opencode.session_move hint. With this change the hint is gone. bun run test test/tool-opencode.test.ts and bun typecheck pass in packages/core.

The guard reads the request's tools keyed by name, the same way other built-in plugins do (patch, websearch, shell). So it covers the primary, compaction and generate requests, and a narrower execute deny still keeps the hint.

Public API: unchanged.

The new test is heavier than this two-line fix needs (see inline).

Related: #57720, #56038

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is large for a two-line guard. It builds SessionModelRequest with a stub transport, a resolved OpenAI model and three permission rulesets just to check that one system part is or isn't there. It can be dropped to keep the change minimal. If you'd like to keep a regression test, please cut it to a single check that the plugin's context hook adds no hint when event.tools has no execute.

This branch has not been deployed

No deployments
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.

opencode.tools adds the execute / session_move hint even when Code Mode is denied

1 participant