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

貢獻指南

開啟貢獻指南

研究方向

從 task tool 使用的 Copilot SDK 工作階段串流路徑,以及重現中顯示的 assistant.message_delta listener 開始。使用 CLI 1.0.24 和 SDK 0.2.2 執行 JavaScript 範例,然後比較來自 subagents 的 parentToolCallId 事件與 assistant.message 事件。當平行 subagents 在執行期間發出 assistant.message_delta 事件時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, shell
領域
api, cli
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。