Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/api/server_grok_models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestModelsDispatchByGrokShellUserAgent(t *testing.T) {
modelRegistry := registry.GetGlobalRegistry()
clientID := "test-grok-shell-model-list"
modelRegistry.RegisterClient(clientID, "openai", []*registry.ModelInfo{
{ID: "grok-shell-openai-model", DisplayName: "Grok Shell Model", ContextLength: 256000, Thinking: &registry.ThinkingSupport{Levels: []string{"high"}}},
{ID: "grok-shell-openai-model", DisplayName: "Grok Shell Model", ContextLength: 256000, Thinking: &registry.ThinkingSupport{Levels: []string{"high", "xhigh"}}},
})
modelRegistry.RegisterClient(clientID+"-claude", "claude", []*registry.ModelInfo{
{ID: "grok-shell-claude-model", DisplayName: "Claude Catalog Model", ContextLength: 200000},
Expand Down Expand Up @@ -53,6 +53,7 @@ func TestModelsDispatchByGrokShellUserAgent(t *testing.T) {
SupportedInAPI bool `json:"supported_in_api"`
ReasoningEfforts []struct {
Value string `json:"value"`
Label string `json:"label"`
} `json:"reasoning_efforts"`
} `json:"data"`
}
Expand All @@ -73,9 +74,12 @@ func TestModelsDispatchByGrokShellUserAgent(t *testing.T) {
if model.APIBackend != "responses" || !model.SupportedInAPI {
t.Fatalf("OpenAI model routing fields = %#v", model)
}
if len(model.ReasoningEfforts) != 1 || model.ReasoningEfforts[0].Value != "high" {
if len(model.ReasoningEfforts) != 2 || model.ReasoningEfforts[0].Value != "high" || model.ReasoningEfforts[1].Value != "xhigh" {
t.Fatalf("OpenAI reasoning efforts = %#v", model.ReasoningEfforts)
}
if got := model.ReasoningEfforts[1].Label; got != "Extra High" {
t.Fatalf("xhigh label = %q, want Extra High", got)
}
case "grok-shell-claude-model":
foundClaude = true
if model.Model != model.ID || model.Name != "Claude Catalog Model" || model.ContextWindow != 200000 {
Expand Down
12 changes: 9 additions & 3 deletions internal/client/grokbuild/grokbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ModelInfo struct {
// ReasoningEffort represents reasoning effort level in Grok Shell model entries.
type ReasoningEffort struct {
Value string `json:"value"`
Label string `json:"label,omitempty"`
}

// ModelEntry represents a single model entry formatted for Grok Shell.
Expand Down Expand Up @@ -49,10 +50,15 @@ func BuildResponse(models []ModelInfo) Response {

var efforts []ReasoningEffort
for _, level := range m.ReasoningLevels {
trimmed := strings.TrimSpace(level)
if trimmed != "" {
efforts = append(efforts, ReasoningEffort{Value: trimmed})
value := strings.TrimSpace(level)
if value == "" {
continue
}
effort := ReasoningEffort{Value: value}
if value == "xhigh" {
effort.Label = "Extra High"
}
efforts = append(efforts, effort)
}

entry := ModelEntry{
Expand Down