Skip to content

Compaction fails with 400 Bad Request when using GitHub Copilot Enterprise #11157

@unimun

Description

@unimun

Description

Problem

Compaction (conversation summarization) fails with 400 Bad Request when using GitHub Copilot Enterprise provider with Claude models.

Root Cause

GitHub Copilot API's /chat/completions endpoint rejects messages with role: "tool" during summarization requests.

API Validation

Test Case Request Contains Response Status
Test 1 Simple user message only Success (200) ✅ PASS
Test 2 Assistant message with tool_calls Success (200) ✅ PASS
Test 3 Tool result message (role: "tool") Bad Request (400) ❌ FAIL
Test 4 Both tool_calls + tool result Bad Request (400) ❌ FAIL

Solution

Provider-specific filtering in packages/opencode/src/session/compaction.ts:

  • Check model.providerID for "copilot"
  • Only sanitize tool messages for GitHub Copilot
  • Other providers pass messages unchanged

Verification

  • Compaction works for GitHub Copilot
  • Regular chat with tools still works
  • API behavior validated with curl tests
  • Build passes

Plugins

No response

OpenCode version

dev build

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions