Skip to content

Subagent abort shows spurious Unknown tool search warning and conflates user abort with failure #211

@aebrer

Description

@aebrer

Summary

When background subagents are manually aborted with ESC, two related UX problems appear:

  1. A spurious Warning: Unknown tool search surfaces in the subagent output
  2. The TUI output mixes the "cancelled by user" message with stderr error noise, making it hard to tell whether the agent was killed by the user or crashed on its own

Current Behavior

  • Built-in agents like Explore and feature-dev specify search in their tools: YAML field
  • filterSubagentTools passes search through to the child process's --tools arg
  • The child process validates --tools against allTools in args.ts — but allTools does not include search (only createAllTools() / createAllToolDefinitions() add it conditionally)
  • The child prints the warning to stderr and continues
  • On normal completion the warning is hidden because exitCode === 0 and stderr is discarded
  • On user abort (SIGTERMexitCode !== 0) the parent includes stderr in errorMessage, so the warning suddenly becomes visible
  • _handleBackgroundComplete prepends "This agent was cancelled by the user." but also appends the error message, producing confusing output like:
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

Proposed Behavior

  1. search is recognized as a valid tool name in CLI argument validation so the spurious warning never appears
  2. When a subagent is cancelled by the user, the output clearly says so and does not mix in stderr noise from the SIGTERM kill

Acceptance Criteria

  • allTools and allToolDefinitions include search (via pre-instantiated exports from search.ts, matching the pattern used by read.ts, bash.ts, etc.)
  • Passing --tools search to a dreb process does not produce a warning
  • When cancelled === true in _handleBackgroundComplete, the output makes the user-abort status unambiguous and suppresses or clearly demotes the SIGTERM-derived error noise
  • Subagents that fail on their own (not user-aborted) still show their error output as before

Technical Notes

  • search.ts lacks the pre-instantiated searchTool / searchToolDefinition exports that other tools have (read.ts:268-269)
  • allTools is a static export used for CLI validation; createAllTools() dynamically adds search but that path is not hit during args.ts parsing
  • SUBAGENT_DEFAULT_TOOLS intentionally excludes search for agents that don't explicitly request it; this is fine — the bug is only that explicitly-requested search triggers a validation warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions