[PR #7165] refactor: simplify task tool subagent filtering #12282

Closed
opened 2026-02-16 18:17:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7165

State: closed
Merged: Yes


Summary

Small cleanup to align the task tool's filtering approach with how skill.ts handles it, plus simplification of the userInvokedAgents mechanism.

Self-contained filtering:

  • Move subagent filtering into task.ts itself (using ctx?.agent from #7042)
  • Remove the post-hoc regeneration in prompt.ts

Simplify bypass logic:

  • Replace userInvokedAgents array with bypassAgentCheck boolean
  • Only check the current turn's user message (not all messages in session)
  • Prevents bypass from persisting across the entire session

Test cleanup:

  • Remove redundant filterSubagents tests (already covered by PermissionNext.evaluate tests)

Changes

  • task.ts: Filter during description generation + simplify permission check
  • prompt.ts: Remove regeneration block + use bypassAgentCheck boolean
  • test: Remove redundant tests (~130 lines)

No functional changes to permission behavior - just cleaner code!

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7165 **State:** closed **Merged:** Yes --- ## Summary Small cleanup to align the task tool's filtering approach with how skill.ts handles it, plus simplification of the `userInvokedAgents` mechanism. **Self-contained filtering:** - Move subagent filtering into `task.ts` itself (using `ctx?.agent` from #7042) - Remove the post-hoc regeneration in `prompt.ts` **Simplify bypass logic:** - Replace `userInvokedAgents` array with `bypassAgentCheck` boolean - Only check the current turn's user message (not all messages in session) - Prevents bypass from persisting across the entire session **Test cleanup:** - Remove redundant `filterSubagents` tests (already covered by `PermissionNext.evaluate` tests) ## Changes - `task.ts`: Filter during description generation + simplify permission check - `prompt.ts`: Remove regeneration block + use `bypassAgentCheck` boolean - `test`: Remove redundant tests (~130 lines) No functional changes to permission behavior - just cleaner code!
yindo added the pull-request label 2026-02-16 18:17:12 -05:00
yindo closed this issue 2026-02-16 18:17:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12282