Link Search Menu Expand Document Documentation Menu

Execute an agent

Introduced 2.13

When an agent is executed, it runs the tools with which it is configured. Starting with OpenSearch version 3.0, you can execute an agent asynchronously by setting the async query parameter to true.

Endpoints

POST /_plugins/_ml/agents/<agent_id>/_execute

Query parameters

The following table lists the available query parameters.

Parameter Data type Required/Optional Description
async Boolean Optional If true, executes the agent asynchronously and returns a task_id to track execution. To check the status of the task, use the Tasks API. Default is false.

Request body fields

The following table lists the available request fields.

Field Data type Required/Optional Description
parameters Object Required The parameters required by the agent.
parameters.verbose Boolean Optional Provides verbose output.

Example request

POST /_plugins/_ml/agents/879v9YwBjWKCe6Kg12Tx/_execute
{
  "parameters": {
    "question": "what's the population increase of Seattle from 2021 to 2023"
  }
}

Example response

{
  "inference_results": [
    {
      "output": [
        {
          "result": """ Based on the given context, the key information is:

The metro area population of Seattle in 2021 was 3,461,000.
The metro area population of Seattle in 2023 is 3,519,000.

To calculate the population increase from 2021 to 2023:

Population in 2023 (3,519,000) - Population in 2021 (3,461,000) = 58,000

Therefore, the population increase of Seattle from 2021 to 2023 is 58,000."""
        }
      ]
    }
  ]
}
350 characters left

Have a question? .

Want to contribute? or .