Skip to content

Feature Request: sessions_spawn_and_wait for reliable subagent execution #19506

Description

@ultimatecomputer

Feature Request: Reliable Subagent Spawn with Built-in Polling

Use Case

When spawning subagents for long-running tasks, agents need:

  • Automatic polling for completion (not manual checks)
  • Timeout handling
  • Auto-retry on stall/crash
  • Clear failure escalation

Currently, agents must manually poll sessions_history or risk losing track of subagent results.

Proposed API

Option A: Extend sessions_spawn with wait options:

{
  "tool": "sessions_spawn",
  "arguments": {
    "task": "...",
    "label": "...",
    "wait": true,              // NEW: block until complete
    "timeout": 300,            // NEW: total timeout (seconds)
    "checkInterval": 10,       // NEW: poll frequency (seconds)
    "maxRetries": 2,           // NEW: respawn on stall
    "onTimeout": "escalate"    // NEW: "escalate" | "return_partial"
  }
}

Option B: New tool sessions_spawn_and_wait with same arguments (mandatory wait).

Implementation Notes

  • Gateway already tracks subagent sessions
  • Internal polling loop won't expose complexity to agents
  • Backward compatible (wait=false or new tool)
  • Returns final result or structured error with logs

Benefits

  • Reliability becomes default, not optional
  • Eliminates "did my subagent finish?" uncertainty
  • Handles respawn logic consistently
  • Matches "DO BEFORE ASK" agent philosophy

Related

Pattern documented in agent workspaces using helper scripts, but native support would be cleaner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions