Commands

There are 23 commands. Together the commands cover every agentic workflow: variables, flow control, progress, termination, external systems, LLMs, other agents, the user, and output.

Variables

  • varSets variables in function, agent, or conversation scope.

Flow control

  • ifRuns one command block or another, based on a condition.
  • whileLoop that repeats as long as the condition remains true.
  • forIterates over the elements of an iterable.
  • breakBreaks out of the innermost loop when the value is true. Only allowed inside 'for' and 'while'.
  • continueStarts the next iteration of the innermost loop when the value is true. Only allowed inside 'for' and 'while'.
  • funcCalls another function.
  • returnReturns from the current function with this value.
  • parallelRuns several of the agent's functions at the same time.

LLM interaction

  • promptSets the prompt that is sent to the LLM.
  • llmMakes a large language model call.
  • memoryStores and searches a user's long-term memory.

External systems

  • apiCalls a REST API. Other protocols are not supported.
  • dbRuns a relational database query.

Deep agents

  • searchFinds agents matching a query, optionally filtered by tag.
  • invokeRuns another agent and returns its result.

Human-in-the-loop

  • askPauses the agent and asks the user for input.

Agent output

  • outputAdds text, HTML or images to the agent's output.

Agent termination

  • endEnds the agent successfully and adds the value to the output. Agent state is saved.
  • failEnds the agent with a failure message. Agent state is not saved. The value is shown in the UI.

Observability

  • progressSends a progress message to the UI. The message is not part of the agent's output.
  • traceTraces execution. Shown when the agent is validated.
  • logLogs a message on the agent server. A plain string logs to the default logger at info level.

Each command is documented in the Command reference. Each page has a table of the command's fields, generated from the agent schema, and an example.

agenta set of functionsmainrequired · execution starts herecommandcommandcommandfunctionAcommandcommandfunctionBcommandcommandThe commandsVariablesvarFlow controlifwhileforbreakcontinuefuncreturnparallelLLM interactionpromptllmmemoryExternal systemsapidbDeep agentssearchinvokeHuman-in-the-loopaskAgent outputoutputAgent terminationendfailObservabilityprogresstracelog
An agent is a set of functions, main is required, and a function is an ordered dict of commands

Results

Commands that call something set the result variable for the next command to read. The commands that set result are api, db, llm, search, invoke, func, parallel, ask and memory. Other commands leave result unchanged. The next call overwrites result, so save a result you need later with var.

Error handling on a command

api, db and llm accept an onError block. When the command raises an error, the block runs with exc set to the exception, and the function continues with the next command. Without an onError block on the command, the error goes to the function's onError, and then to the caller.

Where a command may appear

A few commands are restricted. The restrictions are checked when the draft is validated. The check follows calls through func and through the functions an llm command offers as tools:

ContextNot allowedWhy
Inside a for blockask, invokeA pause cannot be resumed mid-iteration.
Inside onErrorask, invokeError handling must complete.
A function run by parallelaskParallel branches cannot pause.
A function used as an LLM toolendA tool must return to the model.
Outside a loopbreak, continueNothing to break out of.