When background subagents are manually aborted with ESC, two related UX problems appear:
This agent was cancelled by the user.
Error: Warning: Unknown tool search. Valid tools: read, bash, edit, write, grep, find, ls, web_search, web_fetch, subagent, tmp_read, wait
Summary
When background subagents are manually aborted with ESC, two related UX problems appear:
Warning: Unknown tool searchsurfaces in the subagent outputCurrent Behavior
Exploreandfeature-devspecifysearchin theirtools:YAML fieldfilterSubagentToolspassessearchthrough to the child process's--toolsarg--toolsagainstallToolsinargs.ts— butallToolsdoes not includesearch(onlycreateAllTools()/createAllToolDefinitions()add it conditionally)exitCode === 0and stderr is discardedSIGTERM→exitCode !== 0) the parent includes stderr inerrorMessage, so the warning suddenly becomes visible_handleBackgroundCompleteprepends "This agent was cancelled by the user." but also appends the error message, producing confusing output like:Proposed Behavior
searchis recognized as a valid tool name in CLI argument validation so the spurious warning never appearsAcceptance Criteria
allToolsandallToolDefinitionsincludesearch(via pre-instantiated exports fromsearch.ts, matching the pattern used byread.ts,bash.ts, etc.)--tools searchto a dreb process does not produce a warningcancelled === truein_handleBackgroundComplete, the output makes the user-abort status unambiguous and suppresses or clearly demotes the SIGTERM-derived error noiseTechnical Notes
search.tslacks the pre-instantiatedsearchTool/searchToolDefinitionexports that other tools have (read.ts:268-269)allToolsis a static export used for CLI validation;createAllTools()dynamically addssearchbut that path is not hit duringargs.tsparsingSUBAGENT_DEFAULT_TOOLSintentionally excludessearchfor agents that don't explicitly request it; this is fine — the bug is only that explicitly-requestedsearchtriggers a validation warning