github / github/copilot-sdk

`subagent.started` event sometimes reports "General Purpose Agent" instead of registered `displayName` (intermittent, same code/commit)

Đang mở
#1,277 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
10.5k
Fork
1.5k
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
128

Mô tả

### Summary

When the orchestrator dispatches custom agents via `task`, the `subagent.started` event's `agentDisplayName` field sometimes correctly reports the registered `displayName` (e.g., `"Tenant Metrics"`, `"Outlier Detector"`) and sometimes reports `"General Purpose Agent"`. The behavior is non-deterministic across runs on identical code.

### Repro

```ts
const session = await client.createSession({
customAgents: [
{ name: "tenant-metrics", displayName: "Tenant Metrics", prompt: "..." },
{ name: "outlier-detector", displayName: "Outlier Detector", prompt: "..." },
/* ... 3 more named custom agents ... */
],
});

session.on("subagent.started", (evt) => console.log(evt.data.agentDisplayName));
await session.sendAndWait({ prompt: "Dispatch all five custom agents to analyze..." });
```

Observed across multiple runs of the same code, same commit, same SDK/CLI:
- Run 1: prints `"Tenant Metrics"`, `"Outlier Detector"`, etc. correctly
- Run 2: prints `"General Purpose Agent"` for all 5 agents

### Expected

`agentDisplayName` consistently matches `customAgents[].displayName` (or, when not set, falls back to `customAgents[].name`).

### Actual

Non-deterministic. The intermittency is the larger concern — it suggests state leaking across runs or initialization-order sensitivity in the CLI's agent registration path.

### Evidence (SDK source — limited)

`nodejs/src/generated/session-events.ts`: `SubagentStartedData` includes `agentDisplayName: string`. The SDK never populates this field — the event arrives over RPC from the CLI. The bug is in the CLI binary, which is not source-readable.

### Consumer impact

- Dashboards and reports show `"General Purpose Agent" × N` instead of distinguishable names.
- Per-agent metrics rollups (timings, token usage, cost) keyed by `agentDisplayName` collapse to a single bucket.

### Suggested fix

- Propagate the custom agent's `displayName` (or the dispatching `task` call's `name` field) to `subagent.started` events consistently.
- **Separately:** root-cause the intermittency. Even if the display-name propagation lands, an intermittent CLI is a debugging hazard.

### Related

- #1110 — `agentId` missing from `SessionEvent` in .NET, Go, and Python SDKs. Adjacent: another `SessionEvent` field that's not being populated reliably across SDKs/runtimes.

### Environment

```
- SDK: @github/copilot-sdk@0.3.0 (also observed on older versions)
- CLI: @github/copilot@1.0.45 (also observed on 1.0.14+)
- Node: 22 LTS
- OS: Windows 11
- Model: claude-sonnet-4-6
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.