claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

No recovery mechanism for abandoned agent tasks

Open ringger opened this issue 7 months ago • 2 comments

Issue Description

When Claude launches an agent task using the Task tool but after some time, Claude stops waiting and continues with other work, there's no way to retrieve the agent's work or final report. This creates inefficient resource usage and lost computational work.

Steps to Reproduce

  1. Claude launches an agent task using the Task tool with complex, time-consuming work (e.g., systematic codebase analysis)
  2. After some time, Claude stops waiting and continues with other work instead of waiting for completion
  3. Agent completes its work but Claude has no access to the results
  4. No tools available for Claude to retrieve agent output after the fact

Expected Behavior

Claude should be able to:

  • Check if agent tasks are still running
  • Retrieve completed agent reports (similar to how BashOutput works for bash processes)
  • Receive notifications when long-running agents complete
  • Manage agent tasks (list active tasks, retrieve results, etc.)

Current Behavior

  • No tools available to check agent status or retrieve output
  • Agent work is completely lost if Claude stops waiting for initial completion
  • No recovery mechanism available

Impact

  • Wasted computational resources when agents complete valuable work that becomes inaccessible
  • Claude may abandon legitimate long-running analysis tasks
  • Inefficient workflow where Claude duplicates agent work manually

Suggested Solutions

  1. Add TaskOutput tool to retrieve agent results by task ID (similar to BashOutput)
  2. Add TaskStatus tool to check running agent tasks and their progress
  3. Add automatic notifications when agents complete
  4. Improve Task tool documentation about waiting requirements
  5. Consider adding task persistence across Claude Code sessions

Real-World Example

During TRS-80 emulator debugging, Claude launched an agent to systematically search for non-existent method calls across the codebase. This was a legitimate use case requiring thorough analysis. After some time, Claude stopped waiting and continued with manual work, effectively abandoning the agent process. The agent likely completed valuable analysis that became inaccessible, forcing Claude to duplicate the work manually.

Environment

  • Platform: Linux (WSL2)
  • Claude Code session with Task tool and general-purpose agent type
  • Agent tasks run autonomously but lack recovery mechanisms

ringger avatar Sep 15 '25 16:09 ringger

This is a fantastic and well-detailed issue. I've run into this exact behavior as well, especially with agents tasked with deep codebase analysis or planning out a complex refactoring. It's frustrating to see Claude start a really useful, intensive task, only to abandon it and start over manually.

Your comparison to Bash with run_in_background and BashOutput is spot on. The documentation and available tools (like /bashes) show that the framework for this kind of async work already exists in Claude Code. It really feels like the Task tool for sub-agents is missing that parallel functionality. The current implementation seems to assume a synchronous, blocking call, so it's interesting that the main loop can decide to "give up" and move on.

Your suggested solutions are excellent. A TaskOutput tool modeled after BashOutput would be the perfect fix and feels like a natural extension of the existing toolset. A /tasks or /agents --running command to see active agents would also be invaluable for managing these long-running processes.

There's also a cost implication here, which is worth noting. That abandoned agent task still consumed tokens and time, so being able to retrieve the results is also a matter of efficiency and cost management.

As a temporary workaround, I've had some luck by explicitly telling Claude in the initial prompt to "wait for the agent to complete, no matter how long it takes, and do not proceed with any other actions until you receive its report," but it's not a reliable solution.

Great write-up. Hopefully, this gets some attention from the dev team. It would unlock much more powerful, long-running agentic workflows.

Cheers.

coygeek avatar Sep 15 '25 20:09 coygeek

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 05 '25 10:12 github-actions[bot]