@@ -196,6 +196,57 @@ func TestXAIExecutorOmitsUnsupportedReasoningEffort(t *testing.T) {
196196 }
197197}
198198
199+ func TestXAIExecutorUsesLargeContextModelForGrokBuildCompaction (t * testing.T ) {
200+ exec := NewXAIExecutor (& config.Config {})
201+ req := cliproxyexecutor.Request {
202+ Model : "grok-build-0.1" ,
203+ Payload : []byte (`{"model":"grok-build-0.1","input":"hello"}` ),
204+ }
205+
206+ for _ , opts := range []cliproxyexecutor.Options {
207+ {
208+ SourceFormat : sdktranslator .FormatOpenAIResponse ,
209+ Alt : "responses/compact" ,
210+ },
211+ {
212+ SourceFormat : sdktranslator .FormatOpenAIResponse ,
213+ Headers : http.Header {
214+ "X-Codex-Turn-Metadata" : []string {`{"request_kind":"compaction","compaction":{"trigger":"auto","reason":"context_limit"}}` },
215+ },
216+ },
217+ } {
218+ prepared , err := exec .prepareResponsesRequest (context .Background (), req , opts , true )
219+ if err != nil {
220+ t .Fatalf ("prepareResponsesRequest() error = %v" , err )
221+ }
222+ if prepared .baseModel != "grok-4.3" {
223+ t .Fatalf ("baseModel = %q, want grok-4.3" , prepared .baseModel )
224+ }
225+ if got := gjson .GetBytes (prepared .body , "model" ).String (); got != "grok-4.3" {
226+ t .Fatalf ("body model = %q, want grok-4.3; body=%s" , got , string (prepared .body ))
227+ }
228+ }
229+ }
230+
231+ func TestXAIExecutorKeepsGrokBuildModelForNormalRequests (t * testing.T ) {
232+ exec := NewXAIExecutor (& config.Config {})
233+ prepared , err := exec .prepareResponsesRequest (context .Background (), cliproxyexecutor.Request {
234+ Model : "grok-build-0.1" ,
235+ Payload : []byte (`{"model":"grok-build-0.1","input":"hello"}` ),
236+ }, cliproxyexecutor.Options {
237+ SourceFormat : sdktranslator .FormatOpenAIResponse ,
238+ }, true )
239+ if err != nil {
240+ t .Fatalf ("prepareResponsesRequest() error = %v" , err )
241+ }
242+ if prepared .baseModel != "grok-build-0.1" {
243+ t .Fatalf ("baseModel = %q, want grok-build-0.1" , prepared .baseModel )
244+ }
245+ if got := gjson .GetBytes (prepared .body , "model" ).String (); got != "grok-build-0.1" {
246+ t .Fatalf ("body model = %q, want grok-build-0.1; body=%s" , got , string (prepared .body ))
247+ }
248+ }
249+
199250func TestXAIExecutorAppliesThinkingSuffix (t * testing.T ) {
200251 var gotBody []byte
201252 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
0 commit comments