grok_agent
Executes tasks with a schema-enforced reflection loop that retries corrections against a strict cost budget, using Grok models.
Instructions
Unified @grok Entry Point: run the thinking route — the ReAct AgentLoop wrapped in a schema-enforced reflection loop — with explicit retry and budget caps.
Args:
prompt: Task or question for the agent.
session: Optional session name for persistent history in chats.
model: Grok model id (default grok-4.3).
system_prompt: Optional system instruction prepended to the conversation.
max_iterations: Strict cap on reviewer-driven correction retries (default 5).
cost_limit: Total budget in USD before hard abort (default 0.50).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | grok-4.3 | |
| prompt | Yes | ||
| session | No | ||
| cost_limit | No | ||
| system_prompt | No | ||
| max_iterations | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| why | No | Router decision trace (Grok-native). | auto |
| text | No | Human-formatted output (includes footers, citations, cost summary). | |
| model | Yes | Actual executing model ID (e.g. 'grok-4.5'). | |
| plane | No | API | |
| route | Yes | High-level route (fast/agentic/research/etc.). | |
| trace | No | Multi-agent step trace (for grok_agent research mode). | |
| tokens | No | Total tokens consumed. | |
| profile | No | Internal routing profile. | |
| cost_usd | No | Exact USD cost from xAI billing metadata. | |
| degraded | No | True if fallback occurred. | |
| response | Yes | Raw model output or primary content. | |
| citations | No | Native xAI/X citations with URL + snippet. | |
| latency_sec | No | ||
| finish_reason | No | unknown | |
| reasoning_effort | No | Grok 4.5+ native reasoning level. |