Skip to content

Fix event type names for assistant messages#1223

Closed
moeyui1 wants to merge 1 commit intogithub:mainfrom
moeyui1:patch-1
Closed

Fix event type names for assistant messages#1223
moeyui1 wants to merge 1 commit intogithub:mainfrom
moeyui1:patch-1

Conversation

@moeyui1
Copy link
Copy Markdown
Contributor

@moeyui1 moeyui1 commented Mar 30, 2026

Fix event type names for assistant messages per https://github.com/github/copilot-sdk/blob/main/nodejs/src/generated/session-events.ts

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, or workflow file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, or workflow with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.
  • I am targeting the staged branch for this pull request.

Description

Fix the event type names for assistant messages according to the actual definition in SDK: https://github.com/github/copilot-sdk/blob/main/nodejs/src/generated/session-events.ts

Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
  • Update to existing instruction, prompt, agent, plugin, skill, or workflow.
  • Other (please specify):

Additional Notes


By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.

@moeyui1 moeyui1 requested a review from aaronpowell as a code owner March 30, 2026 07:45
Copilot AI review requested due to automatic review settings March 30, 2026 07:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Node.js Copilot SDK instructions to use the correct assistant streaming event type names, aligning the documentation with the SDK’s actual session event definitions.

Changes:

  • Replace assistant.message.delta with assistant.message_delta in streaming examples.
  • Replace assistant.reasoning.delta with assistant.reasoning_delta in streaming examples.

Comment on lines 206 to 210
await new Promise<void>((resolve) => {
session.on((event) => {
switch (event.type) {
case "assistant.message.delta":
case "assistant.message_delta":
// Incremental text chunk
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.
Comment on lines +209 to 214
case "assistant.message_delta":
// Incremental text chunk
process.stdout.write(event.data.deltaContent);
break;
case "assistant.reasoning.delta":
case "assistant.reasoning_delta":
// Incremental reasoning chunk (model-dependent)
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.
@moeyui1 moeyui1 closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants