package gemini import ( "fmt" "testing" "github.com/tidwall/gjson" ) func TestConvertGeminiRequestToCodex_PreservesCustomCallIDs(t *testing.T) { tests := []struct { name string callField string responseField string want string }{ { name: "id", callField: `"id":"call_gateway_id"`, responseField: `"id":"call_gateway_id"`, want: "call_gateway_id", }, { name: "call_id", callField: `"call_id":"call_gateway_call_id"`, responseField: `"call_id":"call_gateway_call_id"`, want: "call_gateway_call_id", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { raw := []byte(fmt.Sprintf(`{ "contents": [ { "role": "model", "parts": [ {"functionCall": {"name": "lookup", %s, "args": {"query": "status"}}} ] }, { "role": "user", "parts": [ {"functionResponse": {"name": "lookup", %s, "response": {"result": "ok"}}} ] } ] }`, tt.callField, tt.responseField)) out := ConvertGeminiRequestToCodex("gpt-5.1-codex", raw, false) gotCallID := gjson.GetBytes(out, "input.0.call_id").String() if gotCallID != tt.want { t.Fatalf("expected function_call call_id %q, got %q; output=%s", tt.want, gotCallID, string(out)) } gotOutputID := gjson.GetBytes(out, "input.1.call_id").String() if gotOutputID != tt.want { t.Fatalf("expected function_call_output call_id %q, got %q; output=%s", tt.want, gotOutputID, string(out)) } }) } }