Skip to navigation

code-tools

Read, change, and test the Code tools of your AI Agent. A Code tool runs a short Python snippet to transform data during a conversation. The alias is code-actions.

Commands

CommandWhat it does
code-tools listLists Code tools, one page at a time.
code-tools get <id>Shows one Code tool and its source. --source-out writes the source to a file.
code-tools createCreates a Code tool from a Python file.
code-tools update <id>Changes a Code tool, or turns it on or off. Fields that you do not give keep their values.
code-tools delete <id>Deletes a Code tool.
code-tools test <id>Runs a Code tool one time with test inputs. The run saves nothing.
code-tools allowed-domains add <domain>Lets the fetch() of a Code tool reach a domain.
code-tools allowed-domains listLists the allowed domains.
code-tools allowed-domains remove <id>Removes an allowed domain.

Examples

Create a Code tool with one input that reads a variable and one input that the AI Agent gives:

adacli acme code-tools create --file filter_items.py --name "Filter items" \
--description "Keep the order items over a price threshold" \
--inputs '[{"name":"order_response","type":"dict","variable_id":"<variable-id>"},{"name":"threshold","type":"number"}]' \
--outputs '[{"name":"Total","key":"total"}]'

Edit the source of a Code tool. Write the source to a file, change it, then send it back:

adacli acme code-tools get <code-tool-id> --source-out filter_items.py
adacli acme code-tools update <code-tool-id> --file filter_items.py

Run a Code tool with test inputs:

adacli acme code-tools test <code-tool-id> --inputs '{"order_response":{"items":[{"price":12}]},"threshold":5}'

Let Code tools call an API:

adacli acme code-tools allowed-domains add https://api.example.com

Details

  • create needs --file, --name, and --description. The API refuses source over 64 KB and a name that another tool uses.
  • update --inputs and update --outputs replace the full list.
  • In an output, variable_id is the 24-character ID of a variable, not its name. key is a JMESPath expression into the result.
  • test runs like a live call. fetch() sends real requests, and secrets resolve.
  • test needs the Owner or Admin role. The API allows 10 test runs each minute. A failed run gives a non-zero exit code.
  • An allowed domain is a scheme and a host, with an optional port. A leading *. allows one level of subdomain. An https:// domain does not allow http:// requests.
  • Do not put a secret in the source. Use an environment variable for each secret.

For every option of a command, run it with --help, for example adacli acme code-tools create --help.

  • api-tools: get the data that a Code tool transforms.
  • variables: get the variable IDs for inputs and outputs.
  • playbooks: run a Code tool from a Playbook step.