eyaltoledano/claude-task-master · error · APICallError
Grok CLI failed with exit code ${result.exitCode}: ${result.
Error message
Grok CLI failed with exit code ${result.exitCode}: ${result.stderr || 'Unknown error'} What it means
This is the generic failure path for a nonzero Grok CLI exit that is NOT an authentication problem. doGenerate throws an API-call error including the exit code, stderr, stdout, and a 200-char prompt excerpt, marked non-retryable. It means the CLI itself ran and failed — bad request, quota, network error inside the CLI, or invalid arguments.
Source
Thrown at packages/ai-sdk-provider-grok-cli/src/grok-cli-language-model.ts:315
if (this.settings.workingDirectory) {
args.push('--directory', this.settings.workingDirectory);
}
try {
const result = await this.executeGrokCli(args, { apiKey });
if (result.exitCode !== 0) {
// Handle authentication errors
if (
result.stderr.toLowerCase().includes('unauthorized') ||
result.stderr.toLowerCase().includes('authentication')
) {
throw createAuthenticationError({
message: `Grok CLI authentication failed: ${result.stderr}`
});
}
throw createAPICallError({
message: `Grok CLI failed with exit code ${result.exitCode}: ${result.stderr || 'Unknown error'}`,
exitCode: result.exitCode,
stderr: result.stderr,
stdout: result.stdout,
promptExcerpt: prompt.substring(0, 200),
isRetryable: false
});
}
// Parse response
const response = convertFromGrokCliResponse(result.stdout);
let text = response.text || '';
// Extract JSON if in object-json mode
const isObjectJson = (
o: unknown
): o is { mode: { type: 'object-json' } } =>
!!o &&View on GitHub (pinned to c0c98d367c)
Solutions
- Read stderr/exitCode in the error payload to identify the root cause (quota, bad request, crash).
- Update the CLI: npm update -g @vibe-kit/grok-cli and retry, since older versions break against API changes.
- Check rate limits/quota on your Grok account and back off before retrying.
- Reproduce manually: run the same prompt through the `grok` CLI directly to see the raw error.
- Verify network/proxy configuration allows the CLI to reach the Grok API.
Example fix
// before (shell) npm list -g @vibe-kit/grok-cli // outdated version, exit code 1 // after (shell) npm update -g @vibe-kit/grok-cli && node app.js
Defensive patterns
Strategy: try-catch
Type guard
function isGrokApiCallError(e) {
return e instanceof Error && /Grok CLI failed with exit code/.test(e.message);
} Try / catch
try {
const result = await model.doGenerate({ prompt });
} catch (e) {
if (isGrokApiCallError(e)) {
console.error(`Grok CLI exited ${e.exitCode ?? '?'}: ${e.stderr ?? e.message}`);
// inspect stderr: quota -> backoff; bad request -> fix prompt/CLI version
} else throw e;
} Prevention
- Keep @vibe-kit/grok-cli updated; old versions break against API changes.
- Implement exponential backoff for rate-limit-shaped stderr messages only.
- Test prompts directly against the `grok` CLI before wiring them into automation.
- Monitor stderr in logs to detect quota exhaustion early.
When it happens
Trigger: doGenerate spawns the Grok CLI, which exits nonzero with stderr not containing 'unauthorized'/'authentication' — e.g. rate limits, malformed prompt/flags, CLI crash, network failure within the CLI.
Common situations: Exhausted Grok rate limits or quota; passing prompts the CLI rejects; outdated CLI version incompatible with current API; network/proxy restrictions in corporate environments; prompt content triggering provider-side refusals.
Related errors
- Grok CLI authentication failed: ${result.stderr}
- Grok CLI execution failed: ${(error as Error).message}
- Command failed with exit code ${result.status}: ${errorOutpu
- Grok CLI is not installed or not found in PATH. Please insta
- Grok CLI API key not found. Set GROK_CLI_API_KEY environment
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/2ac20d2dc94e5bc4.
Report an issue: GitHub.