Skip to content

🤖 fix: map Copilot Responses function-call SSE events #3771

Description

@alecsg77

Copilot Responses adapter sends tool schemas but drops function-call SSE events

Environment

  • Tested Mux: v0.28.1-nightly.12-7-gd25b50ecc-dirty (d25b50ecc)
  • Platform: Linux x86_64
  • Source fixture: coder/mux a9a6b44fa63628a67c06d7d03ef239d668a2646a
  • Component: src/node/services/copilot/copilotResponsesLanguageModel.ts

Problem

CopilotResponsesLanguageModel includes function tools in the outbound Responses request and serializes prior function calls/results. Its streaming parser, however, does not map Responses function-call events to AI SDK tool-input/tool-call stream parts.

mapStreamEvent() currently handles:

  • response.created
  • message/text events
  • terminal events
  • errors

For response.output_item.added, it explicitly returns no parts unless the item type is message. It has no cases for:

response.function_call_arguments.delta
response.function_call_arguments.done

Regression fixture

The attached patch adds a test with this SSE sequence:

response.output_item.added        item.type=function_call
response.function_call_arguments.delta
response.function_call_arguments.done
response.completed

Expected stream-part types:

stream-start
tool-input-start
tool-input-delta
tool-input-end
finish

Actual stream-part types:

stream-start
finish

Test command:

bun test src/node/services/copilot/copilotResponsesLanguageModel.test.ts \
  --test-name-pattern 'streams function-call argument events as tool input parts'

Result:

Targeted fixture: 0 pass, 1 fail.
Full adapter file: 12 existing tests pass, only the new fixture fails.
Expected tool-input-start, tool-input-delta, and tool-input-end;
received only stream-start and finish.

Impact

Any Copilot model using this custom Responses adapter can advertise/receive tool definitions but lose the streamed function call before Mux can execute the tool. This is independent of the separate early-EOF/stream_truncated behavior seen with gpt-5.3-codex.

Expected result

Map the Responses function-call lifecycle into AI SDK stream parts, maintain stable call IDs, and add regression coverage for complete and chunked argument streams.

Evidence

  • evidence/copilot-responses-function-call-fixture.patch
  • evidence/copilot-responses-function-call-fixture.log

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