github / github/app

Background task completion notification is emitted while sub-agent is still running

Open
#330 0 comments 0 reactions 0 assignees View on GitHub
Bugs
Dominant language
No language data
Stars
2.1k
Forks
153
PR merge metrics
No merged PRs in 30d

Description

### Short summary

Main orchestration agents may receive Background task ... has completed notifications before the associated sub-agent has actually finished execution.

### Affected version or release

v0.2.7

### Installation context

Installed at organization scope. Issue observed in a private repository while using GitHub Copilot coding agent background task orchestration.

### What happened?

I have a main orchestration prompt that distributes work across multiple sub-agents.

The main agent:
- generates batches of work
- starts sub-agents to process those batches
- limits concurrent execution to 10 sub-agents
- monitors completion notifications to launch the next queued batches

The issue is that the main agent receives completion notifications such as:

```text
Background task 'taskname' (agent_id: agentname) has completed
```

Followed by:
```text
The agent is still running ar 122s with 14 tool calls completed. Let me think about what's happening...
```

Because of this false completion signal, the orchestrator assumes capacity has been freed and starts additional sub-agents prematurely.

As a result, the system eventually exceeds what appears to be the actual supported concurrent sub-agent limit (possibly 16), causing orchestration instability and inconsistent execution behavior.

```text
Write agent
Arguments
{...}
Cannot resume agent - all 16 concurrent agent slots are in use. Try again after an active agent completes.
```

### Steps to reproduce

1. Create a main orchestration prompt that processes work in batches.
2. Configure the orchestrator to:
- maintain a concurrency limit (example: 10)
- launch additional sub-agents when previous ones complete
3. Start enough batches to keep the queue active.
4. Observe that:
- completion notifications are emitted before sub-agents are actually finished
- the orchestrator launches additional sub-agents too early
- the total number of running sub-agents eventually exceeds the intended concurrency limit

### Expected behavior

A background task completion notification should only be emitted once the associated sub-agent execution has actually completed.

Alternatively, the API/event model should clearly distinguish between:
- parent task completion
- sub-agent lifecycle completion
- orchestration-level completion

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.