|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Agentic context |
| 4 | +nav_order: 2 |
| 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/search-pipelines/agentic-query-translator-processor/) to expose the agent's query translation process and maintain conversation continuity: |
| 15 | + |
| 16 | +1. The processor retrieves agent context information from the pipeline processing context. |
| 17 | +2. Based on the processor configuration, it selectively includes the agent steps summary and the query domain-specific language (DSL) query in the response. |
| 18 | +3. The memory ID is always included, when available, for conversation continuity. |
| 19 | +4. The context information is added to the search response extensions. |
| 20 | +5. Type validation ensures that all context attributes are strings. |
| 21 | + |
| 22 | +## Request body fields |
| 23 | + |
| 24 | +The following table lists all available request fields. |
| 25 | + |
| 26 | +Field | Data type | Description |
| 27 | +:--- | :--- | :--- |
| 28 | +`agent_steps_summary` | Boolean | Whether to include the agent's execution steps summary in the response. Default is `false`. Optional. |
| 29 | +`dsl_query` | Boolean | Whether to include the generated DSL query in the response. Default is `false`. Optional. |
| 30 | + |
| 31 | +## Response fields |
| 32 | + |
| 33 | +When enabled, the processor adds the following fields to the search response extensions. |
| 34 | + |
| 35 | +Field | Description |
| 36 | +:--- | :--- |
| 37 | +`agent_steps_summary` | A summary of the steps that the agent took to translate the natural language query (included when `agent_steps_summary` is `true`). |
| 38 | +`memory_id` | The conversation memory ID for maintaining context across queries. Only provide this in the `agentic` query if you want to continue the previous conversation. |
| 39 | +`dsl_query` | The generated DSL query that was executed (included when `dsl_query` is `true`). |
| 40 | + |
| 41 | +## Example |
| 42 | + |
| 43 | +The following example request creates a search pipeline with an `agentic_context` response processor: |
| 44 | + |
| 45 | +```json |
| 46 | +PUT /_search/pipeline/agentic_pipeline |
| 47 | +{ |
| 48 | + "request_processors": [ |
| 49 | + { |
| 50 | + "agentic_query_translator": { |
| 51 | + "agent_id": "your-agent-id" |
| 52 | + } |
| 53 | + } |
| 54 | + ], |
| 55 | + "response_processors": [ |
| 56 | + { |
| 57 | + "agentic_context": { |
| 58 | + "agent_steps_summary": true, |
| 59 | + "dsl_query": true |
| 60 | + } |
| 61 | + } |
| 62 | + ] |
| 63 | +} |
| 64 | +``` |
| 65 | +{% include copy-curl.html %} |
| 66 | + |
| 67 | +Perform a search using the configured pipeline: |
| 68 | + |
| 69 | +```json |
| 70 | +POST /your-index/_search?search_pipeline=agentic_search_pipeline |
| 71 | +{ |
| 72 | + "query": { |
| 73 | + "agentic": { |
| 74 | + "query_text": "Show me shoes in white color", |
| 75 | + "memory_id": "your memory id" |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | +{% include copy-curl.html %} |
| 81 | + |
| 82 | +The response contains the steps taken by the agent to translate the query, the memory ID, and the rewritten DSL query: |
| 83 | + |
| 84 | +```json |
| 85 | +{ |
| 86 | + "took": 15, |
| 87 | + "hits": { |
| 88 | + "_shards": {...}, |
| 89 | + "hits": [...] |
| 90 | + }, |
| 91 | + "ext": { |
| 92 | + "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.", |
| 93 | + "memory_id": "WVhHiJkBnqovov2plcDH", |
| 94 | + "dsl_query": "{\"query\":{\"bool\":{\"filter\":[{\"term\":{\"category\":\"shoes\"}},{\"term\":{\"price\":100.0}}]}}}" |
| 95 | + } |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +## Related pages |
| 100 | + |
| 101 | +- [Agentic search queries]({{site.url}}{{site.baseurl}}/vector-search/ai-search/agentic-search) |
| 102 | +- [Agents]({{site.url}}{{site.baseurl}}/ml-commons-plugin/agents-tools/agents/index/) |
| 103 | +- [Agentic query translator processor]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/agentic-query-translator-processor/) |
0 commit comments