Fix event type names for assistant messages#1223
Conversation
Fix event type names for assistant messages per https://github.com/github/copilot-sdk/blob/main/nodejs/src/generated/session-events.ts
There was a problem hiding this comment.
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.deltawithassistant.message_deltain streaming examples. - Replace
assistant.reasoning.deltawithassistant.reasoning_deltain streaming examples.
| await new Promise<void>((resolve) => { | ||
| session.on((event) => { | ||
| switch (event.type) { | ||
| case "assistant.message.delta": | ||
| case "assistant.message_delta": | ||
| // Incremental text chunk |
There was a problem hiding this comment.
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).
| 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) |
There was a problem hiding this comment.
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).
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
npm startand verified thatREADME.mdis up to date.stagedbranch 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
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.