-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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.providerIDfor "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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working