generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 616
Add execute tool API doc #11214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
natebower
merged 6 commits into
opensearch-project:main
from
nathaliellenaa:execute_tool
Oct 13, 2025
+231
−17
Merged
Add execute tool API doc #11214
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d252659
Add execute tool API doc
nathaliellenaa 8c83c17
Address comments
nathaliellenaa 4aaf7ec
Apply suggestions from code review
natebower 550db36
Doc review
kolchfa-aws 5efa604
Update _ml-commons-plugin/agents-tools/tools/search-index-tool.md
natebower 92776b0
Apply suggestions from code review
kolchfa-aws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
layout: default | ||
title: Execute tool | ||
parent: ML Commons APIs | ||
nav_order: 100 | ||
--- | ||
|
||
# Execute Tool API | ||
**Introduced 3.2** | ||
{: .label .label-purple } | ||
|
||
The Execute Tool API allows you to run individual tools directly without creating an agent first. This API is particularly beneficial for applications requiring quick, single-tool operations where the overhead of agent creation and management is unnecessary. | ||
|
||
## Use cases | ||
|
||
The Execute Tool API is ideal for: | ||
- **Direct tool execution**: Run specific tools like search, data analysis, or retrieval operations without agent setup. | ||
- **Testing and debugging**: Quickly test tool functionality during development. | ||
- **Lightweight integrations**: Integrate specific OpenSearch capabilities into applications without full agent workflows. | ||
- **Standalone operations**: Perform single tasks that don't require conversation memory or complex orchestration. | ||
|
||
## Supported tools | ||
|
||
This API supports all available OpenSearch tools. Each tool can be executed independently with its specific parameters. | ||
|
||
For more information regarding the list of available tools, see [Tools]({{site.url}}{{site.baseurl}}/ml-commons-plugin/agents-tools/tools/index/). | ||
|
||
## Endpoint | ||
|
||
```json | ||
POST /_plugins/_ml/tools/_execute/<tool_name> | ||
``` | ||
|
||
The `<tool_name>` parameter refers to the predefined tool type name, such as `PPLTool`, `SearchIndexTool`, or `VectorDBTool`,---not a custom tool name that you define. | ||
{: .note} | ||
|
||
## Request body field | ||
|
||
The following table lists all request body field. | ||
|
||
| Field | Data type | Required | Description | | ||
| :--- | :--- | :--- | :--- | | ||
| `parameters` | Object | Yes | Contains tool-specific parameters that vary depending on the tool being executed. Each tool requires different parameters based on its functionality. | | ||
|
||
### Parameter structure | ||
|
||
The `parameters` object combines the parameters used during tool registration and tool execution. The specific fields depend on the tool being executed. | ||
|
||
To determine the required parameters for a specific tool, refer to the individual tool documentation in the [Tools]({{site.url}}{{site.baseurl}}/ml-commons-plugin/agents-tools/tools/index/) section. | ||
|
||
| Component | Description | | ||
|:-------------------------|:-----------------------------------------------| | ||
| Tool registration parameters | Parameters specified during tool registration. | | ||
| Tool execution parameters | Parameters specified during tool execution. | | ||
|
||
## Example requests | ||
The following are examples of both simple and complex tool execution. | ||
|
||
### Example 1: Simple tool execution | ||
|
||
```json | ||
POST /_plugins/_ml/tools/_execute/ListIndexTool | ||
{ | ||
"parameters": { | ||
"question": "How many indices do I have?" | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
### Example response | ||
|
||
```json | ||
{ | ||
"inference_results": [ | ||
{ | ||
"output": [ | ||
{ | ||
"name": "response", | ||
"result": "row,health,status,index,uuid,pri(number of primary shards),rep(number of replica shards),docs.count(number of available documents),docs.deleted(number of deleted documents),store.size(store size of primary and replica shards),pri.store.size(store size of primary shards)\n1,yellow,open,movies,kKcJKu2aT0C9uwJIPP4hxw,2,1,2,0,7.8kb,7.8kb\n2,green,open,.plugins-ml-config,h8ovp_KFTq6_zvcBEn2kvg,1,0,1,0,4kb,4kb\n3,green,open,.plugins-ml-agent,1oGlUBCIRAGXLbLv27Qg8w,1,0,1,0,8kb,8kb\n" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Example 2: Complex tool execution | ||
|
||
```json | ||
POST /_plugins/_ml/tools/_execute/PPLTool | ||
nathaliellenaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
"parameters": { | ||
"question": "what's the population of Seattle in 2021?", | ||
"index": "test-population", | ||
"model_id": "1TuQQ5gBMJhRgCqgSV79" // Remote model | ||
kolchfa-aws marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
``` | ||
{% include copy-curl.html %} | ||
|
||
### Example response | ||
|
||
```json | ||
{ | ||
"inference_results": [ | ||
{ | ||
"output": [ | ||
{ | ||
"name": "response", | ||
"dataAsMap": { | ||
"result":"{\"ppl\":\"source\=test-population | where QUERY_STRING([\'population_description\'], \'Seattle\') AND QUERY_STRING([\'population_description\'], \'2021\')\",\"executionResult\":\"{\\n \\\"schema\\\": [\\n {\\n \\\"name\\\": \\\"population_description\\\",\\n \\\"type\\\": \\\"string\\\"\\n }\\n ],\\n \\\"datarows\\\": [],\\n \\\"total\\\": 0,\\n \\\"size\\\": 0\\n}\"}" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
nathaliellenaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
layout: default | ||
title: Stats | ||
parent: ML Commons APIs | ||
nav_order: 110 | ||
nav_order: 120 | ||
--- | ||
|
||
# Stats API | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.