llm

Sends the current prompt to a large language model and returns the model's answer. With functions or mcp set, the model can call tools, and the command runs the tool loop for you.

Fields

FieldTypeDefaultDescription
onErrorcommand blockCommands to run if this command raises an uncaught error.
profilerequiredstringThe LLM profile, which defines the vendor, model and call parameters.
promptdynamic stringThe prompt for this call. Needed only when the agent uses more than one prompt.
functionslist of nameFunctions the LLM may call as tools.
mcplist of stringMCP tools used in this LLM call. Each element should be in the form MCP_NAME.TOOL_NAME.
vendorToolslist of string or integer or number or boolean or list of SafeJsonValue or object of string → SafeJsonValueTools provided by the vendor and executed on the vendor side. Passed unchanged to the LLM provider.
maxToolCallLoopsinteger10The maximum number of tool-calling rounds.
timeoutinteger60LLM timeout in seconds. This timeout applies separately to each call during multi-step tool calling.
outputFormat"default" | "structured""default"'default' or 'structured'. With 'structured', the first tool call is returned as a dict, shaped by the function named in 'functions'.
streamOutputbooleanfalseStreams the LLM's text and image output to the user. Off by default.

Result

By default the result is the model's text answer, as a string. With outputFormat: "structured", the model is expected to answer with a tool call. The result is then a dict of { functionName: arguments }, shaped by the function's declared args. A function call gives typed output without parsing text. With streamOutput: true, the text and any images the model produces are also streamed straight to the user as part of the agent's output.

Tool calling

promptsystem + history + queryLLManswerno tool call · the resulttool callrun the toolyour function or MCPtool resultsRepeats until the LLM answers without a tool call, at most maxToolCallLoops times.A tool error goes back to the LLM with the profile's tool error prompt.
The llm command's tool loop

functions lists the functions of this agent that the model may call. Each function needs a description and typed args, because the model sees those. When the model asks for a call, the function runs with the model's arguments. The function's return value goes back to the model. The loop repeats until the model answers with text or maxToolCallLoops is reached.

mcp lists tools from MCP servers as server.tool, or just server for every tool the server offers. vendorTools passes vendor-defined tools, such as web search, through untouched. The LLM profile caps how many tools one call may carry.

A tool that raises an error is reported to the model as an error, together with the profile's tool error prompt. The model can then correct its arguments or give up gracefully. An ask inside a tool function pauses the agent exactly as anywhere else, and the agent resumes mid-loop when the user answers.

Example

"functions": {
  "runQuery": {
    "description": "Runs a SQL query against the orders database and returns the rows.",
    "args": {
      "sql": { "type": "str", "description": "A read-only SQL query." }
    },
    "commands": {
      "db": { "profile": "orders", "sql": "{ sql }" },
      "return": "{ result }"
    }
  },
  "main": {
    "commands": {
      "prompt": {
        "system": "You answer questions about orders. The table orders has columns id, status, total and customer_email.",
        "user": "{ sys.query }"
      },
      "llm": {
        "profile": "gpt5_mini",
        "functions": ["runQuery"],
        "streamOutput": true
      }
    }
  }
}

Rules

  • profile is the literal name of an LLM profile. To pick a profile at runtime, branch with if.
  • The token ceiling, retries, headers and any extra request parameters come from the profile.
  • An agent's run is stopped once the run's LLM spend passes the max LLM cost per run in Runtime limits.
  • end is best avoided inside a tool function. A tool must return to the model.