History

Merge branch 'router-for-me:main' into main

Luis Pater committed 8 months agov6.8.42-0

Commit 352cb982 parents 7ebd8f0 585049218 files · +360 −30Browse files

Unified · Split

18 files
  1. config.example.yaml +3 −0
  2. internal/api/handlers/management/config_lists.go +11 −6
  3. internal/config/vertex_compat.go +4 −0
  4. internal/runtime/executor/antigravity_executor_buildrequest_test.go +4 −0
  5. internal/translator/antigravity/claude/antigravity_claude_request.go +34 −4
  6. internal/translator/antigravity/claude/antigravity_claude_request_test.go +97 −0
  7. internal/translator/codex/claude/codex_claude_request.go +2 −0
  8. internal/translator/codex/openai/chat-completions/codex_openai_response.go +5 −0
  9. internal/translator/codex/openai/chat-completions/codex_openai_response_test.go +47 −0
  10. internal/translator/gemini-cli/claude/gemini-cli_claude_request.go +28 −0
  11. internal/translator/gemini-cli/claude/gemini-cli_claude_request_test.go +42 −0
  12. internal/translator/gemini/claude/gemini_claude_request.go +28 −0
  13. internal/translator/gemini/claude/gemini_claude_request_test.go +42 −0
  14. internal/translator/gemini/openai/responses/gemini_openai-responses_request.go +1 −16
  15. internal/util/gemini_schema.go +1 −1
  16. internal/watcher/diff/config_diff.go +5 −0
  17. internal/watcher/synthesizer/config.go +1 −1
  18. sdk/cliproxy/service.go +5 −2
config.example.yaml+3−0
@@ -233,6 +233,9 @@ nonstream-keepalive-interval: 0 · 232 unmodified lines
233233 # alias: "vertex-flash" # client-visible alias
234234 # - name: "gemini-2.5-pro"
235235 # alias: "vertex-pro"
236+# excluded-models: # optional: models to exclude from listing
237+# - "imagen-3.0-generate-002"
238+# - "imagen-*"
236239
237240 # Amp Integration
238241 # ampcode:
internal/api/handlers/management/config_lists.go+11−6
@@ -516,12 +516,13 @@ func (h *Handler) PutVertexCompatKeys(c *gin.Context) { · 515 unmodified lines
516516 }
517517 func (h *Handler) PatchVertexCompatKey(c *gin.Context) {
518518 type vertexCompatPatch struct {
519− APIKey *string `json:"api-key"`
520− Prefix *string `json:"prefix"`
521− BaseURL *string `json:"base-url"`
522− ProxyURL *string `json:"proxy-url"`
523− Headers *map[string]string `json:"headers"`
524− Models *[]config.VertexCompatModel `json:"models"`
519+ APIKey *string `json:"api-key"`
520+ Prefix *string `json:"prefix"`
521+ BaseURL *string `json:"base-url"`
522+ ProxyURL *string `json:"proxy-url"`
523+ Headers *map[string]string `json:"headers"`
524+ Models *[]config.VertexCompatModel `json:"models"`
525+ ExcludedModels *[]string `json:"excluded-models"`
525526 }
526527 var body struct {
527528 Index *int `json:"index"`
@@ -585,6 +586,9 @@ func (h *Handler) PatchVertexCompatKey(c *gin.Context) { · 57 unmodified lines
585586 if body.Value.Models != nil {
586587 entry.Models = append([]config.VertexCompatModel(nil), (*body.Value.Models)...)
587588 }
589+ if body.Value.ExcludedModels != nil {
590+ entry.ExcludedModels = config.NormalizeExcludedModels(*body.Value.ExcludedModels)
591+ }
588592 normalizeVertexCompatKey(&entry)
589593 h.cfg.VertexCompatAPIKey[targetIndex] = entry
590594 h.cfg.SanitizeVertexCompatKeys()
@@ -1029,6 +1033,7 @@ func normalizeVertexCompatKey(entry *config.VertexCompatKey) { · 438 unmodified lines
10291033 entry.BaseURL = strings.TrimSpace(entry.BaseURL)
10301034 entry.ProxyURL = strings.TrimSpace(entry.ProxyURL)
10311035 entry.Headers = config.NormalizeHeaders(entry.Headers)
1036+ entry.ExcludedModels = config.NormalizeExcludedModels(entry.ExcludedModels)
10321037 if len(entry.Models) == 0 {
10331038 return
10341039 }
internal/config/vertex_compat.go+4−0
@@ -34,6 +34,9 @@ type VertexCompatKey struct { · 33 unmodified lines
3434
3535 // Models defines the model configurations including aliases for routing.
3636 Models []VertexCompatModel `yaml:"models,omitempty" json:"models,omitempty"`
37+
38+ // ExcludedModels lists model IDs that should be excluded for this provider.
39+ ExcludedModels []string `yaml:"excluded-models,omitempty" json:"excluded-models,omitempty"`
3740 }
3841
3942 func (k VertexCompatKey) GetAPIKey() string { return k.APIKey }
@@ -74,6 +77,7 @@ func (cfg *Config) SanitizeVertexCompatKeys() { · 34 unmodified lines
7477 }
7578 entry.ProxyURL = strings.TrimSpace(entry.ProxyURL)
7679 entry.Headers = NormalizeHeaders(entry.Headers)
80+ entry.ExcludedModels = NormalizeExcludedModels(entry.ExcludedModels)
7781
7882 // Sanitize models: remove entries without valid alias
7983 sanitizedModels := make([]VertexCompatModel, 0, len(entry.Models))
internal/runtime/executor/antigravity_executor_buildrequest_test.go+4−0
@@ -59,6 +59,7 @@ func buildRequestBodyFromPayload(t *testing.T, modelName string) map[string]any · 58 unmodified lines
5959 "properties": {
6060 "mode": {
6161 "type": "string",
62+ "deprecated": true,
6263 "enum": ["a", "b"],
6364 "enumTitles": ["A", "B"]
6465 }
@@ -156,4 +157,7 @@ func assertSchemaSanitizedAndPropertyPreserved(t *testing.T, params map[string]a · 91 unmodified lines
156157 if _, ok := mode["enumTitles"]; ok {
157158 t.Fatalf("enumTitles should be removed from nested schema")
158159 }
160+ if _, ok := mode["deprecated"]; ok {
161+ t.Fatalf("deprecated should be removed from nested schema")
162+ }
159163 }
internal/translator/antigravity/claude/antigravity_claude_request.go+34−4
@@ -431,6 +431,33 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 430 unmodified lines
431431 out, _ = sjson.SetRaw(out, "request.tools", toolsJSON)
432432 }
433433
434+ // tool_choice
435+ toolChoiceResult := gjson.GetBytes(rawJSON, "tool_choice")
436+ if toolChoiceResult.Exists() {
437+ toolChoiceType := ""
438+ toolChoiceName := ""
439+ if toolChoiceResult.IsObject() {
440+ toolChoiceType = toolChoiceResult.Get("type").String()
441+ toolChoiceName = toolChoiceResult.Get("name").String()
442+ } else if toolChoiceResult.Type == gjson.String {
443+ toolChoiceType = toolChoiceResult.String()
444+ }
445+
446+ switch toolChoiceType {
447+ case "auto":
448+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "AUTO")
449+ case "none":
450+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "NONE")
451+ case "any":
452+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "ANY")
453+ case "tool":
454+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "ANY")
455+ if toolChoiceName != "" {
456+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.allowedFunctionNames", []string{toolChoiceName})
457+ }
458+ }
459+ }
460+
434461 // Map Anthropic thinking -> Gemini thinkingBudget/include_thoughts when type==enabled
435462 if t := gjson.GetBytes(rawJSON, "thinking"); enableThoughtTranslate && t.Exists() && t.IsObject() {
436463 switch t.Get("type").String() {
@@ -441,15 +468,18 @@ func ConvertClaudeRequestToAntigravity(modelName string, inputRawJSON []byte, _ · 4 unmodified lines
441468 out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.includeThoughts", true)
442469 }
443470 case "adaptive", "auto":
444− // Adaptive/auto thinking:
445− // - If output_config.effort is present, pass it through as thinkingLevel.
446− // - Otherwise, default to "high".
447− // ApplyThinking later normalizes/clamps and may convert level → budget per target model.
471+ // For adaptive thinking:
472+ // - If output_config.effort is explicitly present, pass through as thinkingLevel.
473+ // - Otherwise, treat it as "enabled with target-model maximum" and emit high.
474+ // ApplyThinking handles clamping to target model's supported levels.
448475 effort := ""
449476 if v := gjson.GetBytes(rawJSON, "output_config.effort"); v.Exists() && v.Type == gjson.String {
450477 effort = strings.ToLower(strings.TrimSpace(v.String()))
451478 }
452479 if effort != "" {
480+ if effort == "max" {
481+ effort = "high"
482+ }
453483 out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", effort)
454484 } else {
455485 out, _ = sjson.Set(out, "request.generationConfig.thinkingConfig.thinkingLevel", "high")
internal/translator/antigravity/claude/antigravity_claude_request_test.go+97−0
@@ -193,6 +193,42 @@ func TestConvertClaudeRequestToAntigravity_ToolDeclarations(t *testing.T) { · 192 unmodified lines
193193 }
194194 }
195195
196+func TestConvertClaudeRequestToAntigravity_ToolChoice_SpecificTool(t *testing.T) {
197+ inputJSON := []byte(`{
198+ "model": "gemini-3-flash-preview",
199+ "messages": [
200+ {
201+ "role": "user",
202+ "content": [
203+ {"type": "text", "text": "hi"}
204+ ]
205+ }
206+ ],
207+ "tools": [
208+ {
209+ "name": "json",
210+ "description": "A JSON tool",
211+ "input_schema": {
212+ "type": "object",
213+ "properties": {}
214+ }
215+ }
216+ ],
217+ "tool_choice": {"type": "tool", "name": "json"}
218+ }`)
219+
220+ output := ConvertClaudeRequestToAntigravity("gemini-3-flash-preview", inputJSON, false)
221+ outputStr := string(output)
222+
223+ if got := gjson.Get(outputStr, "request.toolConfig.functionCallingConfig.mode").String(); got != "ANY" {
224+ t.Fatalf("Expected toolConfig.functionCallingConfig.mode 'ANY', got '%s'", got)
225+ }
226+ allowed := gjson.Get(outputStr, "request.toolConfig.functionCallingConfig.allowedFunctionNames").Array()
227+ if len(allowed) != 1 || allowed[0].String() != "json" {
228+ t.Fatalf("Expected allowedFunctionNames ['json'], got %s", gjson.Get(outputStr, "request.toolConfig.functionCallingConfig.allowedFunctionNames").Raw)
229+ }
230+}
231+
196232 func TestConvertClaudeRequestToAntigravity_ToolUse(t *testing.T) {
197233 inputJSON := []byte(`{
198234 "model": "claude-3-5-sonnet-20240620",
@@ -1199,3 +1235,64 @@ func TestConvertClaudeRequestToAntigravity_ToolAndThinking_NoExistingSystem(t *t · 1000 unmodified lines
11991235 t.Errorf("Interleaved thinking hint should be in created systemInstruction, got: %v", sysInstruction.Raw)
12001236 }
12011237 }
1238+
1239+func TestConvertClaudeRequestToAntigravity_AdaptiveThinking_EffortLevels(t *testing.T) {
1240+ tests := []struct {
1241+ name string
1242+ effort string
1243+ expected string
1244+ }{
1245+ {"low", "low", "low"},
1246+ {"medium", "medium", "medium"},
1247+ {"high", "high", "high"},
1248+ {"max", "max", "high"},
1249+ }
1250+
1251+ for _, tt := range tests {
1252+ tt := tt
1253+ t.Run(tt.name, func(t *testing.T) {
1254+ inputJSON := []byte(`{
1255+ "model": "claude-opus-4-6-thinking",
1256+ "messages": [{"role": "user", "content": [{"type": "text", "text": "Hello"}]}],
1257+ "thinking": {"type": "adaptive"},
1258+ "output_config": {"effort": "` + tt.effort + `"}
1259+ }`)
1260+
1261+ output := ConvertClaudeRequestToAntigravity("claude-opus-4-6-thinking", inputJSON, false)
1262+ outputStr := string(output)
1263+
1264+ thinkingConfig := gjson.Get(outputStr, "request.generationConfig.thinkingConfig")
1265+ if !thinkingConfig.Exists() {
1266+ t.Fatal("thinkingConfig should exist for adaptive thinking")
1267+ }
1268+ if thinkingConfig.Get("thinkingLevel").String() != tt.expected {
1269+ t.Errorf("Expected thinkingLevel %q, got %q", tt.expected, thinkingConfig.Get("thinkingLevel").String())
1270+ }
1271+ if !thinkingConfig.Get("includeThoughts").Bool() {
1272+ t.Error("includeThoughts should be true")
1273+ }
1274+ })
1275+ }
1276+}
1277+
1278+func TestConvertClaudeRequestToAntigravity_AdaptiveThinking_NoEffort(t *testing.T) {
1279+ inputJSON := []byte(`{
1280+ "model": "claude-opus-4-6-thinking",
1281+ "messages": [{"role": "user", "content": [{"type": "text", "text": "Hello"}]}],
1282+ "thinking": {"type": "adaptive"}
1283+ }`)
1284+
1285+ output := ConvertClaudeRequestToAntigravity("claude-opus-4-6-thinking", inputJSON, false)
1286+ outputStr := string(output)
1287+
1288+ thinkingConfig := gjson.Get(outputStr, "request.generationConfig.thinkingConfig")
1289+ if !thinkingConfig.Exists() {
1290+ t.Fatal("thinkingConfig should exist for adaptive thinking without effort")
1291+ }
1292+ if thinkingConfig.Get("thinkingLevel").String() != "high" {
1293+ t.Errorf("Expected default thinkingLevel \"high\", got %q", thinkingConfig.Get("thinkingLevel").String())
1294+ }
1295+ if !thinkingConfig.Get("includeThoughts").Bool() {
1296+ t.Error("includeThoughts should be true")
1297+ }
1298+}
internal/translator/codex/claude/codex_claude_request.go+2−0
@@ -255,6 +255,8 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool) · 254 unmodified lines
255255 tool, _ = sjson.SetRaw(tool, "parameters", normalizeToolParameters(toolResult.Get("input_schema").Raw))
256256 tool, _ = sjson.Delete(tool, "input_schema")
257257 tool, _ = sjson.Delete(tool, "parameters.$schema")
258+ tool, _ = sjson.Delete(tool, "cache_control")
259+ tool, _ = sjson.Delete(tool, "defer_loading")
258260 tool, _ = sjson.Set(tool, "strict", false)
259261 template, _ = sjson.SetRaw(template, "tools.-1", tool)
260262 }
internal/translator/codex/openai/chat-completions/codex_openai_response.go+5−0
@@ -74,8 +74,13 @@ func ConvertCodexResponseToOpenAI(_ context.Context, modelName string, originalR · 73 unmodified lines
7474 }
7575
7676 // Extract and set the model version.
77+ cachedModel := (*param).(*ConvertCliToOpenAIParams).Model
7778 if modelResult := gjson.GetBytes(rawJSON, "model"); modelResult.Exists() {
7879 template, _ = sjson.Set(template, "model", modelResult.String())
80+ } else if cachedModel != "" {
81+ template, _ = sjson.Set(template, "model", cachedModel)
82+ } else if modelName != "" {
83+ template, _ = sjson.Set(template, "model", modelName)
7984 }
8085
8186 template, _ = sjson.Set(template, "created", (*param).(*ConvertCliToOpenAIParams).CreatedAt)
internal/translator/codex/openai/chat-completions/codex_openai_response_test.go+47−0
@@ -0,0 +1,47 @@
1+package chat_completions
2+
3+import (
4+ "context"
5+ "testing"
6+
7+ "github.com/tidwall/gjson"
8+)
9+
10+func TestConvertCodexResponseToOpenAI_StreamSetsModelFromResponseCreated(t *testing.T) {
11+ ctx := context.Background()
12+ var param any
13+
14+ modelName := "gpt-5.3-codex"
15+
16+ out := ConvertCodexResponseToOpenAI(ctx, modelName, nil, nil, []byte(`data: {"type":"response.created","response":{"id":"resp_123","created_at":1700000000,"model":"gpt-5.3-codex"}}`), &param)
17+ if len(out) != 0 {
18+ t.Fatalf("expected no output for response.created, got %d chunks", len(out))
19+ }
20+
21+ out = ConvertCodexResponseToOpenAI(ctx, modelName, nil, nil, []byte(`data: {"type":"response.output_text.delta","delta":"hello"}`), &param)
22+ if len(out) != 1 {
23+ t.Fatalf("expected 1 chunk, got %d", len(out))
24+ }
25+
26+ gotModel := gjson.Get(out[0], "model").String()
27+ if gotModel != modelName {
28+ t.Fatalf("expected model %q, got %q", modelName, gotModel)
29+ }
30+}
31+
32+func TestConvertCodexResponseToOpenAI_FirstChunkUsesRequestModelName(t *testing.T) {
33+ ctx := context.Background()
34+ var param any
35+
36+ modelName := "gpt-5.3-codex"
37+
38+ out := ConvertCodexResponseToOpenAI(ctx, modelName, nil, nil, []byte(`data: {"type":"response.output_text.delta","delta":"hello"}`), &param)
39+ if len(out) != 1 {
40+ t.Fatalf("expected 1 chunk, got %d", len(out))
41+ }
42+
43+ gotModel := gjson.Get(out[0], "model").String()
44+ if gotModel != modelName {
45+ t.Fatalf("expected model %q, got %q", modelName, gotModel)
46+ }
47+}
internal/translator/gemini-cli/claude/gemini-cli_claude_request.go+28−0
@@ -156,6 +156,7 @@ func ConvertClaudeRequestToCLI(modelName string, inputRawJSON []byte, _ bool) [] · 155 unmodified lines
156156 tool, _ = sjson.Delete(tool, "input_examples")
157157 tool, _ = sjson.Delete(tool, "type")
158158 tool, _ = sjson.Delete(tool, "cache_control")
159+ tool, _ = sjson.Delete(tool, "defer_loading")
159160 if gjson.Valid(tool) && gjson.Parse(tool).IsObject() {
160161 if !hasTools {
161162 out, _ = sjson.SetRaw(out, "request.tools", `[{"functionDeclarations":[]}]`)
@@ -171,6 +172,33 @@ func ConvertClaudeRequestToCLI(modelName string, inputRawJSON []byte, _ bool) [] · 9 unmodified lines
171172 }
172173 }
173174
175+ // tool_choice
176+ toolChoiceResult := gjson.GetBytes(rawJSON, "tool_choice")
177+ if toolChoiceResult.Exists() {
178+ toolChoiceType := ""
179+ toolChoiceName := ""
180+ if toolChoiceResult.IsObject() {
181+ toolChoiceType = toolChoiceResult.Get("type").String()
182+ toolChoiceName = toolChoiceResult.Get("name").String()
183+ } else if toolChoiceResult.Type == gjson.String {
184+ toolChoiceType = toolChoiceResult.String()
185+ }
186+
187+ switch toolChoiceType {
188+ case "auto":
189+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "AUTO")
190+ case "none":
191+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "NONE")
192+ case "any":
193+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "ANY")
194+ case "tool":
195+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.mode", "ANY")
196+ if toolChoiceName != "" {
197+ out, _ = sjson.Set(out, "request.toolConfig.functionCallingConfig.allowedFunctionNames", []string{toolChoiceName})
198+ }
199+ }
200+ }
201+
174202 // Map Anthropic thinking -> Gemini CLI thinkingConfig when enabled
175203 // Translator only does format conversion, ApplyThinking handles model capability validation.
176204 if t := gjson.GetBytes(rawJSON, "thinking"); t.Exists() && t.IsObject() {
internal/translator/gemini-cli/claude/gemini-cli_claude_request_test.go+42−0
@@ -0,0 +1,42 @@
1+package claude
2+
3+import (
4+ "testing"
5+
6+ "github.com/tidwall/gjson"
7+)
8+
9+func TestConvertClaudeRequestToCLI_ToolChoice_SpecificTool(t *testing.T) {
10+ inputJSON := []byte(`{
11+ "model": "gemini-3-flash-preview",
12+ "messages": [
13+ {
14+ "role": "user",
15+ "content": [
16+ {"type": "text", "text": "hi"}
17+ ]
18+ }
19+ ],
20+ "tools": [
21+ {
22+ "name": "json",
23+ "description": "A JSON tool",
24+ "input_schema": {
25+ "type": "object",
26+ "properties": {}
27+ }
28+ }
29+ ],
30+ "tool_choice": {"type": "tool", "name": "json"}
31+ }`)
32+
33+ output := ConvertClaudeRequestToCLI("gemini-3-flash-preview", inputJSON, false)
34+
35+ if got := gjson.GetBytes(output, "request.toolConfig.functionCallingConfig.mode").String(); got != "ANY" {
36+ t.Fatalf("Expected request.toolConfig.functionCallingConfig.mode 'ANY', got '%s'", got)
37+ }
38+ allowed := gjson.GetBytes(output, "request.toolConfig.functionCallingConfig.allowedFunctionNames").Array()
39+ if len(allowed) != 1 || allowed[0].String() != "json" {
40+ t.Fatalf("Expected allowedFunctionNames ['json'], got %s", gjson.GetBytes(output, "request.toolConfig.functionCallingConfig.allowedFunctionNames").Raw)
41+ }
42+}
internal/translator/gemini/claude/gemini_claude_request.go+28−0
@@ -137,6 +137,7 @@ func ConvertClaudeRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 136 unmodified lines
137137 tool, _ = sjson.Delete(tool, "input_examples")
138138 tool, _ = sjson.Delete(tool, "type")
139139 tool, _ = sjson.Delete(tool, "cache_control")
140+ tool, _ = sjson.Delete(tool, "defer_loading")
140141 if gjson.Valid(tool) && gjson.Parse(tool).IsObject() {
141142 if !hasTools {
142143 out, _ = sjson.SetRaw(out, "tools", `[{"functionDeclarations":[]}]`)
@@ -152,6 +153,33 @@ func ConvertClaudeRequestToGemini(modelName string, inputRawJSON []byte, _ bool) · 9 unmodified lines
152153 }
153154 }
154155
156+ // tool_choice
157+ toolChoiceResult := gjson.GetBytes(rawJSON, "tool_choice")
158+ if toolChoiceResult.Exists() {
159+ toolChoiceType := ""
160+ toolChoiceName := ""
161+ if toolChoiceResult.IsObject() {
162+ toolChoiceType = toolChoiceResult.Get("type").String()
163+ toolChoiceName = toolChoiceResult.Get("name").String()
164+ } else if toolChoiceResult.Type == gjson.String {
165+ toolChoiceType = toolChoiceResult.String()
166+ }
167+
168+ switch toolChoiceType {
169+ case "auto":
170+ out, _ = sjson.Set(out, "toolConfig.functionCallingConfig.mode", "AUTO")
171+ case "none":
172+ out, _ = sjson.Set(out, "toolConfig.functionCallingConfig.mode", "NONE")
173+ case "any":
174+ out, _ = sjson.Set(out, "toolConfig.functionCallingConfig.mode", "ANY")
175+ case "tool":
176+ out, _ = sjson.Set(out, "toolConfig.functionCallingConfig.mode", "ANY")
177+ if toolChoiceName != "" {
178+ out, _ = sjson.Set(out, "toolConfig.functionCallingConfig.allowedFunctionNames", []string{toolChoiceName})
179+ }
180+ }
181+ }
182+
155183 // Map Anthropic thinking -> Gemini thinking config when enabled
156184 // Translator only does format conversion, ApplyThinking handles model capability validation.
157185 if t := gjson.GetBytes(rawJSON, "thinking"); t.Exists() && t.IsObject() {
internal/translator/gemini/claude/gemini_claude_request_test.go+42−0
@@ -0,0 +1,42 @@
1+package claude
2+
3+import (
4+ "testing"
5+
6+ "github.com/tidwall/gjson"
7+)
8+
9+func TestConvertClaudeRequestToGemini_ToolChoice_SpecificTool(t *testing.T) {
10+ inputJSON := []byte(`{
11+ "model": "gemini-3-flash-preview",
12+ "messages": [
13+ {
14+ "role": "user",
15+ "content": [
16+ {"type": "text", "text": "hi"}
17+ ]
18+ }
19+ ],
20+ "tools": [
21+ {
22+ "name": "json",
23+ "description": "A JSON tool",
24+ "input_schema": {
25+ "type": "object",
26+ "properties": {}
27+ }
28+ }
29+ ],
30+ "tool_choice": {"type": "tool", "name": "json"}
31+ }`)
32+
33+ output := ConvertClaudeRequestToGemini("gemini-3-flash-preview", inputJSON, false)
34+
35+ if got := gjson.GetBytes(output, "toolConfig.functionCallingConfig.mode").String(); got != "ANY" {
36+ t.Fatalf("Expected toolConfig.functionCallingConfig.mode 'ANY', got '%s'", got)
37+ }
38+ allowed := gjson.GetBytes(output, "toolConfig.functionCallingConfig.allowedFunctionNames").Array()
39+ if len(allowed) != 1 || allowed[0].String() != "json" {
40+ t.Fatalf("Expected allowedFunctionNames ['json'], got %s", gjson.GetBytes(output, "toolConfig.functionCallingConfig.allowedFunctionNames").Raw)
41+ }
42+}
internal/translator/gemini/openai/responses/gemini_openai-responses_request.go+1−16
@@ -354,22 +354,7 @@ func ConvertOpenAIResponsesRequestToGemini(modelName string, inputRawJSON []byte · 353 unmodified lines
354354 funcDecl, _ = sjson.Set(funcDecl, "description", desc.String())
355355 }
356356 if params := tool.Get("parameters"); params.Exists() {
357− // Convert parameter types from OpenAI format to Gemini format
358− cleaned := params.Raw
359− // Convert type values to uppercase for Gemini
360− paramsResult := gjson.Parse(cleaned)
361− if properties := paramsResult.Get("properties"); properties.Exists() {
362− properties.ForEach(func(key, value gjson.Result) bool {
363− if propType := value.Get("type"); propType.Exists() {
364− upperType := strings.ToUpper(propType.String())
365− cleaned, _ = sjson.Set(cleaned, "properties."+key.String()+".type", upperType)
366− }
367− return true
368− })
369− }
370− // Set the overall type to OBJECT
371− cleaned, _ = sjson.Set(cleaned, "type", "OBJECT")
372− funcDecl, _ = sjson.SetRaw(funcDecl, "parametersJsonSchema", cleaned)
357+ funcDecl, _ = sjson.SetRaw(funcDecl, "parametersJsonSchema", params.Raw)
373358 }
374359
375360 geminiTools, _ = sjson.SetRaw(geminiTools, "0.functionDeclarations.-1", funcDecl)
internal/util/gemini_schema.go+1−1
@@ -430,7 +430,7 @@ func removeUnsupportedKeywords(jsonStr string) string { · 429 unmodified lines
430430 keywords := append(unsupportedConstraints,
431431 "$schema", "$defs", "definitions", "const", "$ref", "$id", "additionalProperties",
432432 "propertyNames", "patternProperties", // Gemini doesn't support these schema keywords
433− "enumTitles", "prefill", // Claude/OpenCode schema metadata fields unsupported by Gemini
433+ "enumTitles", "prefill", "deprecated", // Schema metadata fields unsupported by Gemini
434434 )
435435
436436 deletePaths := make([]string, 0)
internal/watcher/diff/config_diff.go+5−0
@@ -304,6 +304,11 @@ func BuildConfigChangeDetails(oldCfg, newCfg *config.Config) []string { · 303 unmodified lines
304304 if oldModels.hash != newModels.hash {
305305 changes = append(changes, fmt.Sprintf("vertex[%d].models: updated (%d -> %d entries)", i, oldModels.count, newModels.count))
306306 }
307+ oldExcluded := SummarizeExcludedModels(o.ExcludedModels)
308+ newExcluded := SummarizeExcludedModels(n.ExcludedModels)
309+ if oldExcluded.hash != newExcluded.hash {
310+ changes = append(changes, fmt.Sprintf("vertex[%d].excluded-models: updated (%d -> %d entries)", i, oldExcluded.count, newExcluded.count))
311+ }
307312 if !equalStringMap(o.Headers, n.Headers) {
308313 changes = append(changes, fmt.Sprintf("vertex[%d].headers: updated", i))
309314 }
internal/watcher/synthesizer/config.go+1−1
@@ -319,7 +319,7 @@ func (s *ConfigSynthesizer) synthesizeVertexCompat(ctx *SynthesisContext) []*cor · 318 unmodified lines
319319 CreatedAt: now,
320320 UpdatedAt: now,
321321 }
322− ApplyAuthExcludedModelsMeta(a, cfg, nil, "apikey")
322+ ApplyAuthExcludedModelsMeta(a, cfg, compat.ExcludedModels, "apikey")
323323 out = append(out, a)
324324 }
325325 return out
sdk/cliproxy/service.go+5−2
@@ -820,10 +820,13 @@ func (s *Service) registerModelsForAuth(a *coreauth.Auth) { · 819 unmodified lines
820820 case "vertex":
821821 // Vertex AI Gemini supports the same model identifiers as Gemini.
822822 models = registry.GetGeminiVertexModels()
823− if authKind == "apikey" {
824− if entry := s.resolveConfigVertexCompatKey(a); entry != nil && len(entry.Models) > 0 {
823+ if entry := s.resolveConfigVertexCompatKey(a); entry != nil {
824+ if len(entry.Models) > 0 {
825825 models = buildVertexCompatConfigModels(entry)
826826 }
827+ if authKind == "apikey" {
828+ excluded = entry.ExcludedModels
829+ }
827830 }
828831 models = applyExcludedModels(models, excluded)
829832 case "gemini-cli":

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t