Skip to content

TaskOutput hangs after background agent completes #20236

Description

@stream727

Problem Summary

When using TaskOutput to wait for a background task completion, the main session hangs and does not respond even after the agent has completed.

Steps to Reproduce

  1. Start a background agent with Task(..., run_in_background=true)
  2. Wait for results with TaskOutput(task_id) (with block=true)
  3. Agent completes its work
  4. Main session remains stuck in "Waiting for task" / "Booping…" state
  5. More than 5 minutes pass without detecting completion
  6. Manually cancel with Esc key, then the completed task's results are displayed

Expected Behavior

  • TaskOutput should immediately return results when the agent completes
  • Completion detection should work correctly

Actual Behavior

  • TaskOutput continues to block after agent completion
  • Session hangs in "Booping…" state for several minutes
  • Results are only retrievable via manual cancellation (Esc)

Environment

  • Claude Code version: 2.1.17
  • Platform: Linux (WSL2)
  • OS: Linux 6.6.87.2-microsoft-standard-WSL2

Additional Context

This issue significantly impacts workflows that rely on background agent orchestration. The workaround of manually canceling and re-requesting results is disruptive to automated pipelines.

Possible Root Cause

The completion polling/notification mechanism may not be correctly detecting when the background task state changes from "running" to "completed".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions