Skip to main content
Glama

code_executor

Solve computational, data, or analysis tasks by letting Grok write and run Python iteratively in a stateful sandbox to produce numeric answers and execution output.

Instructions

Solve a task by letting Grok run Python in a stateful sandbox.

The agent iteratively writes and executes Python (with common scientific
libraries) to arrive at a numeric, data, or analysis answer.

Args:
    prompt: Task or question requiring computation.
    model: Grok model driving the agent (default `grok-4.6`).
    max_turns: Cap the number of reasoning/execution turns.
    show_usage: Append a token usage and cost footer to the answer (default False).

Returns:
    Markdown with the final answer followed by each code execution block's stdout.

Input Schema

NameRequiredDescriptionDefault
modelNogrok-4.6
promptYes
max_turnsNo
show_usageNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.4
  2. Removed
  3. Changed1 schema field changedv1.0.1
    • addedInput schema / properties / show_usage
      Added value: +{
      +  "default": false,
      +  "title": "Show Usage",
      +  "type": "boolean"
      +}
  4. Added
  5. Removed
  6. Added
  7. Removed
  8. Added
  9. Removed
  10. Changed1 schema field changed
    • changedInput schema / properties / model / default
      Previous value: -"grok-4-1-fast"New value: +"grok-4-1-fast-reasoning"
  11. Changed1 schema field changed
    • removedInput schema / properties / include_code_output
      Removed value: -{
      -  "default": true,
      -  "title": "Include Code Output",
      -  "type": "boolean"
      -}
  12. Added

TDQS

A3.6/5.0
Behavior3/5

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

With no annotations, the description carries the full burden, and it does disclose meaningful traits: statefulness of the sandbox, iterative write/execute behavior, common scientific libraries, and the Markdown return shape with stdout blocks. It omits execution limits, sandbox lifetime/persistence scope, timeout behavior, and any network or side-effect constraints, which matters for a tool that runs arbitrary code.

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?

Front-loaded with the core purpose, then structured Args/Returns sections that map directly to the schema. Slightly verbose in restating the return format, but every element is informative and there is no filler.

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?

There is no output schema and no annotations, so the description must cover both the argument contract and the return value — which it does via the Args and Returns sections. For a 4-parameter tool this is largely sufficient; missing operational limits (timeouts, sandbox persistence) are the only notable gap.

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

Parameters4/5

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

Schema description coverage is 0% and the schema provides only titles, so the description must compensate — and it does, documenting all four parameters with meaning and defaults: prompt purpose, the driving model, what max_turns caps, and that show_usage appends a token/cost footer. Only minor gaps remain (e.g., model value options, max_turns default).

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 first sentence gives a specific verb and resource: 'Solve a task by letting Grok run Python in a stateful sandbox,' which clearly identifies this as a sandboxed code-execution tool distinct from chat/search siblings. It does not explicitly name an alternative sibling (e.g., grok_agent), so differentiation is implied rather than stated.

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?

Usage is implied by 'Task or question requiring computation' and 'numeric, data, or analysis answer,' which tells the agent the kind of request that fits. However, there is no explicit when-to-use guidance versus alternatives like grok_agent, chat, or web_search, and no stated exclusions.

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