Skip to content

fix: normalize Copilot reasoning stream IDs - #836

Closed
RealBhupesh wants to merge 1 commit into
Nano-Collective:mainfrom
RealBhupesh:codex/fix-copilot-reasoning-stream
Closed

RealBhupesh wants to merge 1 commit into
Nano-Collective:mainfrom
RealBhupesh:codex/fix-copilot-reasoning-stream

Conversation

@RealBhupesh

Copy link
Copy Markdown
Contributor

Summary

  • normalize GitHub Copilot Responses API event IDs by the stable output_index before AI SDK 6 parses the stream
  • cover reasoning summaries, text deltas, completed items, state cleanup, and reused output indexes
  • preserve non-SSE, control, malformed, and [DONE] events
  • support LF, CRLF, and CR-only SSE framing plus case-insensitive media types
  • add a patch changeset

Closes #719

Root cause

GitHub Copilot can rotate the opaque item_id across events for one logical output while keeping output_index stable. @ai-sdk/openai 3.x keys active reasoning state by item ID, so the rotated ID triggers the reported summaryParts dereference.

NanoCoder already carries a pnpm patch, but published npm/Homebrew installations do not receive or apply it: the package publishes dist and selected assets, not patches/ or pnpm-workspace.yaml. That explains why the reporter reproduces the crash in releases containing the repository commit.

The upstream SDK fixed the same live Copilot sequence in vercel/ai#18548 by correlating events through output_index, but that correction is on the provider's next major line. This PR applies the narrow compatibility normalization only to NanoCoder's Copilot fetch path without a broad AI SDK migration.

Validation

  • focused provider suite: 25 passed
  • regression mutation confirmed the correlation test fails when ID rewriting is removed
  • pnpm run test:format
  • pnpm run test:lint
  • git diff --check
  • independent review found no remaining findings
  • with prerequisite fix: restore ACP provider discovery #830 applied, build and TypeScript checks pass
  • the full suite reached 6,279 passing tests before one live Context7 network test timed out; that exact external test passed on immediate isolated rerun

Current branch CI will inherit the ACP SDK failure already on main until #830 merges.

@will-lamerton

Copy link
Copy Markdown
Member

Hey @RealBhupesh - thanks for this PR - closing due to an earlier PR that solves the issue is almost ready to merge!

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.

[Bug] Cannot read properties of undefined (reading 'summaryParts') when using Github Copilot with GPT-5.3 Codex

2 participants