|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Agentic context |
| 4 | +nav_order: 70 |
| 5 | +has_children: false |
| 6 | +parent: Search processors |
| 7 | +grand_parent: Search pipelines |
| 8 | +--- |
| 9 | + |
| 10 | +# Agentic context processor |
| 11 | +Introduced 3.3 |
| 12 | +{: .label .label-purple } |
| 13 | + |
| 14 | +The `agentic_context` search response processor adds agent execution context information to search response extensions. This processor works in conjunction with the [agentic query translator]({{site.url}}{{site.baseurl}}/search-plugins/agentic-query-translator/) to provide transparency into the agent's query translation process and maintain conversation continuity. |
| 15 | + |
| 16 | +## Request body fields |
| 17 | + |
| 18 | +The following table lists all available request fields. |
| 19 | + |
| 20 | +Field | Data type | Description |
| 21 | +:--- | :--- | :--- |
| 22 | +`agent_steps_summary` | Boolean | Whether to include the agent's execution steps summary in the response. Default is `false`. Optional. |
| 23 | +`dsl_query` | Boolean | Whether to include the generated DSL query in the response. Default is `false`. Optional. |
| 24 | + |
| 25 | +## Response fields |
| 26 | + |
| 27 | +When enabled, the processor adds the following fields to the search response extensions: |
| 28 | + |
| 29 | +Field | Description |
| 30 | +:--- | :--- |
| 31 | +`agent_steps_summary` | A summary of the steps the agent took to translate the natural language query (included when `agent_steps_summary` is `true`) |
| 32 | +`dsl_query` | The generated DSL query that was executed (included when `dsl_query` is `true`) |
| 33 | + |
| 34 | +## Example |
| 35 | + |
| 36 | +The following example request creates a search pipeline with an `agentic_context` response processor: |
| 37 | + |
| 38 | +```json |
| 39 | +PUT /_search/pipeline/agentic_pipeline |
| 40 | +{ |
| 41 | + "request_processors": [ |
| 42 | + { |
| 43 | + "agentic_query_translator": { |
| 44 | + "agent_id": "your-agent-id" |
| 45 | + } |
| 46 | + } |
| 47 | + ], |
| 48 | + "response_processors": [ |
| 49 | + { |
| 50 | + "agentic_context": { |
| 51 | + "agent_steps_summary": true, |
| 52 | + "dsl_query": true |
| 53 | + } |
| 54 | + } |
| 55 | + ] |
| 56 | +} |
| 57 | +``` |
| 58 | +{% include copy-curl.html %} |
| 59 | + |
| 60 | +## Usage |
| 61 | + |
| 62 | +When you perform a search with the configured pipeline, the response will include agent context information: |
| 63 | + |
| 64 | +```json |
| 65 | +POST /your-index/_search?search_pipeline=agentic_search_pipeline |
| 66 | +{ |
| 67 | + "query": { |
| 68 | + "agentic": { |
| 69 | + "query_text": "Show me shoes in white color", |
| 70 | + "memory_id": "your memory id" |
| 71 | + } |
| 72 | + } |
| 73 | +} |
| 74 | +``` |
| 75 | +{% include copy-curl.html %} |
| 76 | + |
| 77 | +### Example response |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "took": 15, |
| 82 | + "hits": { |
| 83 | + "_shards": {...}, |
| 84 | + "hits": [...] |
| 85 | + }, |
| 86 | + "ext": { |
| 87 | + "agent_steps_summary": "I have these tools available: [ListIndexTool, IndexMappingTool, query_planner_tool]\\nFirst I used: ListIndexTool — input: \"\"; context gained: \"Discovered products-index which seems relevant for products and pricing context\"\\nSecond I used: IndexMappingTool — input: \"products-index\"; context gained: \"Confirmed presence of category and price fields in products-index\"\\nThird I used: query_planner_tool — qpt.question: \"Show me shoes that cost exactly 100 dollars.\"; index_name_provided: \"products-index\"\\nValidation: qpt output is valid and accurately reflects the request for shoes priced at 100 dollars.", |
| 88 | + "memory_id": "WVhHiJkBnqovov2plcDH", |
| 89 | + "dsl_query": "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"category\":\"shoes\"}},{\"term\":{\"price\":100.0}}]}}}" |
| 90 | + } |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +## How it works |
| 95 | + |
| 96 | +1. The processor retrieves agent context information from the pipeline processing context |
| 97 | +2. Based on configuration, it selectively includes agent steps summary and DSL query |
| 98 | +3. Memory ID is always included when available for conversation continuity |
| 99 | +4. The context information is added to the search response extensions |
| 100 | +5. Type validation ensures all context attributes are strings |
0 commit comments