Skip to content

Commit 4eec0f2

Browse files
author
jack
committed
Add Grok model context limits (131K tokens)
- Added 'grok' pattern to MODEL_SPECIFIC_LIMITS with 131_072 token limit - This fixes the issue where CLI was showing 0/32000 tokens for Grok models - All Grok models (grok-3, grok-3-mini, etc) now correctly show 0/131072 tokens - Added debug logging to xAI provider for better troubleshooting
1 parent 30dbcba commit 4eec0f2

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

.goose/memory/project improvement ideas.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,24 @@ Successfully added xAI provider support for Grok models to Goose:
2424
**Branch:** feature/add-grok-models
2525
**Commit:** ff54e6d576
2626

27+
# ["xai", "fix", "endpoint", "url", "api"]
28+
Fixed critical issue with xAI provider endpoint URL:
29+
30+
**Problem:**
31+
Getting 404 error when using xAI provider because of incorrect API endpoint construction.
32+
33+
**Root Cause:**
34+
The code was constructing URL as: `https://api.x.ai` + `v1/chat/completions` = `https://api.x.ai/v1/chat/completions`
35+
But x.ai API documentation shows the base URL should be `https://api.x.ai/v1` and then append `chat/completions`.
36+
37+
**Solution:**
38+
1. Changed `XAI_API_HOST` from `"https://api.x.ai"` to `"https://api.x.ai/v1"`
39+
2. Updated URL joining to append `"chat/completions"` instead of `"v1/chat/completions"`
40+
3. Updated UI provider registry default host to match
41+
4. Tested with curl - now returns proper 400 auth error instead of 404
42+
43+
**Additional Issue Found:**
44+
User had `GOOSE_LEAD_MODEL: claude-opus-4-20250514` in config which was triggering lead/worker mode. This model doesn't exist, causing cascade failures. Recommend removing or updating to valid model.
45+
46+
**Status:** Fixed and committed (commit 30dbcba3e4)
47+

crates/goose/src/model.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ static MODEL_SPECIFIC_LIMITS: Lazy<HashMap<&'static str, usize>> = Lazy::new(||
3030
// Meta Llama models, https://github.com/meta-llama/llama-models/tree/main?tab=readme-ov-file#llama-models-1
3131
map.insert("llama3.2", 128_000);
3232
map.insert("llama3.3", 128_000);
33+
34+
// x.ai Grok models, https://docs.x.ai/docs/overview
35+
map.insert("grok", 131_072);
3336
map
3437
});
3538

crates/goose/src/providers/xai.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ impl XaiProvider {
7979
ProviderError::RequestFailed(format!("Failed to construct endpoint URL: {e}"))
8080
})?;
8181

82+
tracing::debug!("xAI API URL: {}", url);
83+
tracing::debug!("xAI request model: {:?}", self.model.model_name);
84+
8285
let response = self
8386
.client
8487
.post(url)

0 commit comments

Comments
 (0)