Skip to content

[Bug]: Background tasks and subagents never proactively notify upon completion (requires manual polling), and finished processes remain orphaned in UI #977

Description

@abaidalgarni

Antigravity CLI Version

1.1.27

Environment Context

  • OS: Windows 11 Enterprise 64-bit (Version 10.0.22000, Build 22000.3260)
  • Shell: PowerShell 7.6.5 / Windows PowerShell 5.1 (pwsh)
  • Terminal Emulator: Windows Terminal / ConHost
  • Runtime Version: agy prebuilt binary 1.1.27
  • Hardware Details: Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz, 8 GB RAM

Describe the Bug

There are two major, interconnected failure modes with background terminal tasks (run_command async tasks) and subagents (invoke_subagent):

1. Silent Completion (Never notifies the user without manual polling)

  • This occurs not just on multi-hour tasks, but even on routine, short background tasks (e.g., downloads, builds, subagent queries).
  • When a background command is launched, the agent tells the user it is waiting and ends its turn.
  • When the task completes in the background, the CLI never proactively notifies the user or resumes the conversation.
  • The session sits completely silent and idle indefinitely.
  • The user is forced to manually intervene and prompt the agent (e.g. typing "check progress", "status", or "is it done?"). Only after the user's manual message does the agent query the task status and report that the task finished.

2. Ghost/Zombie Background Processes & UI Desync

  • In other instances, even after a task has completed and the agent reports it as finished, the background task indicator / process tracker in the UI continues to display the task as actively "running".
  • The underlying subprocess or subagent worker is never cleanly reaped, closed, or deregistered, leaving orphaned background processes active on the system and cluttering the active task list.

Steps to Reproduce

  1. Launch an interactive session: agy
  2. Run any command or subagent that executes asynchronously in the background (e.g., package installation, build step, or parallel subagents).
  3. Wait for the background process to finish.
  4. Observe:
    • The CLI remains completely silent. It does not display the completion output or notify the user that work has concluded.
    • Type "check progress". Only then does the agent inspect the task log and inform the user of the result.
    • Check the background task manager / UI indicator: often the task is still listed as RUNNING or the process handle was never cleanly closed.

Expected Behavior

  1. Proactive Reactive Wakeup: Once a background terminal command or subagent exits/finishes, the task supervisor should immediately trigger the reactive wakeup, causing the agent to wake up and proactively post an update to the user (e.g., "Task completed with exit code 0...") without requiring the user to manually poll.
  2. Clean Process Reaping: When a task completes, its OS process handles must be closed, resources freed, and its status in the task tracker transitioned to DONE / purged from active background processes.

Root Cause Analysis

  1. Broken Event Dispatch between Task Supervisor and Agent Loop:
    The supervisor detects process termination and writes output to the task log, but the reactive wakeup event either fails to break the waiting turn or is treated purely as an internal state update without prompting the model to generate a user-facing completion message.
  2. Missing Process Handle Cleanup (Windows):
    On Windows, child processes spawned via PTY/command runners that don't explicitly close stdin/stdout/stderr pipes or child job objects remain in a zombie state, preventing the UI process counter from clearing.
  3. Turn-Based Deadlock:
    The agent architecture expects "Reactive Wakeup (No Polling Needed)", but in practice, the user is forced into manual polling loops because the completion event fails to synthesize a user-visible response turn.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions