Skip to content

Background agents cannot be killed and run indefinitely, burning tokens #37218

Description

@mably

What' + chr(39) + 's Wrong?

Background agents launched via the Agent tool with run_in_background: true cannot be stopped once launched. There is no kill mechanism. Agents that get stuck in loops or fail to make progress continue running for hours, consuming tokens with zero useful output.

What Should Happen?

There should be a way to kill background agents — either via a /kill command, a TaskStop tool, or automatic timeout after a configurable period.

Steps to Reproduce

  1. Launch a background agent with a complex task
  2. Agent gets stuck (e.g. repeatedly reading API logs, failing to push code)
  3. Agent output grows to 1MB+ over hours
  4. No way to stop it — it runs until hitting the context limit

Impact

In our case, 4 zombie agents ran for 4+ hours, producing 1.2MB of output each with zero useful results. This is significant token waste on a Max subscription.

Suggested Fix

  • Add a TaskStop tool or /kill <agent_id> command
  • Add configurable timeout for background agents (default 30 minutes?)
  • Auto-kill agents that have not produced a tool call in >5 minutes

Environment

  • Claude Code version: 2.1.81
  • Model: claude-opus-4-6
  • OS: macOS Darwin 24.6.0
  • Terminal: iTerm2

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