Skip to content

FLEET: session.idle fires before all sub-agents complete — fleet completion is non-deterministic #2263

@darthmolen

Description

@darthmolen

Summary

session.idle fires when the orchestrating session has no pending work queued, but sub-agents may still be running. In testing with 4 sub-agents, only 2 subagent.completed events arrived before session.idle. The other 2 never produced completion events. There is no reliable way to know when all fleet work is done.

Steps to Reproduce

const session = await client.createSession({
    onPermissionRequest: async () => ({ approved: true }),
});

const started = [], completed = [];

session.on('subagent.started', (d) => started.push(d.toolCallId));
session.on('subagent.completed', (d) => completed.push(d.toolCallId));

session.on('session.idle', () => {
    console.log(`started=${started.length}, completed=${completed.length}`);
    // → "started=4, completed=2"  ← 2 sub-agents never signalled done
});

await session.rpc.fleet.start({ prompt: 'Do 4 parallel tasks on A, B, C, D' });

Observed Behaviour

Spike data from session ba5281cc-5df6-48d8-861d-806f9a51e0e7 (2026-03-17):

{
  "subagentsStarted": [
    { "toolCallId": "tooluse_4Vim3gCZxGXWqGqX832PIO", "elapsedMs": 47837 },
    { "toolCallId": "tooluse_QF8x4XKh69tWubnLV1Q9PK", "elapsedMs": 47837 },
    { "toolCallId": "tooluse_Cg1Vhzlg2tLvFgr6yAzLDg", "elapsedMs": 47838 },
    { "toolCallId": "tooluse_rTPWcjyPoZKMHpjiglj9Bi", "elapsedMs": 47838 }
  ],
  "subagentsCompleted": [
    { "toolCallId": "tooluse_QF8x4XKh69tWubnLV1Q9PK", "elapsedMs": 138770 },
    { "toolCallId": "tooluse_4Vim3gCZxGXWqGqX832PIO", "elapsedMs": 170059 }
  ],
  "sessionIdleAt": 175813
}

4 started, 2 completed — session.idle fired at 175s. The other 2 tool call IDs appear in tool.execution_start/complete events but no subagent.completed arrived.

Expected Behaviour

One of:

  1. session.idle must not fire until all fleet sub-agents have emitted subagent.completed or subagent.failed
  2. A fleet.complete event fires when all sub-agents finish, independent of session.idle
  3. Documentation clarifies session.idle ≠ fleet completion with the correct waiting pattern

Impact

Callers relying on session.idle to know fleet is done will get false positives. Results from in-flight sub-agents may be silently dropped.

Related

See also: FLEET-2 (session.task_complete never fires), FLEET-4 (no fleet.* lifecycle events)

Environment

  • SDK: @github/copilot-sdk v0.1.32
  • CLI: latest
  • Node: v24.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions