github / github/copilot-cli

Subagent streaming deltas (assistant.message_delta) not emitted to SDK consumers

未关闭
#2,645 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:agents area:non-interactive
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### 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

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, shell
领域
api, cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。