Skip to content

Commit 34c8ccb

Browse files
committed
Fixed: #437
feat(runtime): strip `service_tier` in GitHub Copilot response normalization
1 parent d08e164 commit 34c8ccb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

internal/runtime/executor/github_copilot_executor.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ func normalizeGitHubCopilotChatTools(body []byte) []byte {
653653
}
654654

655655
func normalizeGitHubCopilotResponsesInput(body []byte) []byte {
656+
body = stripGitHubCopilotResponsesUnsupportedFields(body)
656657
input := gjson.GetBytes(body, "input")
657658
if input.Exists() {
658659
// If input is already a string or array, keep it as-is.
@@ -825,6 +826,12 @@ func normalizeGitHubCopilotResponsesInput(body []byte) []byte {
825826
return body
826827
}
827828

829+
func stripGitHubCopilotResponsesUnsupportedFields(body []byte) []byte {
830+
// GitHub Copilot /responses rejects service_tier, so always remove it.
831+
body, _ = sjson.DeleteBytes(body, "service_tier")
832+
return body
833+
}
834+
828835
func normalizeGitHubCopilotResponsesTools(body []byte) []byte {
829836
tools := gjson.GetBytes(body, "tools")
830837
if tools.Exists() {

internal/runtime/executor/github_copilot_executor_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ func TestNormalizeGitHubCopilotResponsesInput_NonStringInputStringified(t *testi
132132
}
133133
}
134134

135+
func TestNormalizeGitHubCopilotResponsesInput_StripsServiceTier(t *testing.T) {
136+
t.Parallel()
137+
body := []byte(`{"input":"user text","service_tier":"default"}`)
138+
got := normalizeGitHubCopilotResponsesInput(body)
139+
140+
if gjson.GetBytes(got, "service_tier").Exists() {
141+
t.Fatalf("service_tier should be removed, got %s", gjson.GetBytes(got, "service_tier").Raw)
142+
}
143+
if gjson.GetBytes(got, "input").String() != "user text" {
144+
t.Fatalf("input = %q, want %q", gjson.GetBytes(got, "input").String(), "user text")
145+
}
146+
}
147+
135148
func TestNormalizeGitHubCopilotResponsesTools_FlattenFunctionTools(t *testing.T) {
136149
t.Parallel()
137150
body := []byte(`{"tools":[{"type":"function","function":{"name":"sum","description":"d","parameters":{"type":"object"}}},{"type":"web_search"}]}`)

0 commit comments

Comments
 (0)