Skip to content

fix(opencode): align batch tool execution with active turn filtering#21366

Open
GuestAUser wants to merge 3 commits intoanomalyco:devfrom
GuestAUser:fix/batch-tool-filtering
Open

fix(opencode): align batch tool execution with active turn filtering#21366
GuestAUser wants to merge 3 commits intoanomalyco:devfrom
GuestAUser:fix/batch-tool-filtering

Conversation

@GuestAUser
Copy link
Copy Markdown

@GuestAUser GuestAUser commented Apr 7, 2026

Issue for this PR

Closes #21367

Type of change

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

What does this PR do?

batch was resolving tools independently from the turn tool set, so it could miss model-gated tools like apply_patch and drift from the tools actually exposed to the model.

This change:

  • reuses LLM.filterTools() as the shared turn filter
  • threads the filtered tool IDs through SessionPrompt via extra.allow
  • resolves ToolRegistry.tools(...) in batch with the active { providerID, modelID }
  • rejects batched subcalls that were not enabled in the active turn

This keeps external / MCP tools out of batch and makes batched execution match normal tool execution.

How did you verify your code works?

  • cd packages/opencode
  • bun test test/tool/batch.test.ts test/tool/apply_patch.test.ts
  • bun typecheck
  • added regression coverage for:
    • batch -> apply_patch under a GPT-5-style patch turn
    • rejecting apply_patch when the turn allowlist excludes it

Screenshots / recordings

N/A — non-UI change.

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

batch can drift from active turn tool filtering

1 participant