Subagent streaming deltas (assistant.message_delta) not emitted to SDK consumers
- Linguagem predominante
- Shell
- Estrelas
- 11.2k
- Forks
- 1.9k
- Merge médio
- 14h 16min
- PRs com merge (30d)
- 6
Descrição
### Describe the bug
When subagents runs in parallel via the `task` tool, the SDK consumer does not receive any `assistant.message_delta` events from the subagents. Only after each subagent fully completes does a single `assistant.message` event arrive. During running, subagents' streaming output is invisible to the SDK.
I think there's already an issue reporting this, but it is closed few days ago: #2265 . However I can still repro this in the latest version of Copilot SDK (0.2.2) and CLI (1.0.24).
This makes it hard for cases like tracking each subagent's output.
### Affected version
GitHub Copilot CLI 1.0.24.
### Steps to reproduce the behavior
```
import { CopilotClient, approveAll } from '@github/copilot-sdk';
const client = new CopilotClient();
await client.start()
const session = await client.createSession({
model: "gpt-4.1",
streaming: true,
onPermissionRequest: approveAll
});
const withParent = [];
const withoutParent = [];
const fullWithParent = [];
const fullWithoutParent = [];
const fullDelta = [];
const fullMessage = [];
session.on("assistant.message_delta", (e) => { (e.data.parentToolCallId ? withParent : withoutParent).push(e) });
session.on("assistant.message_delta", (e) => { fullDelta.push(e) });
session.on("assistant.message", (e) => { (e.data.parentToolCallId ? fullWithParent : fullWithoutParent).push(e) });
session.on("assistant.message", (e) => { fullMessage.push(e) });
await session.sendAndWait({ prompt: 'Launch exactly 2 subagents in parallel via the task tool, and let each of them give a 300 words self-introduction.' }, 300000);
console.log(`Delta events with parentToolCallId: ${withParent.length}`);
console.log(`Delta events without parentToolCallId: ${withoutParent.length}`);
console.log(`Full events with parentToolCallId: ${fullWithParent.length}`);
console.log(`Full events without parentToolCallId: ${fullWithParent.length}`);
console.log('\nAll delta messages:');
fullDelta.forEach((m) => { console.log(JSON.stringify(m, null, 2)); });
console.log('\nAll messages:');
fullMessage.forEach((m) => { console.log(JSON.stringify(m, null, 2)); });
await session.disconnect();
await client.stop();
```
### Expected behavior
`Delta events with parentToolCallId` should > 0 and there should be events from subagents.
### Additional context
https://docs.github.com/en/copilot/how-tos/copilot-sdk/use-copilot-sdk/streaming-events#assistantmessage_delta
Guia de contribuição
Direção de pesquisa
Start with the Copilot SDK session streaming path used by the task tool and the assistant.message_delta listener shown in the reproduction. Run the JavaScript example with CLI 1.0.24 and SDK 0.2.2, then compare parentToolCallId events from subagents with assistant.message events. Done means parallel subagents emit assistant.message_delta events while running.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, shell
- Domínio
- api, cli
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 48/100