Skip to content

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

Open
Yun-0000 wants to merge 2 commits into
anomalyco:devfrom
Yun-0000:denied-execute-hint
Open

Yun-0000 wants to merge 2 commits 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.

The regression test fires the context hook with no execute tool.

Before: without the guard, that hook still added the hint. The test failed at toBe(false), received true.

After: the hook leaves the hint out. With execute present, the hint is still added. That case is not in the test.

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, cached on push).

Passed on this head: check-compliance, check-standards. add-contributor-label passed on the previous head and did not re-run. test, typecheck, and nix-eval are absent 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

closeAll: Effect.void,
})

it.effect("skips the session_move hint when execute is wholly denied", () =>

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cut it to one context-hook check. When event.tools has no execute, the hook adds no session_move hint.

Re-ran on Bun 1.4.2. Without the guard the test fails (false received true). With the guard, packages/core bun run test test/tool-opencode.test.ts is 3 pass and bun typecheck passes. With execute on the event, the hint is still added. I left that case out of the test.

@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 earlier test comment is addressed. The new test calls the context hook directly with no execute tool and checks that the hint is left out. I ran the #57711 reproduction again on the current base: the main request still carries the session_move hint without offering execute. With this pull request the hint is gone. bun run test test/tool-opencode.test.ts and bun typecheck pass in packages/core.

Public API: unchanged.

No further concerns.

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