Skip to main content
Glama

grok_request_async

Destructive

Start xAI Grok CLI requests as durable background jobs. Poll job status and retrieve results via dedicated endpoints to avoid blocking your workflow.

Instructions

Start an xAI Grok CLI request as a durable background job. Poll with llm_job_status, collect with llm_job_result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
denyNoGrok --deny <RULE>: permission deny rules. Each entry → its own --deny instance.
agentNoGrok --agent <NAME>: agent name or definition file path.
allowNoGrok --allow <RULE>: permission allow rules. Each entry → its own --allow instance.
checkNoGrok --check: append a self-verification loop to the prompt (headless only). Not advertised by grok 1.0.4+; passed through for older installs.
modelNoModel name or alias (e.g. grok-4.5, latest)
oauthNoGrok --oauth: use OAuth during authentication.
rulesNoGrok --rules <RULES>: extra rules to append to the system prompt. Supports `@file` prefix; gateway passes the value verbatim.
agentsNoGrok --agents <JSON>: inline subagent definitions (JSON string or name → { description, prompt, … } map).
effortNoGrok effort level. Known values: low, medium, high, xhigh, max. Your installed grok decides what it accepts; these are not enforced.
noPlanNoGrok --no-plan: disable plan mode.
promptNoPrompt text for Grok (mutually exclusive with promptParts)
bestOfNNoGrok --best-of-n <N>: run the task N ways in parallel and pick the best (headless only). Not advertised by grok 1.0.4+; passed through for older installs.
sandboxNoGrok --sandbox <PROFILE>: sandbox profile for filesystem and network access. Freeform per `grok --help` (no enum constraint); also settable via GROK_SANDBOX env var.
maxTurnsNoGrok `--max-turns N`: cap on agent-loop iterations for cost / latency control (Phase 4 slice δ). Bounded to safe integers ≤ 10000.
noMemoryNoGrok --no-memory: disable cross-session memory.
todoGateNoGrok --todo-gate: enable runtime turn-end TodoGate for this session (session-scoped, not persisted).
verbatimNoGrok --verbatim: send the prompt exactly as given. Also skips gateway optimizePrompt when true.
worktreeNoSlice λ: run this request inside a dedicated git worktree owned by the gateway. `true` creates a fresh worktree at `<repoRoot>/.worktrees/<uuid>` branched from HEAD. `{ name?, ref? }` lets the caller supply a sanitized name and/or a git ref (default: HEAD). When the request carries a sessionId and the session already has a worktree, reuse requires same-host ownership metadata and a matching live Git registration. Named path collisions never reuse manager state. Gateway-managed worktrees work with file-backed and PostgreSQL session managers. Shared PostgreSQL rows do not transfer filesystem ownership; reuse and cleanup remain limited to the owning host. The Grok, Devin, and Mistral adapters require an explicit provider-native sessionId; fresh, createNewSession, and resumeLatest-only worktree requests fail closed because they cannot durably reselect the worktree. The request must select a registered workspace explicitly, through caller-owned session metadata, or through the configured default. Worktrees never fall back to the gateway process cwd and cannot be combined with local workingDir, addDir, or includeDirs paths. The gateway spawns the child CLI with `cwd: <worktree-path>`; no `-w`/`--worktree` flag is ever emitted to the underlying CLI. On worktree materialization, the gateway suppresses repository, system, and global Git hooks and configured clean, smudge, and process checkout filters, sparse checkout, and lazy object fetching. Filter-dependent content such as Git LFS remains in its repository representation instead of executing host commands. On session_delete, session_clear_all or file-backed TTL eviction, both managers hide a durably owned worktree session while cleanup runs. Failed Git removal retains a cleanup-pending tombstone, blocks reuse, and is retried when a manager is registered on the owning host; the record is finalized only once Git no longer registers the worktree, which is read back rather than inferred from the recorded path being absent. A worktree that moved, or whose owner marker cannot be read, is not a removal. Deletion processed by another host removes no worktree and leaves the owning host's record intact. The database-side cleanup_expired_sessions function stages the same tombstone instead of deleting a worktree-bearing session; it invokes no gateway observer and so attempts no removal itself. A tombstone is not bounded by retention. Successful responses are prefixed with `[gateway] worktree=<absolute-path>\n` so callers can use the path. For Claude approvalStrategy:mcp_managed, requesting or reusing a worktree requires approval and LLM_GATEWAY_APPROVAL_ALLOW_BYPASS=1. Other adapters reject mcp_managed before launch. NOTE: callers should `.gitignore` the `.worktrees/` directory in their repo (the gateway does NOT auto-gitignore; see slice λ spec Q4).
sessionIdNoProvider-native session ID to resume (emits --resume <id>; use resumeLatest for --continue). Note: the gw-* id minted for a brand-new session is not resumable via sessionId; continue with resumeLatest:true.
workspaceNoRegistered workspace alias for remote HTTP/OAuth provider calls. Do not use this field, workspace_list, or workspace_register_existing_repo as a fallback for stdio/local provider path access; pass workingDir/addDir/includeDirs directly instead.
jsonSchemaNoGrok 0.2.73 --json-schema: constrain output to a JSON Schema (string literal or object; implies json output). Set outputFormat:json so the gateway treats the reply as structured output (skips response optimization and warning injection); the default output format is not json, so pass it explicitly.
mcpServersNoThis provider does not receive gateway-managed MCP configuration. mcpServers has no effect with legacy, and mcp_managed is rejected before launch because ambient MCP configuration cannot be isolated.
promptFileNoGrok --prompt-file <PATH>: single-turn prompt loaded from a file.
promptJsonNoGrok --prompt-json <JSON>: single-turn prompt JSON blocks (string or serializable value).
workingDirNoGrok --cwd <DIR>: working directory for this invocation. Lets headless callers run Grok against a directory other than the gateway process's cwd. Stdio/local callers may pass local paths directly. Remote HTTP/OAuth callers must use relative paths inside a selected registered workspace. Do not call workspace_* tools to fix stdio/local provider path access.
forkSessionNoGrok 0.2.73 --fork-session: when resuming (--resume/--continue), fork into a new session ID instead of reusing the original.
noAltScreenNoGrok --no-alt-screen: run inline without alt screen.
noSubagentsNoGrok --no-subagents: disable subagent spawning.
promptPartsNoCache-aware structured prompt: { system?, tools?, context?, task }. Mutually exclusive with prompt. Stable parts hash into cache_state for prefix-discipline tracking.
restoreCodeNoGrok --restore-code: check out the original session commit when resuming.
worktreeRefNoGrok 0.2.73 --worktree-ref <REF>: git ref (branch/tag/commit) to base the native worktree on. Requires nativeWorktree.
allowedToolsNoAllowed built-in tools (passed as --tools comma list)
forceRefreshNoBypass dedup and force a fresh CLI run even if a recent identical request exists
leaderSocketNoGrok 0.2.32+ --leader-socket <PATH>: custom leader socket path (default ~/.grok/leader.sock). Targets an isolated leader process, e.g. a local/branch Grok build; name it ~/.grok/leader-*.sock to keep `grok leader list/kill` discovery working.
outputFormatNoOutput format for headless mode. Grok default is plain. The gateway parses json and streaming-json; other formats are passed through as raw output.
resumeLatestNoResume most recent Grok session in cwd (--continue). Note: the gw-* id minted for a brand-new session is not resumable via sessionId; continue with resumeLatest:true.
alwaysApproveNoAuto-approve all tool executions (--always-approve).
correlationIdNoRequest trace ID (auto if omitted)
idleTimeoutMsNoIdle timeout in ms (min 30s, max 1h). Omit = gateway default of 600000ms (10 min) with no output before the process is killed.
providerFlagsNoFlags passed to the provider binary verbatim, keyed exactly as the binary spells them (e.g. {"--best-of-n": "3", "--verbatim": true, "--rules": ["a", "b"]}). Use this for any flag your installed CLI accepts that this schema does not name: the binary decides what it supports, not the gateway. true emits the flag alone; a list REPEATS the flag once per item (pass a joined string if your CLI wants a comma-separated value). Values may not start with '-', and a flag the gateway is already emitting for this request is refused rather than duplicated. LOCAL stdio callers only: remote HTTP/OAuth callers are refused every flag here and should use this tool's declared parameters, which carry their own host-path and approval gates.
approvalPolicyNoapprovalPolicy is unavailable for this provider. It has no effect with legacy, and mcp_managed is rejected before launch because ambient MCP configuration cannot be isolated.
compactionModeNoGrok --compaction-mode: summary (default) | transcript | segments. Sets GROK_COMPACTION_MODE.
nativeWorktreeNoGrok -w/--worktree: native CLI worktree flag (`true` → bare `--worktree`, string → named). NOT gateway slice λ `worktree`.
optimizePromptNoOptimize prompt before execution
permissionModeNoGrok permission mode: default|acceptEdits|auto|dontAsk|bypassPermissions|plan.
disallowedToolsNoDisallowed built-in tools (passed as --disallowed-tools comma list)
reasoningEffortNoReasoning effort for reasoning models. Known values: low, medium, high, xhigh, max. Not enforced; the installed binary decides.
approvalStrategyNoApproval strategy: legacy is supported. mcp_managed is rejected before launch because this adapter cannot isolate ambient MCP configuration.legacy
compactionDetailNoGrok --compaction-detail: segment verbatim detail (none|minimal|balanced|verbose, default verbose). Only affects segments mode. Sets GROK_COMPACTION_DETAIL.
compressResponseNoCompress the response display text when collected via llm_job_result (native compressor; default: [compression].enabled).
createNewSessionNoForce new session
disableWebSearchNoGrok --disable-web-search: disable web search and remote retrieval tools.
experimentalMemoryNoGrok --experimental-memory: enable cross-session memory.
systemPromptOverrideNoGrok --system-prompt-override <PROMPT>: replace the agent's system prompt entirely.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv3.2.1
    • changedInput schema / properties / worktree / description
      Previous value: -"Slice λ: run this request inside a dedicated git worktree owned by the gateway. `true` creates a fresh worktree at `<repoRoot>/.worktrees/<uuid>` branched from HEAD. `{ name?, ref? }` lets the caller supply a sanitized name and/or a git ref (default: HEAD). When the request carries a sessionId and the session already has a worktree, reuse requires same-host ownership metadata and a matching live Git registration. Named path collisions never reuse manager state. Gateway-managed worktrees require the local file-backed session manager and fail closed with PostgreSQL sessions. The Grok, Devin, and Mistral adapters require an explicit provider-native sessionId; fresh, createNewSession, and resumeLatest-only worktree requests fail closed because they cannot durably reselect the worktree. The request must select a registered workspace explicitly, through caller-owned session metadata, or through the configured default. Worktrees never fall back to the gateway process cwd and cannot be combined with local workingDir, addDir, or includeDirs paths. The gateway spawns the child CLI with `cwd: <worktree-path>`; no `-w`/`--worktree` flag is ever emitted to the underlying CLI. On worktree materialization, the gateway suppresses repository, system, and global Git hooks and configured clean, smudge, and process checkout filters, sparse checkout, and lazy object fetching. Filter-dependent content such as Git LFS remains in its repository representation instead of executing host commands. On session_delete or TTL eviction the gateway hides the session and runs `git worktree remove --force`. Failed removal retains a durable cleanup-pending tombstone which blocks reuse and is retried when the file store is registered on the owning host. The tombstone is finalized only after verified Git removal. Successful responses are prefixed with `[gateway] worktree=<absolute-path>\\n` so callers can use the path. For Claude approvalStrategy:mcp_managed, requesting or reusing a worktree requires approval and LLM_GATEWAY_APPROVAL_ALLOW_BYPASS=1. Other adapters reject mcp_managed before launch. NOTE: callers should `.gitignore` the `.worktrees/` directory in their repo (the gateway does NOT auto-gitignore; see slice λ spec Q4)."New value: +"Slice λ: run this request inside a dedicated git worktree owned by the gateway. `true` creates a fresh worktree at `<repoRoot>/.worktrees/<uuid>` branched from HEAD. `{ name?, ref? }` lets the caller supply a sanitized name and/or a git ref (default: HEAD). When the request carries a sessionId and the session already has a worktree, reuse requires same-host ownership metadata and a matching live Git registration. Named path collisions never reuse manager state. Gateway-managed worktrees work with file-backed and PostgreSQL session managers. Shared PostgreSQL rows do not transfer filesystem ownership; reuse and cleanup remain limited to the owning host. The Grok, Devin, and Mistral adapters require an explicit provider-native sessionId; fresh, createNewSession, and resumeLatest-only worktree requests fail closed because they cannot durably reselect the worktree. The request must select a registered workspace explicitly, through caller-owned session metadata, or through the configured default. Worktrees never fall back to the gateway process cwd and cannot be combined with local workingDir, addDir, or includeDirs paths. The gateway spawns the child CLI with `cwd: <worktree-path>`; no `-w`/`--worktree` flag is ever emitted to the underlying CLI. On worktree materialization, the gateway suppresses repository, system, and global Git hooks and configured clean, smudge, and process checkout filters, sparse checkout, and lazy object fetching. Filter-dependent content such as Git LFS remains in its repository representation instead of executing host commands. On session_delete, session_clear_all or file-backed TTL eviction, both managers hide a durably owned worktree session while cleanup runs. Failed Git removal retains a cleanup-pending tombstone, blocks reuse, and is retried when a manager is registered on the owning host; the record is finalized only once Git no longer registers the worktree, which is read back rather than inferred from the recorded path being absent. A worktree that moved, or whose owner marker cannot be read, is not a removal. Deletion processed by another host removes no worktree and leaves the owning host's record intact. The database-side cleanup_expired_sessions function stages the same tombstone instead of deleting a worktree-bearing session; it invokes no gateway observer and so attempts no removal itself. A tombstone is not bounded by retention. Successful responses are prefixed with `[gateway] worktree=<absolute-path>\\n` so callers can use the path. For Claude approvalStrategy:mcp_managed, requesting or reusing a worktree requires approval and LLM_GATEWAY_APPROVAL_ALLOW_BYPASS=1. Other adapters reject mcp_managed before launch. NOTE: callers should `.gitignore` the `.worktrees/` directory in their repo (the gateway does NOT auto-gitignore; see slice λ spec Q4)."
  2. Addedv3.2.0
  3. Removedv3.0.0
  4. First observedv2.16.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already carry destructiveHint=true, idempotentHint=false, and readOnlyHint=false, so the mutation/safety profile is declared externally. The description adds the durable-background-job behavior beyond annotations — the call returns something pollable rather than a synchronous answer — which is the key behavior an agent needs. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with zero filler: the scope ('durable background job') is front-loaded, and the retrieval flow follows immediately. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 54-parameter tool with no output schema, the description covers the core lifecycle but omits the return shape (that it yields a pollable job identifier), does not mention cancellation via the sibling llm_job_cancel, and leaves the sync-vs-async decision implicit. The schema mitigates parameter confusion, but an agent must infer key workflow decisions from sibling names.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with rich per-parameter explanations of flags, constraints, and host-path gates, so the schema carries the full semantic load. The description adds no parameter-level detail, which matches the baseline-3 for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a concrete action ('Start an xAI Grok CLI request') and a resource, and characterizes the execution model as a 'durable background job', which clearly differentiates this from the synchronous grok_request sibling. Pointing to llm_job_status and llm_job_result reinforces that this is the non-blocking variant.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives an explicit retrieval workflow ('Poll with llm_job_status, collect with llm_job_result'), which is actionable guidance for what to do after invoking the tool. However, it never explicitly states when to prefer async over the synchronous grok_request sibling or when not to use it, so an exclusion criterion is missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.