Skip to main content
Glama

grok_agent

Run a Grok agent that combines web and X search, code execution, image generation, and file or image analysis to answer complex prompts in a single call.

Instructions

All-in-one Grok agent combining files, vision, web/X search, code execution, and image generation.

Enable any subset of tools and attach any mix of uploaded files and images.
The agent decides which tools to use per turn. Supports optional local
session history and multi-agent research via `agent_count`.

Args:
    prompt: Task or question for the agent.
    session: Optional session name for persistent history in `chats/{session}.json`.
    model: Grok model driving the agent (default `grok-4.6`).
    file_ids: IDs of previously uploaded files to attach as context.
    image_urls: Public image URLs to attach.
    image_paths: Local image files to attach (sent as base64 data URIs).
    use_web_search: Enable the agentic web search tool.
    use_x_search: Enable the agentic X (Twitter) search tool.
    use_code_execution: Enable the Python code execution tool.
    use_image_generation: Enable the server-side image generation tool, letting the agent
        create and edit images mid-conversation. Images are saved under `images/`.
    image_generation_action: Which image capabilities to expose: `"auto"` (default, generate
        and edit), `"generate"` (text-to-image only), or `"edit"` (editing only).
    allowed_domains: Web search allow-list (max 5, mutually exclusive with excluded).
    excluded_domains: Web search deny-list (max 5).
    allowed_x_handles: X search handle allow-list (max 10, mutually exclusive with excluded).
    excluded_x_handles: X search handle deny-list (max 10).
    from_date: X search inclusive start date as `DD-MM-YYYY`.
    to_date: X search inclusive end date as `DD-MM-YYYY`.
    enable_image_understanding: Let search tools analyze images they encounter.
    enable_video_understanding: Let X search analyze videos in posts.
    enable_image_search: Let web search find and return image results.
    include_inline_citations: Embed `[1]`-style citation markers into the answer.
    system_prompt: Optional system instruction prepended to the conversation.
    max_turns: Cap the agent's reasoning/tool turns.
    agent_count: 4 or 16. Only valid with `grok-4.20-multi-agent`.
    service_tier: `"default"` or `"priority"`. Priority is processed faster at a higher token price.
    guidelines: Moderation settings like `{"violence": "decline"}`. Categories are `nsfw`,
        `violence` and `profanity`. Doesn't work with multi-agent models.
    show_usage: Append a token usage and cost footer to the answer (default False).

Returns:
    Markdown with the answer body, then a `**Generated Images:**` list of saved file paths
    when the agent produced images, then a `**Sources:**` list when citations exist.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "prompt": "<prompt>"
    },
    "name": "grok_agent"
  }
}

Input Schema

NameRequiredDescriptionDefault
modelNogrok-4.6
promptYes
sessionNo
to_dateNo
file_idsNo
from_dateNo
max_turnsNo
guidelinesNo
image_urlsNo
show_usageNo
agent_countNo
image_pathsNo
service_tierNo
use_x_searchNo
system_promptNo
use_web_searchNo
allowed_domainsNo
excluded_domainsNo
allowed_x_handlesNo
excluded_x_handlesNo
use_code_executionNo
enable_image_searchNo
use_image_generationNo
image_generation_actionNo
include_inline_citationsNo
enable_image_understandingNo
enable_video_understandingNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / guidelines
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": {
      +        "type": "string"
      +      },
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Guidelines"
      +}
  2. Addedv1.0.4
  3. Removed
  4. Changed1 schema field changedv1.0.1
    • addedInput schema / properties / show_usage
      Added value: +{
      +  "default": false,
      +  "title": "Show Usage",
      +  "type": "boolean"
      +}
  5. Changed1 schema field changed
    • addedInput schema / properties / enable_image_search
      Added value: +{
      +  "default": false,
      +  "title": "Enable Image Search",
      +  "type": "boolean"
      +}
  6. Added
  7. Removed
  8. Added
  9. Removed
  10. Changed1 schema field changed
    • addedInput schema / properties / agent_count
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Agent Count"
      +}
  11. Added
  12. Removed
  13. Changed1 schema field changed
    • changedInput schema / properties / model / default
      Previous value: -"grok-4-1-fast"New value: +"grok-4-1-fast-reasoning"
  14. Changed1 schema field changed
    • addedInput schema / properties / session
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "title": "Session"
      +}
  15. Added

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations at all, the description carries the full burden and largely meets it: it discloses side effects (session history persisted to `chats/{session}.json`, generated images written under `images/`), cost implications (`service_tier` priority is faster at a higher token price), and the exact output structure via a Returns section. This is substantially more than a restatement of the parameters.

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

Conciseness4/5

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

Length is proportional to 27 parameters, the summary leads, and the Args/Returns structure makes it scannable. A few entries merely restate the parameter name (e.g. `use_web_search`, `use_x_search`), and defaults are omitted for parameters like `max_turns` and `agent_count`, but there is no padding.

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

Completeness4/5

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

For a high-complexity, unannotated, no-output-schema tool, the definition covers capabilities, side effects, parameter constraints, and return format — the things an agent needs to call it correctly. Gaps are minor: no error/failure behavior, no guidance on what happens if a session name is reused, and several defaults are unstated.

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

Parameters5/5

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

Schema description coverage is 0% across 27 parameters, so the description must compensate entirely, and it does — it documents every parameter with meaning, enum values (`image_generation_action` auto/generate/edit, `service_tier` default/priority, `agent_count` 4 or 16), list caps (max 5 domains, max 10 handles), formats, defaults, and mutual exclusivity. This is exactly the compensation the dimension rewards.

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

Purpose4/5

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

The opening line names a specific resource (a Grok agent) and enumerates its capabilities — files, vision, web/X search, code execution, image generation — with the key behavioral point that 'the agent decides which tools to use per turn.' That implicitly separates it from narrow siblings like web_search or generate_image, but it never explicitly says when a dedicated sibling is preferable, so it stops short of a 5.

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

Usage Guidelines3/5

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

There is real constraint guidance — `agent_count` is only valid with `grok-4.20-multi-agent`, allow-lists and deny-lists are mutually exclusive, dates use `DD-MM-YYYY`, and `guidelines` doesn't work with multi-agent models. However, it gives no when-to-use framing relative to `chat`, `code_executor`, `web_search`, or `generate_image`, which is the main decision an agent faces.

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