opencode icon indicating copy to clipboard operation
opencode copied to clipboard

refactor: simplify task tool subagent filtering

Open malhashemi opened this issue 1 week ago • 3 comments

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!

malhashemi avatar Jan 07 '26 04:01 malhashemi