Update Context Management API
Introduced 3.5
Use this API to update an existing context management configuration. You can modify the description, hooks configuration, and context manager settings.
Endpoints
PUT /_plugins/_ml/context_management/{context_management_name}
Path parameters
The following table lists the available path parameters.
| Parameter | Data type | Required/Optional | Description |
|---|---|---|---|
context_management_name | String | Required | The name of the context management to update. |
Request body fields
The following table lists the available request body fields.
| Field | Data type | Required/Optional | Description |
|---|---|---|---|
description | String | Optional | A human-readable description of what this context management does. |
hooks | Object | Optional | A map of hook names to lists of context manager configurations. See The hooks object. |
The request body follows the same structure as the Create Context Management API. Fields that you omit keep their existing values. In the hooks object, each hook that you specify replaces the existing configuration for that hook, and hooks that you omit are unchanged.
Example request: Update description
PUT /_plugins/_ml/context_management/advanced-context-management
{
"description": "Updated description for advanced context management with multiple strategies"
}
Example request: Update hooks configuration
PUT /_plugins/_ml/context_management/sliding_window_max_40000_tokens_managers
{
"description": "Context management for truncating tool outputs to prevent input length issues",
"hooks": {
"PRE_LLM": [
{
"type": "SlidingWindowManager",
"config": {
"max_messages": 8
}
}
],
"POST_TOOL": [
{
"type": "ToolsOutputTruncateManager",
"config": {
"max_output_length": 40000
}
}
]
}
}
Example response
{
"_index": ".plugins-ml-context-management-templates",
"_id": "sliding_window_max_40000_tokens_managers",
"_version": 2,
"result": "updated",
"forced_refresh": true,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"_seq_no": 4,
"_primary_term": 1
}
Related documentation
For more information, see Context management.