Skip to content

Copilot provider crashes on reasoning_summary_part events — "Cannot read properties of undefined (reading 'summaryParts')" #738

Description

@pbtrudel

Summary

When gpt-5.6-luna (or any GPT model routed through Copilot's Responses API, spec: "responses") is selected, requests fail mid-stream with:

Error: Cannot read properties of undefined (reading 'summaryParts')

Root cause

OpenAI's Responses API now emits response.reasoning_summary_part.added events (encrypted reasoning). The AI SDK parser (@ai-sdk/openai) tracks these via activeReasoning[item_id], keyed on each reasoning item's item_id.

GitHub Copilot has a known quirk of rotating item IDs across events for the same logical part. The provider's createCopilotStreamFixer() normalizes this id-rotation for text-* and reasoning-* events only — it does not handle reasoning_summary_part.added.

As a result, when a summary part arrives with an item_id the parser never saw a preceding reasoning output_item.added for, activeReasoning[value.item_id] is undefined, and the parser dereferences .summaryParts on it, throwing.

Where

  • Package: @byokkit/cmd-provider-copilot v0.1.1 (latest)
  • File: dist/chunk-KNVRT45Z.jscreateCopilotStreamFixer()
  • Crash origin: @ai-sdk/openai/src/responses/openai-responses-language-model.ts:2117
activeReasoningPart.summaryParts[value.summary_index] = 'active';

Expected Behavior

The stream fixer should also normalize/forward reasoning_summary_part events (or drop them) so the activeReasoning map stays consistent despite Copilot's item-id rotation.

Actual Behavior

Selecting gpt-5.6-luna under the GitHub Copilot provider section in /model and sending a request results in the stream crashing mid-response with Error: Cannot read properties of undefined (reading 'summaryParts'). The error occurs after the model begins emitting reasoning content, and no completion is returned.

Steps to reproduce the issue

  1. Connect GitHub Copilot: cmd login copilot and complete the device sign-in.
  2. Open /model and navigate to the GitHub Copilot provider section.
  3. Select a GPT model routed through the Responses API (e.g. gpt-5.6-luna).
  4. Send a prompt that triggers reasoning output (a multi-step coding or reasoning request).
  5. Observe the request fail mid-stream with Error: Cannot read properties of undefined (reading 'summaryParts').

Command Code Version

1.32.1

Operating System

Linux

Terminal/IDE

Unknown

Shell

bash

Session file (optional)

{"type":"session","version":3,"id":"ee5b89bb-41b9-4af3-9fca-3bf8c053e049","timestamp":"2026-08-24T02:20:41.576Z","cwd":"/home/pbtrudel"}
{"type":"model_change","id":"e167ed7c","parentId":null,"timestamp":"2026-08-24T02:20:56.174Z","model":"gpt-5.6-luna"}
{"type":"message","id":"6d4fffc4","parentId":"e167ed7c","timestamp":"2026-08-24T02:21:14.501Z","message":{"role":"user","content":[{"type":"text","text":"test using the tools in this harness"}],"meta":{"source":"user","createdAt":1787538070623,"messageId":"7f845134-0ba2-4510-8493-92791e8207c3"}}}
{"type":"message","id":"13184e10","parentId":"6d4fffc4","timestamp":"2026-08-24T02:21:14.503Z","message":{"role":"user","content":[{"type":"text","text":"Error: Cannot read properties of undefined (reading 'summaryParts')\n\nType "continue" to try again. If the issue persists, contact support: https://commandcode.ai/discord\nTrace ID: 7557d41091117d424fe2669a7a3f3289"}],"meta":{"messageId":"9378126f-c2aa-4858-8f59-06c9f6923ac0"}}}

Fix prompt (optional)

You're fixing a crash in @byokkit/cmd-provider-copilot v0.1.1. When using a GPT model routed through Copilot's Responses API, requests fail mid-stream with Error: Cannot read properties of undefined (reading 'summaryParts'), originating in @ai-sdk/openai/src/responses/openai-responses-language-model.ts:2117.

Root cause: GitHub Copilot rotates item_id values across events for the same logical part. createCopilotStreamFixer() in dist/chunk-KNVRT45Z.js already normalizes this id rotation for text-* and reasoning-* events, but it does not cover the OpenAI Responses API's response.reasoning_summary_part.added events. When the AI SDK parser receives a reasoning_summary_part.added whose item_id it never saw, activeReasoning[value.item_id] is undefined, and dereferencing .summaryParts on it throws.

Task:

  1. Locate createCopilotStreamFixer() in the package source and identify exactly which event types it currently remaps (confirm which ones are handled vs. skipped, and how the id remapping/normalization is implemented for the covered events).
  2. Extend the fixer to normalize item_id for the reasoning_summary_part.* family — at minimum reasoning_summary_part.added and reasoning_summary_part.done, plus reasoning_summary_text if present — using the same id-rotation mapping strategy used for the existing reasoning-* events.
  3. Ensure the mapping persists keyed by the stable logical identity (not the rotating raw item_id) so the parser's activeReasoning[...] entry exists by the time summaryParts is dereferenced.
  4. Build and verify the fix resolves the mid-stream crash; include a note if the Dist build (e.g. dist/chunk-KNVRT45Z.js) needs regenerating or if the patch should target the source *.js/.ts that produces it.

Constraints: Minimal, surgical change only — do not refactor unrelated logic. Preserve existing event-ordering and stream-delivery semantics.

Additional context

  1. Cover the full event family, not just .added. The parser path around line 2117 handles the whole reasoning-summary cluster:

    • response.reasoning_summary_part.added / response.reasoning_summary_part.done
    • response.reasoning_summary_text.delta / response.reasoning_summary_text.done
    • response.output_item.added / response.output_item.done (a reasoning item carries its summary array here)
    • response.reasoning.done (the encrypted reasoning item)

    Any of these that carry a rotating item_id must be normalized together, or the crash just moves to the next event in the family.

  2. Restore the exact invariant, not just the symptom. activeReasoning is keyed by item.id from response.output_item.added (type reasoning), then response.reasoning_summary_part.added pushes into activeReasoning[id].summaryParts. The fix must make those two events resolve to the same canonical id. Treating .added in isolation without reconciling output_item.added and .done will still leave ordering/state broken.

  3. Repro data (ideal). Capture the raw SSE chunk sequence with the rotating item_id values from a failing request and paste the sequence in. Even a redacted two-event snippet — e.g. output_item.added {id: A} followed by reasoning_summary_part.added {item_id: B} — pins the bug and lets the agent write a deterministic unit test rather than validating only against live Copilot calls.

  4. Copilot-only gating. createCopilotStreamFixer() is a provider-specific shim. Normalization must only apply to Copilot streams — not plain OpenAI Responses streams — or it risks corrupting ids for providers that do not rotate them.

  5. Source/upstream lookup. The package belongs to the byokkit project. Check npm/GitHub for the actual source and open a PR. Confirm whether dist/ is the only shipped artifact (no src/ or sourcemaps), since that determines whether the patch is a clean source diff or an inline dist/ edit.

  6. Immediate mitigation (stopgap). While the fix lands, pin @ai-sdk/openai to the last version released before encrypted reasoning summaries, or pin the provider package back, to unblock users immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions