Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions instructions/copilot-sdk-nodejs.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ Handle both delta events (incremental) and final events:
await new Promise<void>((resolve) => {
session.on((event) => {
switch (event.type) {
case "assistant.message.delta":
case "assistant.message_delta":
// Incremental text chunk
Comment on lines 206 to 210
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this example the handler registered via session.on(...) is never unsubscribed, so if the session keeps emitting events (or this pattern is repeated) it can lead to duplicate output and a leaked listener. Since this doc later shows const unsubscribe = session.on(...), consider capturing and calling unsubscribe() when you resolve on session.idle (or in a finally).

Copilot uses AI. Check for mistakes.
process.stdout.write(event.data.deltaContent);
break;
case "assistant.reasoning.delta":
case "assistant.reasoning_delta":
// Incremental reasoning chunk (model-dependent)
Comment on lines +209 to 214
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR updates Node.js docs to use assistant.message_delta / assistant.reasoning_delta, but there are still Node.js cookbook examples in this repo using the older dotted names (e.g., cookbook/copilot-sdk/nodejs/accessibility-report.md and cookbook/copilot-sdk/nodejs/recipe/accessibility-report.ts use assistant.message.delta). To avoid conflicting guidance, please update those examples (or clarify if both spellings are supported).

Copilot uses AI. Check for mistakes.
process.stdout.write(event.data.deltaContent);
break;
Expand Down Expand Up @@ -665,7 +665,7 @@ const session = await client.createSession({
let currentMessage = "";

const unsubscribe = session.on((event) => {
if (event.type === "assistant.message.delta") {
if (event.type === "assistant.message_delta") {
currentMessage += event.data.deltaContent;
process.stdout.write(event.data.deltaContent);
} else if (event.type === "assistant.message") {
Expand Down
Loading