Skip to main content

Overview

The Grok agent wraps the xAI Grok CLI via GrokAgentModel. Configure it through Spring properties under agent-client.grok.*.

Configuration Properties

Prefix: agent-client.grok

permissionMode and Mode Interaction

The portable isAutoApprove() maps to bypassPermissions, the only mode that grants every tool call without a prompt.

Portable Option Mapping

System instructions are prepended, not passed as a flag

Grok has --system-prompt-override, but it replaces the CLI’s own system prompt rather than adding to it, which strips the agent’s tool instructions. Portable systemInstructions mean “also tell it this”, so they are prepended to the goal — the same choice every other provider here makes.

Result Metadata

Grok returns a JSON envelope in headless mode, so nothing is scraped from log text. AgentResponseMetadata.getProviderFields() carries: getModel() reports the model that actually ran (from the envelope’s modelUsage key), which may differ from the requested slug when the CLI expands an alias. getSessionId() carries the session UUID.

Sessions

Grok accepts a caller-supplied session UUID (--session-id) for a new conversation and resumes with --resume <id>, so the id never has to be recovered from output. GrokClient.resume(sessionId, prompt, options) exposes this. Grok does not currently implement AgentSessionRegistry.
grok models reports “You are not authenticated” even on an authenticated install. The provider’s health check therefore uses grok --version; using models would reject a working CLI.

Availability

Since 0.28.0.

Installation

Install the CLI from grok.com/cli and authenticate once with grok login. The provider discovers the executable via GROK_CLI_PATH, then which grok, then ~/.local/bin/grok and ~/.grok/bin/grok.