Skip to content

fix(openai): deduplicate Copilot response text - #3846

Merged
dgageot merged 1 commit into
mainfrom
fix/copilot-responses-duplicate-output
Jul 27, 2026
Merged

fix(openai): deduplicate Copilot response text#3846
dgageot merged 1 commit into
mainfrom
fix/copilot-responses-duplicate-output

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • deduplicate GitHub Copilot Responses API text by stable output_index when event item_id values differ
  • preserve the completed-item snapshot fallback when no text delta was received
  • add regression coverage for duplicated structured output, missing deltas, and multiple output slots

Issue expectations

Expectation Implementation
Responses from github-copilot are emitted once Streamed content is tracked by both item ID and output_index
Judge output remains valid JSON The completed item snapshot is not appended after its text deltas
Providers that omit text deltas still return content response.output_item.done remains a fallback when no content was emitted
Multiple outputs remain independent Content state is tracked separately for each output_index

Reproduction

Before the fix, the regression stream produced:

{"answer":"structured","confidence":0.9}{"answer":"structured","confidence":0.9}

After the fix, it produces:

{"answer":"structured","confidence":0.9}

Validation

  • go test ./pkg/model/provider/openai -run TestResponseStream_CopilotUnstableItemIDsOutputTextNotDuplicated -count=20
  • go test -race ./pkg/model/provider/openai -run TestResponseStream_CopilotUnstableItemIDsOutputTextNotDuplicated -count=1
  • go test ./pkg/model/provider/openai -count=1
  • env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy task test
  • task --force lint
  • task build

Live verification against the affected gpt-5.6-* models was unavailable because the models are disabled for the available Copilot token and return model_not_supported. The regression test replays the observed Copilot event shape deterministically.

Fixes #3839

@Sayt-0
Sayt-0 requested a review from a team as a code owner July 27, 2026 12:20
@aheritier aheritier added the status/needs-triage For issues that need to be triaged label Jul 27, 2026
@dgageot
dgageot merged commit 9601b7a into main Jul 27, 2026
14 checks passed
@dgageot
dgageot deleted the fix/copilot-responses-duplicate-output branch July 27, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-triage For issues that need to be triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github-copilot: answers of api_type openai_responses are doubled

3 participants