opencode
opencode copied to clipboard
fix: exclude tools field from agent config spread
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