Commands

There are 20 commands. Together they cover the agentic workflow: variables, flow control, progress, termination, external systems, LLMs, 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

  • 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.

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 to the user by the Search2o application.

Observability

  • progressStreams a progress message to the UI, that is shown to the user. 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 has a page in the Command reference, with a table of its fields generated from the agent schema and an example.

agenta set of functionsmainrequired · execution starts herecommandcommandcommand…functionAcommandcommand…functionBcommandcommand…The commandsVariablesvarFlow controlifwhileforbreakcontinuefuncreturnparallelLLM interactionllmmemoryExternal systemsapidbHuman-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 result for the next command to read. The commands that set it are api, db, llm, func, parallel, ask and memory. Other commands leave result unchanged. The next call overwrites it, 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

Some commands are restricted. Validation checks the restrictions and follows calls through func and through the functions an llm command offers as tools:

ContextNot allowedWhy
Inside a for blockaskA pause cannot be resumed mid-iteration.
Inside onErroraskError handling must complete.
A function with a description, which makes it a toolendA tool must return to the model.
Outside a loopbreak, continueNothing to break out of.