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.
Feature Request: Reliable Subagent Spawn with Built-in Polling
Use Case
When spawning subagents for long-running tasks, agents need:
Currently, agents must manually poll
sessions_historyor risk losing track of subagent results.Proposed API
Option A: Extend
sessions_spawnwith 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_waitwith same arguments (mandatory wait).Implementation Notes
Benefits
Related
Pattern documented in agent workspaces using helper scripts, but native support would be cleaner.