[Bug 7.4.17] Task subagents retry overloads, then abort and leave an orphaned tool
Description
On Kilo Code 7.4.17, foreground Task subagents can spend several minutes retrying server_is_overloaded, then all active children are cancelled and the parent receives only Tool execution aborted. A model-initiated retry creates duplicate child sessions and fails again. The parent loop can then exit with an orphaned interrupted Task tool.
The incident is especially confusing when provider.openai.options.chunkTimeout is configured, because the cancellation boundary strongly matches that timeout while the parent is waiting for local Task tools.
Environment
- Kilo Code:
7.4.17 - Surface: VS Code extension on Windows 11
- Parent and child model:
openai/gpt-5.6-sol-pro - Child agent: built-in
exploresubagent - Runtime: AI SDK
- Relevant provider options:
{
"timeout": 300000,
"chunkTimeout": 180000
}Reproduction timeline
The parent launched two Task subagents in parallel.
First batch:
09:17:15Z: two child sessions were created.- Their provider calls repeatedly returned
service_unavailable_error/server_is_overloadedand oneProviderHeaderTimeoutError. - The children kept retrying and one child reached a second agent step.
09:18:11Z: the last concurrently running non-Task tool in the parent completed.09:21:11Z: both child sessions were cancelled, approximately 180 seconds after that last parent tool event.09:21:13Z: both parent Task calls changed toerror: Tool execution abortedafter 238.1 seconds total.- One child ended as
MessageAbortedError; the other retained an unfinished assistant message.
The parent model then retried the same two investigations by creating two new child sessions.
Second batch:
09:22:31Z: two replacement child sessions were created.- They again received repeated
server_is_overloadedresponses but also performed real work and tool calls. 09:25:31Z: both children were cancelled.09:25:34Z: both parent Task calls changed toerror: Tool execution abortedafter 182.7/182.8 seconds.- The parent log then reported:
loop exit with orphaned interrupted tool ... tool=taskThe configured chunkTimeout was 180,000 ms. The second failure aligns almost exactly with it. The first failure also aligns with 180 seconds after the last other parallel tool completed. This suggests that the provider stream idle timer may continue running while the parent is legitimately waiting for Task children.
The upstream overload is a valid trigger, but it should not produce an opaque/orphaned lifecycle state.
Actual behavior
- Transient
server_is_overloadedresponses are retried repeatedly for several minutes with no useful status in the parent UI. - Active child work is cancelled at the parent timeout boundary.
- The Task result loses the underlying cause and only says
Tool execution aborted. - No resumable
task_idis returned on this error path. - Retrying creates new duplicate child sessions instead of resuming the existing children.
- The parent can exit with
orphaned interrupted tool.
Expected behavior
- Provider
chunkTimeoutshould measure silence from the provider transport, not time spent executing or awaiting a local Task tool. - Task/subagent lifecycle timeout should be separate and configurable.
- Transient provider errors should have a bounded retry policy, preferably one automatic retry by default or a configurable count.
- The UI should show a localized, actionable terminal message with elapsed time, phase, retry count, and root cause. For example:
Subagent was cancelled after 3 minutes while the parent was waiting.
Last upstream error: server_is_overloaded. Automatic retry 1/1 exhausted.
Child session: <task_id>; it can be resumed.- The Task error path should always return the existing child
task_id, partial result/transcript location, and terminal state so the parent can retry exactly once by resuming the same child. - Cancelling children must settle every parent Task call cleanly; the parent loop must not retain an orphaned interrupted tool.
Related issues
- #12483: provider stream idle timeout and
chunkTimeoutworkaround. - #11708: Task subagent blocks the parent and has no independent cancellation/lifecycle timeout.
- #11745: subagent timeout can be ignored.
- #12493: control, stop, prompt, and resume Task subagents.
- #9792: retryable provider failures were not handled cleanly; closed as stale.
Privacy-safe evidence available
I have the exact parent/child session IDs, message IDs, Task call IDs, database rows, and opencode.log timeline. I can provide a sanitized log bundle if maintainers specify the preferred attachment format.
Source: Kilo-Org/kilocode