fix(copilot-sdk-nodejs): correct assistant message delta event name (#1712)

The accessibility-report recipe and its companion doc used "assistant.message.delta" (dotted), which never matches the SDK event. The canonical name is "assistant.message_delta" (underscore), as documented in instructions/copilot-sdk-nodejs.instructions.md and used by the Python cookbook. Without this fix the streaming branch was dead and no incremental output was printed.


(cherry picked from commit e050d7bfc96c55924b0bf534c8b3e57359463ba9)

Signed-off-by: syalioune <sy_alioune@yahoo.fr>
This commit is contained in:
syalioune
2026-05-15 03:17:38 +02:00
committed by GitHub
parent ede8b1f59e
commit ee3e386c9c
2 changed files with 10 additions and 10 deletions
@@ -90,7 +90,7 @@ async function main() {
let idleResolve: (() => void) | null = null;
session.on((event) => {
if (event.type === "assistant.message.delta") {
if (event.type === "assistant.message_delta") {
process.stdout.write(event.data.deltaContent ?? "");
} else if (event.type === "session.idle") {
idleResolve?.();
@@ -179,7 +179,7 @@ main().catch(console.error);
## How it works
1. **Playwright MCP server**: Configures a local MCP server running `@playwright/mcp` to provide browser automation tools
2. **Streaming output**: Uses `streaming: true` and `assistant.message.delta` events for real-time token-by-token output
2. **Streaming output**: Uses `streaming: true` and `assistant.message_delta` events for real-time token-by-token output
3. **Accessibility snapshot**: Playwright's `browser_snapshot` tool captures the full accessibility tree of the page
4. **Structured report**: The prompt engineers a consistent WCAG-aligned report format with emoji severity indicators
5. **Test generation**: Optionally detects the project language and generates Playwright accessibility tests
@@ -212,7 +212,7 @@ Unlike `sendAndWait`, this recipe uses streaming for real-time output:
```typescript
session.on((event) => {
if (event.type === "assistant.message.delta") {
if (event.type === "assistant.message_delta") {
process.stdout.write(event.data.deltaContent ?? "");
} else if (event.type === "session.idle") {
idleResolve?.();
@@ -55,7 +55,7 @@ async function main() {
let idleResolve: (() => void) | null = null;
session.on((event) => {
if (event.type === "assistant.message.delta") {
if (event.type === "assistant.message_delta") {
process.stdout.write(event.data.deltaContent ?? "");
} else if (event.type === "session.idle") {
idleResolve?.();