[Bug] Scoped skill-bundle tools are offered to the main conversation although they are hidden from the tool list
Description
Bundle tools default to tools_visibility: scoped: they should be visible only to the bundle's own subagent. getAllTools() hides them, but getAvailableToolNames() (the list that decides which tools may run) still includes them, and the handler can be looked up. The main conversation can run one if the model names it.
Environment
- OS: Windows 11 Home 10.0.26300
- Node version: v22.22.3
- Nanocoder version: 1.32.0 (built from main at 5df35b3a)
- Provider: Not provider-specific
- Model: Not model-specific
Steps to Reproduce
- Create
const tm = new ToolManager(). - Register a scoped tool:
tm.registerSkillTool({name: 'secret_tool', tool: {description: 'x'}, handler: async () => 'RAN', approval: false, readOnly: true, ownerSkill: 'k8s', scoped: true}). - Check
tm.getAvailableToolNames(undefined, 'normal', []).includes('secret_tool'),'secret_tool' in tm.getAllTools()and!!tm.getToolHandler('secret_tool').
Expected Behavior
The tool is not available to the main conversation (false).
Actual Behavior
getAvailableToolNames includes it: true
getAllTools has it: false
handler resolvable: true
The check in tool-filters.ts (hasTool) then passes.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder (main)
Suggested fix:
source/tools/tool-manager.ts:455(getAvailableToolNames): drop scoped entries unless the caller is the owning skill's subagent (entry.scopedis already checked at line 571).- Check
source/hooks/chat-handler/utils/tool-filters.ts:90andsource/skills/registrar.ts:123. - Add a test that a scoped tool is not in the main-agent list and still works for its subagent.
I'm picking this up. Plan: drop scoped entries from getAvailableToolNames() unless the caller is the owning skill's subagent, check the other two call sites you listed, and add a test that a scoped tool is unavailable to the main conversation and still runs for its subagent.