Agent structure

The top-level object holds a set of named functions. Each function is an ordered object of commands. Commands are the units of execution in an agent.

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

Commands are keys

Each command is a key-value pair. The key is the command name and the value carries the command's fields. The value is an object for most commands, and a single value for simple commands 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 more than once in one function takes a suffix after a dot: api, api.2, api.forecast. The suffix is only a label. The suffix appears in traces and error messages.

main

Every agent defines a function named main. Execution starts in main. 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

An agent definition may be at most 20,480 characters by default. The limit is an administrator setting in Runtime limits. Move repeated prompt text into prompt profiles rather than growing the agent.