Agent Studio

Tools

Declarative actions for agent capabilities

Tools

Tools are declarative action definitions that agents can invoke during conversations. Unlike traditional function calls, tools in Agent Studio are configured via JSON without code changes.

Tool Structure

{
  "name": "save_meal",
  "description": "Log a meal the user consumed",
  "parameters": [
    { "name": "meal_type", "type": "string", "enum": ["breakfast", "lunch", "dinner"] },
    { "name": "dishes", "type": "array", "required": true }
  ],
  "actions": [
    { "type": "context.set", "path": "logged_meals[+]", "value": "params" },
    {
      "type": "api_call",
      "url": "{{tenant.settings.endpoints.meal_log}}",
      "method": "POST",
      "body": { "meal": "params" }
    }
  ],
  "on_success": [
    { "type": "respond", "message": "Got it! I've logged your {{params.meal_type}}." }
  ],
  "on_failure": [
    { "type": "respond", "message": "Sorry, I couldn't save that meal." }
  ]
}

Parameters

Define what the LLM should extract from the conversation:

PropertyDescription
nameParameter identifier
typestring, integer, number, boolean, array, object
requiredWhether the parameter is mandatory
enumAllowed values (for strings)
descriptionHelp text for the LLM
defaultDefault value if not provided

Action Types

Tools support 12 action types that can be chained together:

Context Actions

ActionDescriptionProperties
context.setStore values in call contextpath, value
context.getRead values from contextpath
context.deleteRemove values from contextpath
{ "type": "context.set", "path": "user.preferences.theme", "value": "params.selected_theme" }
{ "type": "context.get", "path": "user.name" }
{ "type": "context.delete", "path": "temp.draft" }

Flag Actions

ActionDescriptionProperties
flag.setSet a boolean flagflag
flag.clearClear a boolean flagflag
{ "type": "flag.set", "flag": "skip_confirmation" }
{ "type": "flag.clear", "flag": "needs_verification" }

Communication Actions

ActionDescriptionProperties
respondGenerate speech responsemessage
handoffTransfer to another agenttarget_agent, message (optional)
{ "type": "respond", "message": "I've saved your meal successfully!" }
{ "type": "handoff", "target_agent": "specialist_agent", "message": "Transferring you now..." }

Integration Actions

ActionDescriptionProperties
api_callCall external HTTP APIurl, method, body, headers, response_path, retry_count, retry_delay, on_error
{
  "type": "api_call",
  "url": "https://your-api.com/meals",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer {{user.auth_token}}"
  },
  "body": {
    "user_id": "{{user.id}}",
    "meal_type": "{{params.meal_type}}",
    "calories": "{{params.calories}}"
  },
  "response_path": "workflow.api_response",
  "timeout": 30,
  "retry_count": 3,
  "retry_delay": 0.5,
  "on_error": "fail"
}

API Call Properties

PropertyTypeDefaultDescription
urlstringrequiredFull URL or template (e.g., {{tenant.settings.endpoints.meal_log}})
methodstringPOSTHTTP method (GET, POST, PUT, PATCH, DELETE)
bodyobject-Request body (for POST/PUT/PATCH)
headersobject-HTTP headers
timeoutnumber30Request timeout in seconds
response_pathstring-Context path to store the response
retry_countnumber3Number of retries on failure
retry_delaynumber0.5Delay between retries in seconds
on_errorstringfail"fail" to fail the tool, "continue" to proceed

Logic Actions

ActionDescriptionProperties
conditionalBranch based on conditioncondition, then_actions, else_actions
validateValidate parametersrules
transformTransform datainput_path, output_path, transform_type, transform_config
logLog data for debugginglevel, log_message

Conditional Actions

Execute different actions based on a condition:

{
  "type": "conditional",
  "condition": "context.user_type === 'premium'",
  "then_actions": [
    { "type": "respond", "message": "Welcome back, premium member!" }
  ],
  "else_actions": [
    { "type": "respond", "message": "Welcome! Consider upgrading to premium." }
  ]
}

Conditions support JavaScript-like expressions with access to params, context, and flags.

Validation Actions

Validate input before processing:

{
  "type": "validate",
  "rules": [
    { "field": "params.email", "rule": "email", "error_message": "Please provide a valid email address" }
  ]
}

Supported rules: required, email, phone, number, min_length, max_length, pattern

Transform Actions

Transform data using expressions:

{
  "type": "transform",
  "input_path": "params.items",
  "transform_type": "map",
  "transform_config": { "expression": "item.toUpperCase()" },
  "output_path": "workflow.formatted_items"
}

Log Actions

Log data for debugging:

{
  "type": "log",
  "level": "info",
  "log_message": "Processing meal data"
}

Log levels: debug, info, warn, error

Variable Templates

Use {{path}} to reference context values in messages and action properties:

  • {{params.meal_type}} - Current tool parameters
  • {{user.id}} - User context (from user_context passed at call dispatch)
  • {{user.auth_token}} - Auth token for API calls
  • {{workflow.total}} - Shared workflow state
  • {{agents.meal.last}} - Agent-specific state
  • {{tenant.settings.endpoints.meal_log}} - Tenant-configured endpoints

Array append with [+]:

{ "type": "context.set", "path": "meals[+]", "value": "params" }

External API Calls

Call external APIs using the api_call action with full control over the request:

{
  "type": "api_call",
  "url": "https://your-api.com/meals",
  "method": "POST",
  "headers": {
    "Authorization": "Bearer {{user.auth_token}}"
  },
  "body": {
    "user_id": "{{user.id}}",
    "meal": "{{params}}"
  },
  "response_path": "workflow.api_result",
  "retry_count": 3
}

For portable tools across environments, store API base URLs in tenant settings and reference them via templates:

{
  "type": "api_call",
  "url": "{{tenant.settings.endpoints.meal_api}}/meals",
  "method": "POST",
  "body": { "meal": "{{params}}" }
}

See the Backend Integration Guide for authentication patterns and security best practices.

Success and Failure Callbacks

Define actions to run after tool execution:

{
  "on_success": [
    { "type": "context.set", "path": "last_action", "value": "'meal_saved'" },
    { "type": "respond", "message": "Done!" }
  ],
  "on_failure": [
    { "type": "log", "level": "error", "log_message": "Tool failed" },
    { "type": "respond", "message": "Something went wrong. Please try again." }
  ]
}

Action Chaining

Actions execute in order. Use chaining to build complex workflows:

{
  "actions": [
    {
      "type": "validate",
      "rules": [{ "field": "params.email", "rule": "email" }]
    },
    { "type": "context.set", "path": "user.email", "value": "params.email" },
    {
      "type": "conditional",
      "condition": "params.subscribe === true",
      "then_actions": [
        {
          "type": "api_call",
          "url": "{{tenant.settings.endpoints.subscribe}}",
          "method": "POST",
          "body": { "email": "{{params.email}}" }
        },
        { "type": "flag.set", "flag": "subscribed" }
      ]
    },
    { "type": "respond", "message": "Your email has been saved!" }
  ]
}

On this page