Skip to content

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

Closed

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

Activity

  1. added
    area:sessionsSession management, resume, history, session picker, and session state
    on Apr 6, 2026
  2. added
    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agents
    on Apr 6, 2026
  3. examon commented on Apr 7, 2026

    @examon

    This should be resolved as of v1.0.20. session.idle now waits until all background agents and shell commands have finished before firing, so it should serve as a reliable signal that fleet work is done. If you still see this after updating, please feel free to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:sessionsSession management, resume, history, session picker, and session state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions