@@ -83,6 +83,9 @@ func TestGenerateConfigCllamaRewritesProviderBaseURL(t *testing.T) {
8383 if anthropic ["baseUrl" ] != "http://cllama:8080/v1" {
8484 t .Errorf ("expected proxy baseUrl, got %v" , anthropic ["baseUrl" ])
8585 }
86+ if anthropic ["api" ] != "anthropic-messages" {
87+ t .Fatalf ("expected anthropic provider behind cllama to use anthropic-messages, got %v" , anthropic ["api" ])
88+ }
8689 modelEntries , ok := anthropic ["models" ].([]interface {})
8790 if ! ok || len (modelEntries ) == 0 {
8891 t .Fatalf ("expected models.providers.anthropic.models entries, got %T %v" , anthropic ["models" ], anthropic ["models" ])
@@ -96,6 +99,70 @@ func TestGenerateConfigCllamaRewritesProviderBaseURL(t *testing.T) {
9699 }
97100}
98101
102+ func TestGenerateConfigCllamaGoogleUsesOpenAICompletions (t * testing.T ) {
103+ rc := & driver.ResolvedClaw {
104+ Models : map [string ]string {"primary" : "google/gemini-3-flash-preview" },
105+ Cllama : []string {"passthrough" },
106+ CllamaToken : "weston:abc123hex" ,
107+ }
108+ data , err := GenerateConfig (rc )
109+ if err != nil {
110+ t .Fatal (err )
111+ }
112+ var config map [string ]interface {}
113+ if err := json .Unmarshal (data , & config ); err != nil {
114+ t .Fatal (err )
115+ }
116+ modelsCfg , ok := config ["models" ].(map [string ]interface {})
117+ if ! ok {
118+ t .Fatal ("expected models config" )
119+ }
120+ providers , ok := modelsCfg ["providers" ].(map [string ]interface {})
121+ if ! ok {
122+ t .Fatal ("expected models.providers config" )
123+ }
124+ google , ok := providers ["google" ].(map [string ]interface {})
125+ if ! ok {
126+ t .Fatal ("expected models.providers.google config" )
127+ }
128+ if google ["baseUrl" ] != "http://cllama:8080/v1" {
129+ t .Fatalf ("expected proxy baseUrl, got %v" , google ["baseUrl" ])
130+ }
131+ if google ["apiKey" ] != "weston:abc123hex" {
132+ t .Fatalf ("expected cllama bearer token, got %v" , google ["apiKey" ])
133+ }
134+ if google ["api" ] != "openai-completions" {
135+ t .Fatalf ("expected google provider behind cllama to use openai-completions, got %v" , google ["api" ])
136+ }
137+ modelEntries , ok := google ["models" ].([]interface {})
138+ if ! ok || len (modelEntries ) != 1 {
139+ t .Fatalf ("expected one google model entry, got %T %v" , google ["models" ], google ["models" ])
140+ }
141+ entry , ok := modelEntries [0 ].(map [string ]interface {})
142+ if ! ok {
143+ t .Fatalf ("expected google model entry object, got %T" , modelEntries [0 ])
144+ }
145+ if entry ["id" ] != "google/gemini-3-flash-preview" {
146+ t .Fatalf ("expected google model id to stay provider-prefixed for cllama, got %v" , entry ["id" ])
147+ }
148+ }
149+
150+ func TestGenerateConfigDirectGoogleKeepsNativeAPI (t * testing.T ) {
151+ rc := & driver.ResolvedClaw {
152+ Models : map [string ]string {"primary" : "google/gemini-3-flash-preview" },
153+ }
154+ data , err := GenerateConfig (rc )
155+ if err != nil {
156+ t .Fatal (err )
157+ }
158+ if got , ok := getPath (data , "models.providers.google.api" ); ok {
159+ t .Fatalf ("expected no models.providers.google config without cllama, got %v" , got )
160+ }
161+ if got , ok := getPath (data , "agents.defaults.model.primary" ); ! ok || got != "google/gemini-3-flash-preview" {
162+ t .Fatalf ("expected direct google model to remain on agents.defaults.model.primary, got %v (present=%v)" , got , ok )
163+ }
164+ }
165+
99166func TestGenerateConfigNoCllamaNoProviderRewrite (t * testing.T ) {
100167 rc := & driver.ResolvedClaw {
101168 Models : map [string ]string {"primary" : "anthropic/claude-sonnet-4" },
0 commit comments