func

Calls another function of the agent and returns that function's return value.

Fields

FieldTypeDefaultDescription
namerequiredstringName of the function to call. Must be a literal name, not an expression, and cannot be 'main'.
argsdynamic dictArguments passed to the function.

Example

"functions": {
  "lookupCustomer": {
    "args": { "email": {} },
    "commands": {
      "db": {
        "profile": "crm",
        "sql": "select * from customers where email = :email",
        "params": { "email": "{ email }" }
      },
      "return": "{ result[0] if result else None }"
    }
  },
  "main": {
    "commands": {
      "func": {
        "name": "lookupCustomer",
        "args": { "email": "{ sys.userEmail }" }
      },
      "var": { "customer": "{ result }" }
    }
  }
}

Rules

  • The function name is a literal, not an expression. The function must exist in the agent, and it cannot be main.
  • Arguments become local variables of the called function. An argument that the function declares but the call omits is set to None.
  • The called function's return value is this command's result. A function that reaches the end of its commands without a return returns None.
  • A function cannot call itself, directly or through other functions, while the function is still running.
  • The llm command uses the same mechanism when a function is offered to the model as a tool.