Skip to content

Feature request: Escalating stall recovery for sub-agents (nudge → kill) #39305

Description

@emcc24444

Problem

Sub-agents can stall indefinitely while remaining in "running" status. Today the only automated protection is runTimeoutSeconds (wall-clock cap), which can't distinguish active work from a stalled agent. Manual detection requires checking sessions_history timestamps — unreliable since LLMs have no internal timers and can't self-trigger checks.

Proposed solution

A two-stage stall recovery system that monitors time since last tool call per sub-agent:

Stage 1 — Nudge (stallNudgeSeconds): After N seconds of no tool calls, inject a system message ("You appear stalled — resume your task or report what's blocking you"). Cheap, might recover agents that are confused or lost.

Stage 2 — Kill (stallTimeoutSeconds): If no tool call within M seconds after the nudge, auto-kill the agent and notify the parent session. Backstop for cases where nudging can't help (dead-on-arrival, context exhaustion, hung tool calls).

Config:

{
  "agents": {
    "defaults": {
      "subagents": {
        "stallNudgeSeconds": 90,
        "stallTimeoutSeconds": 180
      }
    }
  }
}

Also available as per-spawn overrides on sessions_spawn.

Why both stages?

  • Nudge alone is optimistic — many stalls aren't recoverable (agent never started, context full, platform-level issue)
  • Kill alone is wasteful — some agents just need a tap on the shoulder
  • Escalating intervention: cheapest recovery first, then hard cutoff

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.impact:ux-release-blockerA non-technical user is blocked without terminal, logs, config, or support.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions