Skip to content

🤖 fix: prevent Copilot Sonnet 4.5 tool-stream hasFinished crash #3770

Description

@alecsg77

Copilot Claude Sonnet 4.5 tool stream crashes with hasFinished TypeError

Environment

  • Mux: v0.28.1-nightly.12-7-gd25b50ecc-dirty (d25b50ecc)
  • Platform: Linux x86_64
  • Provider/model: github-copilot:claude-sonnet-4.5

Reproduction

mux run --runtime local --mode exec --thinking low --json --hide-costs \
  --model github-copilot:claude-sonnet-4.5 \
  'Use the bash tool exactly once to execute: printf TOOL_OK. After the tool result, respond with exactly TOOL_OK. Do not modify files.'

Actual result

The model begins the response, then the stream crashes internally:

TypeError: Cannot read properties of undefined (reading 'hasFinished')

The stack reaches StreamingToolCallTracker.flush() in the bundled @ai-sdk/provider-utils, via the bundled OpenAI-compatible streaming adapter.

The reproduction was repeated 5 times and failed 5/5 times with the same TypeError. A text-only smoke test for the same model passes. The same bash-tool prompt passes with Copilot Sonnet 4.6, Haiku 4.5, GPT-5.4, GPT-5 Mini, and the tested Gemini models.

Expected result

Mux should complete the tool call, or return a structured protocol/provider compatibility error. An internal TypeError should not terminate the turn.

Suspected area

The immediate failure is in AI SDK tool-call stream tracking. A sparse or model-specific Copilot tool_calls[*].index sequence is a plausible trigger, but this issue should not attribute the malformed shape to GitHub or Anthropic without a raw SSE capture.

Possible fix directions:

  • normalize Copilot tool-call indexes before the generic OpenAI-compatible parser;
  • update/patch the AI SDK tracker to tolerate sparse entries;
  • return a structured protocol error instead of dereferencing an undefined tracker entry.

Evidence

The issue pack includes evidence/sonnet45-repetitions.tsv, containing only attempt number, exit status, duration, and error classification.


Generated with mux • Model: openai:gpt-5.6-terra • Thinking: high • Cost: $1.39

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions