[PR #7237] fix: exclude tools field from agent config spread #12313

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

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

State: closed
Merged: No


Summary

Fixes subagent permission bug where tools field was spread into resolved agent config, causing permission blocks to be ignored for tool availability.

Root Cause

In packages/opencode/src/config/config.ts around line 529, the Agent schema transform spreads the entire agent object:

return { ...agent, options, permission, steps }

This preserves the tools field alongside the new permission field, causing tools to override permission-based tool availability.

The Fix

Destructure to exclude tools before spreading:

const { tools, maxSteps, ...rest } = agent
return { ...rest, options, permission, steps }

Testing

  • Built OpenCode from source with this fix
  • Verified with opencode debug agent <name>:
    • System v1.0.220: tools field PRESENT (broken)
    • Fixed build: tools field ABSENT (working)
  • Subagent permission blocks now properly control tool availability

Fixes #6527
Related to #6873

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7237 **State:** closed **Merged:** No --- ## Summary Fixes subagent permission bug where tools field was spread into resolved agent config, causing permission blocks to be ignored for tool availability. ## Root Cause In packages/opencode/src/config/config.ts around line 529, the Agent schema transform spreads the entire agent object: ```typescript return { ...agent, options, permission, steps } ``` This preserves the tools field alongside the new permission field, causing tools to override permission-based tool availability. ## The Fix Destructure to exclude tools before spreading: ```typescript const { tools, maxSteps, ...rest } = agent return { ...rest, options, permission, steps } ``` ## Testing - Built OpenCode from source with this fix - Verified with `opencode debug agent <name>`: - System v1.0.220: tools field PRESENT (broken) - Fixed build: tools field ABSENT (working) - Subagent permission blocks now properly control tool availability Fixes #6527 Related to #6873
yindo added the pull-request label 2026-02-16 18:17:14 -05:00
yindo closed this issue 2026-02-16 18:17:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12313