Agent structure

The top-level object of a definition holds a set of named functions. Each function is an ordered object of commands, the units of execution. The rest of an agent, including the prompts its llm commands name, is the agent meta.

The shape of every agent
{
  "functions": {
    "main": {                    // the entry point; required
      "commands": {
        "api": { ... },          // each key names a command
        "llm": { ... },
        "output": "{ result }"
      }
    },
    "helper": {                  // any number of other functions
      "args": { "city": {} },
      "commands": { ... }
    }
  }
}
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

Definition and agent meta

An agent has two parts. The definition is the JSON above: its functions and their commands. The agent meta is everything else that belongs to the agent: its title, tag, run limits, prompts and const. The meta is edited in the same draft as the definition, validated with it and published with it, but it is not written in the definition. A publish that changes only the meta keeps the agent's version; see Publishing.

Commands are keys

Each command is a key-value pair. The key is the command name and the value carries the command's fields: an object for most commands, a single value for simple ones such as progress or return. Commands run in the order they are written.

Keys in a JSON object must be unique, so a command that appears twice in one function takes a suffix after a dot: api, api.2, api.forecast. The suffix is only a label. It appears in traces and error messages.

main

Every agent defines a function named main, and execution starts there. Other functions run when a function calls them with func or parallel, or when an LLM calls them as tools. main itself cannot be called.

Size

A definition may be at most 20,480 characters by default. The limit is an administrator setting in Runtime limits. Prompts and the const are part of the agent meta, not of the definition, and have limits of their own; see Prompts and Const.