<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title><![CDATA[Gustavo Llermaly - Elasticsearch Labs]]></title>
    <description><![CDATA[Articles and tutorials from the Search team at Elastic]]></description>
    <copyright><![CDATA[© 2026. Elasticsearch B.V. All Rights Reserved]]></copyright>
    <image>
      <title><![CDATA[Gustavo Llermaly - Elasticsearch Labs]]></title>
      <url>https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt1121c0bf0e8a6e65/6a88da6340a1841030ef456f/search-labs-thumbnail.png</url>
      <link>https://www.elastic.co/search-labs/author/gustavo-llermaly</link>
    </image>
    <link>https://www.elastic.co/search-labs/author/gustavo-llermaly</link>
    <atom:link href="https://www.elastic.co/search-labs/rss/author/gustavo-llermaly.xml" rel="self" type="application/rss+xml"/>
    <language><![CDATA[en]]></language>
    <lastBuildDate>Sun, 20 Sep 2026 06:01:28 GMT</lastBuildDate>
  <item>
    <title><![CDATA[Using subagents and Elastic Agent Builder to bring business context into code planning]]></title>
    <description><![CDATA[Learn about subagents, how to ensure they have the right information, and how to create a specialized subagent that connects Claude Code to your Elasticsearch data.]]></description>
    <content:encoded><![CDATA[<p><a href="https://code.claude.com/docs/en/sub-agents">Subagents in Claude Code</a> let you offload specialized tasks to separate context windows, keeping your main conversation focused. In this article, you'll learn what subagents are, when to use them, and how to build a retrieval subagent using Elastic Agent Builder that connects your development workflow to business data in Elasticsearch.</p><h2>What are subagents?</h2><p><em>Subagents </em>are specialized assistants that can be called to execute a specific task, using their own context window. They complete a task and give the results to the main agent, preventing it from saving information that isn’t relevant for the rest of the conversation in the context window.</p><p>Their four core principles are:</p><ul><li><p><strong>Context preservation:</strong> Each subagent uses its own context window.</p></li><li><p><strong>Specialized expertise:</strong> Each subagent is designed for a specific task.</p></li><li><p><strong>Reusability:</strong> You can reuse a subagent in different sessions and projects.</p></li><li><p><strong>Flexible access:</strong> You can limit the subagent access to specific tools.</p></li></ul><p>Each subagent can have access to Claude Code tools to work with the terminal, such as glob, read, write, grep, or bash, or to access the internet, like search, fetch, or call external tools with Model Context Protocol (MCP) servers.</p><p>A subagent uses the following schema:</p>---
name: your-sub-agent-name
description: Description of when this subagent should be invoked
tools: tool1, tool2, tool3  # Optional - inherits all tools if omitted
model: sonnet  # Optional - specify model alias or 'inherit'
permissionMode: default  # Optional - permission mode for the subagent
skills: skill1, skill2  # Optional - skills to auto-load
---

Your subagent's system prompt goes here. This can be multiple paragraphs
and should clearly define the subagent's role, capabilities, and approach
to solve problems.

Include specific instructions, best practices, and any constraints
the subagent should follow.<p>You can call subagents implicitly by talking about the task they run, and Claude will call them automatically. For example, you can say, "I want to plan my new functionality."</p><p>You can also call them explicitly by directly asking Claude Code to use a subagent and telling it, "Use the planning subagent to plan my new functionality."</p><p>Another important feature is that subagents are stateful, so once you give one a task, it will generate an ID. This way, when you use it again, you can start from scratch or provide the ID to give it context from its previous tasks.</p><p>You can read the <a href="https://code.claude.com/docs/en/sub-agents">full documentation here</a>.</p><h2>When are subagents used?</h2><p>Subagents are useful when you need to delegate tasks that require specialized context but you don't want to clutter the main chat window. Considering our example of coding, the most common subtasks include:</p><p>Subtask type</p><p>Description</p><p>Typical tools</p><p>Exploration / research</p><p>Searching and analyzing code without modifying it.</p><p>Read, grep, glob</p><p>Planning</p><p>Running deep analysis to create implementation plans.</p><p>Read, grep, glob, bash</p><p>Code review</p><p>Reviewing quality, safety, and best practices.</p><p>Read, grep, glob, bash</p><p>Code modification</p><p>Writing and editing code.</p><p>Read, edit, write, grep, glob</p><p>Testing / debugging</p><p>Running tests and analyzing issues.</p><p>Bash, read, grep, edit</p><p>Retrieval</p><p>Getting information from external sources (APIs, databases).</p><p>MCP tools, bash</p><p>Claude Code includes three built-in agents that showcase these use cases:</p><p></p><ul><li><p><strong>Explore:</strong> Quick agents for read-only search in the codebase. It's great for answering questions like, "Where are the client's errors handled?"</p></li><li><p><strong>Plan:</strong> Research agent that activates in plan mode to analyze the codebase before proposing changes.</p></li><li><p><strong>General-purpose:</strong> The most capable agent for complex tasks that require multiple steps and can include modifications.</p></li></ul><h2>Context management: Ensuring subagents have the right information</h2><p>One of the most important decisions when designing subagents is how to handle context. There are three key considerations:</p><h3><strong>1. Which context the subagent should get</strong></h3><p>The prompt you give to the subagent must contain all of the necessary information to complete the task since the subagent doesn’t have access to the main chat. You need to be specific:</p><ul><li><p>Do NOT say, "Review the code."</p></li><li><p>SAY, "Review the changes to src/auth/index.ts, focusing on JWT token validation."</p></li></ul><p>Providing the exact file name makes a difference between using the read tool against the file directly and making a wide search using grep and thus wasting time and tokens.</p><p>Also consider what not to include. Irrelevant context can distract the subagent or bias results. It’s tempting to ask for multiple things in one pass, but focused tasks yield better results:</p><ul><li><p>Do NOT say, “Review src/auth/<a href="http://index.ts">index.ts</a>. Here is also the database schema and our API docs for reference, fix bugs and suggest improvements about the architecture decisions.”</p></li><li><p>SAY, “Fix the token refresh bug in src/auth/index.ts that's throwing AUTH_TOKEN_EXPIRED unexpectedly.”</p></li></ul><h3><strong>2. What tools to provide</strong></h3><p>Limit the tools to what’s strictly necessary. This improves security, keeps the subagent focused, and reduces unnecessary tool calls and execution costs.</p># For just an analysis agent
tools: Read, Grep, Glob

# For an agent that needs to modify the code
tools: Read, Edit, Write, Grep, Glob<p>If you don't specify a tools field, the subagent inherits all tools from the main agent, including MCP tools.</p><p>You can learn all Claude Code tools <a href="https://code.claude.com/docs/en/how-claude-code-works#tools">here</a>.</p><h3><strong>3. How to keep context between calls</strong></h3><p>Subagents can be resumed using their agentId:</p># First call
&gt; Use the code-analyzer agent to review the authentication module
[Agent completes the analysis and returns agentId: "abc123"]

# Continue with previous context
&gt; Resume agent abc123 and now analyze the authorization module
[Agent continues with the context from the previous chat]<p></p><p>You can ask Claude for the agent ID or find it in <code>~/.claude/projects/{project}/{sessionId}/subagents/</code></p><p>This is especially useful for long research tasks or multistep workflows.</p><p>Another way to keep context consistent is to ask the agent to write a Markdown checklist with what it's doing and its current progress. Then you can execute <code>/clear</code> without losing the initial instruction. In that request, you can define the task granularity or details to retain that make sense for your use case.</p># Task: Review authentication module

## Progress
- [x] Analyzed src/auth/index.ts
- [x] Found JWT validation issue
- [ ] Review authorization module
- [ ] Check rate limiting

## Findings
- Token refresh has race condition in line 42<p>After you clear the conversation, the next agent can pick it up from here. This is very useful when you want an agent to run a script over a list and watch the output record by record.</p><h2>Orchestration patterns</h2><p>It’s important to see subagents as a context optimization mechanism. The way in which you coordinate them determines the efficiency of the whole system. There are different orchestration patterns.</p><h3><strong>Sequential (chaining)</strong></h3><p>Here, a subagent completes a task, and its results feed the next one in a sequence of tasks, similar to traditional Linux piping.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt421eabae16c6057f/6a170cb06234e07fcedb1a43/74a3a376600cd1b7cdd2dddddfed2f00ab131eed-896x94.png" alt="Sequential (or chaining) subagents, each feeding the next in a sequence of tasks." /><p>Call example:</p>&gt; First use the planning agent to design the feature,
&gt; then use the coding agent to implement it,
&gt; finally use the reviewer agent to check the code<h3><strong>Parallel</strong></h3><p>In this pattern, multiple subagents run independent tasks simultaneously. The main Claude Code agent invokes them since <strong>subagents cannot spawn other subagents</strong>.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt43666c7c597cf666/6a170cb228671458ed93e375/84eca68d29bf79cf978a8089d3c18972738cd2c1-595x272.png" alt="A parallel subagent pattern, with the main Claude Code agent invoking three subagents." /><p>This approach reduces the execution time for tasks like code review since it allows you to work with the same code from different angles without impacting the running time.</p><h3><strong>Hub-and-spoke (delegation)</strong></h3><p>In this approach, the main agent acts as an orchestrator, delegates tasks to specialized agents, and then consolidates the results.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc869c00340b0ac97/6a170cb3e8fbce396239fcb7/93bb2cc55c435f509b426fbcc090a67c53021684-595x272.png" alt="A hub-and-spoke subagent pattern, where the main agent acts as an orchestra" /><p>This is the pattern we’ll implement in our example: The main Claude Code agent will delegate the gathering of business information to a retrieval agent built with Elastic Agent Builder, while the explore agent will look into local files and the planning agent builds a plan.</p><h2>Why use an agent instead of a single query?</h2><p>Before building our retrieval subagent, it's worth understanding when an agent adds value versus when a simple Elasticsearch Query Language (ES|QL) query suffices.</p><p>If you need a single aggregation, like "What's our most visited page?" just run the query directly. The agent adds value when your question requires:</p><ul><li><p><strong>Multiple queries that build on each other:</strong> The answer from query 1 informs query 2.</p></li><li><p><strong>Cross-index reasoning:</strong> Correlating data from different sources.</p></li><li><p><strong>Ambiguity resolution:</strong> The agent interprets and follows leads.</p></li><li><p><strong>Synthesis:</strong> Combining quantitative data with qualitative knowledge.</p></li></ul><p>Our example will demonstrate all of these capabilities.</p><h2>Agent Builder as subagent</h2><p>Generating code using AI is very quick, but the problem is having a good planning phase to set the boundaries for our coding agent. To help with that, Claude created a subagent that <a href="https://code.claude.com/docs/en/common-workflows#use-plan-mode-for-safe-code-analysis">specializes in planning</a> to perform deep analysis and create a to-do list for the main agent to execute.</p><p>With this flow, you can plan based on what Claude Code can see both in local files and on the internet. However, there's still knowledge available in Elasticsearch that you cannot access via standard tools.</p><p>To access our internal knowledge during the planning phase, we'll create a Claude Code subagent by making a retrieval agent using Agent Builder.</p><p>You can configure the agent using the UI or an API. In this example, we'll use the latter.</p><h3><strong>Prerequisites</strong></h3><ul><li><p><a href="https://code.claude.com/docs/en/setup">Claude Code</a> 2.0.76+</p></li><li><p>Elasticsearch 9.2</p></li><li><p>Elasticsearch <a href="https://www.elastic.co/docs/deploy-manage/api-keys/elasticsearch-api-keys">API key</a></p></li></ul><h3><strong>The scenario: Technical debt sprint planning</strong></h3><p>You're a tech lead. You have two weeks and two developers. Your <code>TECH_DEBT.md</code> lists 12 items. You can tackle maybe three or four. Which ones should you prioritize?</p><p>The complexity is that you need to optimize across multiple dimensions simultaneously:</p><ul><li><p><strong>User impact:</strong> How many users hit this issue?</p></li><li><p><strong>Business impact:</strong> Does it affect paying customers? Enterprise tier?</p></li><li><p><strong>Severity:</strong> Errors? Performance? Just ugly code?</p></li><li><p><strong>Effort:</strong> Quick win or rabbit hole?</p></li><li><p><strong>Dependencies:</strong> Does fixing A unlock fixing B?</p></li><li><p><strong>Strategic alignment:</strong> Does it align with Q1 priorities?</p></li></ul><p>A single query like, "What's the most important tech debt item?" fails because this requires:</p><ol><li><p>Reading <code>TECH_DEBT.md</code> to understand what the 12 items even are.</p></li><li><p>For EACH item, querying <code>error_logs</code>to get error frequency.</p></li><li><p>Cross-referencing with <code>customer_data</code> to see tier breakdown.</p></li><li><p>Checking <code>support_tickets</code>to see complaint volume.</p></li><li><p>Reading <code>engineering_standards</code> in the knowledge base to see whether any items violate core principles.</p></li><li><p>Reading <code>Q1_roadmap</code> to check strategic alignment.</p></li><li><p>Synthesizing all of this into a prioritized recommendation.</p></li></ol><p>This is where a retrieval agent can be helpful in orchestrating multiple queries across different indices and synthesizing the results.</p><h2>Steps</h2><h3><strong>Preparing the test dataset</strong></h3><p>We'll create four indices: a knowledge base with internal documentation, error logs, support tickets, and customer data.</p><p>You can create the indices, index the data, and create the agent using one of the following:</p><ul><li><p><strong>Kibana Dev Tools:</strong> Using the Elasticsearch requests provided below.</p></li><li><p><strong>Jupyter Notebook:</strong> Using the <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/notebook.ipynb">complete notebook</a> written for this article.</p></li></ul><h2>Create the indices</h2><p>Open Kibana Dev Tools, and run the following requests to create each index with its mapping and bulk data. Here's an example of the knowledge index structure and data to be indexed:</p>PUT customer_data
{
  "mappings": {
    "properties": {
      "user_id": { "type": "keyword" },
      "customer_tier": { "type": "keyword" },
      "company_name": { "type": "text" },
      "mrr": { "type": "float" },
      "joined_at": { "type": "date" }
    }
  }
}

POST customer_data/_bulk
{"index":{}}
{"user_id":"enterprise_user_01","customer_tier":"enterprise","company_name":"Acme Corp","mrr":2500.00,"joined_at":"2023-01-15"}
{"index":{}}
{"user_id":"enterprise_user_02","customer_tier":"enterprise","company_name":"GlobalTech Inc","mrr":4200.00,"joined_at":"2022-08-20"}
{"index":{}}
{"user_id":"enterprise_user_05","customer_tier":"enterprise","company_name":"DataFlow Systems","mrr":3100.00,"joined_at":"2023-06-01"}
{"index":{}}
{"user_id":"user_001","customer_tier":"free","company_name":"","mrr":0,"joined_at":"2024-03-15"}
{"index":{}}
{"user_id":"user_002","customer_tier":"free","company_name":"","mrr":0,"joined_at":"2024-05-20"}
{"index":{}}
{"user_id":"user_045","customer_tier":"pro","company_name":"SmallBiz LLC","mrr":49.00,"joined_at":"2024-01-10"}
{"index":{}}
{"user_id":"user_089","customer_tier":"pro","company_name":"StartupXYZ","mrr":49.00,"joined_at":"2024-02-28"}<p>Full requests for all indices:</p><ul><li><p><strong>Knowledge index:</strong> <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/elasticsearch_requests/knowledge.txt">knowledge.txt</a></p></li><li><p><strong>Error logs index:</strong> <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/elasticsearch_requests/error_logs.txt">error_logs.txt</a></p></li><li><p><strong>Support tickets index:</strong> <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/elasticsearch_requests/support_tickets.txt">support_tickets.txt</a></p></li><li><p><strong>Customer data index:</strong> <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/elasticsearch_requests/customer_data.txt">customer_data.txt</a></p></li></ul><p>The raw JSON files with the dataset are also available:</p><ul><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/dataset/knowledge.json">knowledge.json</a></p></li><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/dataset/error_logs.json">error_logs.json</a></p></li><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/dataset/support_tickets.json">support_tickets.json</a></p></li><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/dataset/customer_data.json">customer_data.json</a></p></li></ul><h2>Local project files</h2><p>Create the following Markdown (MD) files in your project. These files look like this:</p># Tech Debt Items

## AUTH-001: Token refresh race condition
- **Module**: src/auth/refresh.ts
- **Symptom**: Users randomly logged out
- **Estimate**: 3 days

## EXPORT-002: CSV export timeout on large datasets
- **Module**: src/export/csv.ts
- **Symptom**: Timeout after 30s for &gt;10k rows
- **Estimate**: 2 days

...<p>Full files:</p><p></p><ul><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/TECH_DEBT.md">TECH_DEBT.md</a>: Tech debt items list.</p></li><li><p><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/REQUIREMENTS.md">REQUIREMENTS.md</a>: FlowDesk Q1 2025 requirements.</p></li></ul><p>This ties directly to the tech debt items and gives the agent clear priorities to work with when cross-referencing with the Elasticsearch data.</p><h2>Create an agent with Agent Builder</h2><p>We'll now create an agent capable of running analytics queries with ES|QL to provide us with app usage information while also capable of searching to provide us info from Knowledge Base (KB) in unstructured text format.</p><p>We're using the <a href="https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/tools#built-in-tools">built-in tools</a> since they cover search and analytics on any index. Agent Builder also supports custom tools for more specialized operations, like scoping an index or adding ES|QL dynamic parameters, but that's beyond our scope here.</p><p>You can create the agent using the curl request in <a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/subagents-with-elastic-agent-builder/elasticsearch_requests/create_agent.txt">create_agent.txt</a>.</p>curl -X POST "https://${KIBANA_URL}/api/agent_builder/agents" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "tech-debt-advisor",
    "name": "Tech Debt Prioritization Agent",
    "description": "I help prioritize technical debt by analyzing error logs, support tickets, customer impact, and aligning with engineering standards and roadmap priorities.",
    "avatar_color": "#BFDBFF",
    "avatar_symbol": "TD",
    "configuration": {
      "instructions": "This agent helps prioritize technical debt items. Use the following indices:\n\n- knowledge: Engineering standards, policies, and roadmap priorities\n- error_logs: Production error frequency by module\n- support_tickets: Customer complaints and their urgency\n- customer_data: Customer tier information (enterprise, pro, free)\n\nWhen analyzing tech debt:\n1. Check error frequency in error_logs\n2. Cross-reference affected users with customer_data to understand tier impact\n3. Count support tickets and note urgency markers\n4. Check knowledge base for relevant policies and Q1 priorities\n5. Synthesize findings into prioritized recommendations",
      "tools": [
        {
          "tool_ids": [
            "platform.core.search",
            "platform.core.list_indices",
            "platform.core.get_index_mapping",
            "platform.core.get_document_by_id",
            "platform.core.execute_esql",
            "platform.core.generate_esql"
          ]
        }
      ]
    }
  }'<p>You’ll get this response if everything went OK:</p>{
  "id": "tech-debt-advisor",
  "type": "chat",
  "name": "Tech Debt Prioritization Agent",
  "description": "I help prioritize technical debt by analyzing error logs, support tickets, customer impact, and aligning with engineering standards and roadmap priorities.",
  ...
}<p>The agent will be available in Kibana, so you can now chat with it if you want:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltb05460b667943ed6/6a170cb52867142a3193e379/c655ec6b9b1cc2fa1ab3cc13d289e7b96a543284-815x784.png" alt="Chat with a new agent in Kibana, creating a chart with clients sorted by monthly recurring revenue." /><h3><strong>Configure the agent as Claude Code tool</strong></h3><p>The agent we just created will expose an <a href="https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/mcp-server">MCP server.</a> Let's add the MCP server to Claude Code using the already-generated API key:</p>claude mcp add --transport http agentbuilder https://${KIBANA_URL}/api/agent_builder/mcp --header "Authorization: ApiKey ${API_KEY}"<p>We can check the connection status using <code>claude mcp get agentbuilder</code>.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4d9034e6312b1aa3/6a170cb6c1e8a59e95f88318/ba5fbc144f9e29151b8628dffd33dc74b12deece-499x177.png" alt="Code for &quot;Claude MCP get agentbuilder." /><h3><strong>Create a subagent that uses the tool</strong></h3><p></p><p>Now that we have the Agent Builder available as a set of MCP tools, we can create a subagent in Claude Code that will use all or some of those tools, in combination with Claude Code ones.</p><p></p><p>Claude Code recommends using its agent creator tool for this step:</p><p></p><p>1. Type <code>/agents</code> in Claude Code.</p><p>2. Choose <strong>Create new agent</strong>.</p><p>3. Select <strong>Project scope</strong> so that it's only available for this project. (This is the recommended setting to avoid agent overflow.)</p><p>4. Select <strong>Generate with Claude (recommended)</strong>.</p><p>5. Type in the description: "Agent that analyzes technical debt by querying Elasticsearch for error logs, support tickets, customer data, and engineering knowledge base. Use this agent when you need to prioritize tech debt items based on business impact."</p><p>6. In “Select tools,” choose <strong>Advanced options</strong> and select the tools we defined on the agent creation.</p>Individual Tools:
☒ platform.core.search (agentbuilder)
☒ platform.core.list_indices (agentbuilder)
☒ platform.core.get_index_mapping (agentbuilder)
☒ platform.core.get_document_by_id (agentbuilder)
☒ platform.core.execute_esql (agentbuilder)
☒ platform.core.generate_esq (agentbuilder)<p>7. Select <strong>[ Continue ]</strong>.</p><p>Now choose the model. For planning tasks, the recommendation is to use Opus due to its significant reasoning capacity. So let's select that and continue.</p><p>Finally, choose the background color for our subagent text and confirm.</p><p>Claude automatically names our subagent based on the description (for example, <code>tech-debt-analyzer</code>).</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/bltc9ab15478a2f3a77/6a170cb8b0367d3ed472bd75/f01ac4c9f30fbcbed7fc69881aae9ff72c4616a0-869x521.png" alt="Code for creating a new subagent" /><h2>Testing the agent</h2><p>Once the agent has been created, we can test it with a complex prioritization question that requires multistep reasoning:</p>&gt; Based on TECH_DEBT.md, which items should we prioritize for our 2-week sprint?
&gt; Use the tech-debt-analyzer agent to check error frequency, customer impact,
&gt; support ticket volume, and alignment with engineering standards.<img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt81a604f43091d27a/6a170cb90e2e49471441a165/d76d972ab5b07e6d35bdf3036cb5ee3c080c7156-749x239.png" alt="Code to demonstrate testing the agent with a complex prioritization question." /><p>Watch how the agent orchestrates multiple queries:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt093a3a5425cccb68/6a170cbb7d8d671c6570e775/c49b56c366576406586ba03f694d2bfb09d30895-875x96.png" alt="Code to demonstrate how the agent orchestrates multiple queries." /><p>And will give you a comprehensive analysis of the local files combined with Elasticsearch data:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8d9193f977e5fbbc/6a170cbdc1e8a5779ff8831c/084c532b4c9e993e53810738ae1da1fd4af1f025-1228x693.png" alt="A comprehensive analysis of the local files combined with Elasticsearch data." /><p>This demonstrates why a single query fails and an agent succeeds: It orchestrates five or more queries across different indices, correlates the data, and synthesizes a recommendation that contradicts the naive "fix highest error count" approach.</p><p>By typing <code>/context</code>, we can see how much context each of the MCP tool's definitions uses and our subagent's prompt. Keep an eye on this overhead when creating subagents.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt8c6475d26fa91b2d/6a170cbfd7c02246d5de64e5/3a6f528a9cae7b7fbf17f1b97e13c51c78c1b8b4-666x391.png" alt="Code that shows how much context each of the MCP tool's definitions uses and our subagent's prompt." /><h2>Start planning</h2><p>We can now start planning using local files, the internet, and our Elasticsearch knowledge as information sources.</p><p>Ask something like:</p>"Based on our requirements defined in REQUIREMENTS.md, use the planning agent
to create a detailed implementation plan, prioritizing tasks according to
business impact. Use the tech-debt-analyzer agent to query about internal
company knowledge and make analytical queries about error patterns and
customer impact."<p>Note that Claude decides to run the Elasticsearch data analysis and the local documentation reading in parallel, following the hub-and-spoke orchestration pattern.</p><p>After the analysis, you should get a plan that prioritizes based on actual business data rather than on assumptions. This context will make your AI coding experience much more reliable, as you can feed this plan directly to the agent and execute step by step:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt76067b358ead61bf/6a170cc04a531bb59136a9ba/cfa5c6c44425d6e73355116e08082a33699915a3-961x873.png" alt="Data analysis results that provide an implementation plan prioritized based on actual business data rather than on assumptions." /><p>The more details you provide and the more focused the instructions are, the better the quality of the plan will be. If you have an existing codebase, it will suggest the code changes.</p><h2>Conclusion</h2><p>Subagents are a great tool to offload specific tasks where we only need the final result for the main chat (without going through how we got there), keeping the chat flow focused.</p><p>By choosing the right orchestration pattern (sequential, parallel, or hub-and-spoke) and handling the context properly, we can build efficient and maintainable agent systems.</p><p>Elastic Agent Builder and its MCP feature allow us to access our data using a retrieval subagent to facilitate planning and coding by combining local (files, source code), external (internet), and internal (Elasticsearch) sources. The key insight is that agents add value not for simple queries but when you need multistep reasoning that builds on previous results and synthesizes information from multiple sources.</p><h2>Resources</h2><ul><li><p><a href="https://code.claude.com/docs/en/sub-agents">Claude Code Subagents</a></p></li><li><p><a href="https://www.elastic.co/elasticsearch/agent-builder">Elastic Agent Builder</a></p></li><li><p><a href="https://www.elastic.co/docs/explore-analyze/ai-features/agent-builder/mcp-server">Agent Builder MCP</a></p></li></ul>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/subagents-with-elastic-agent-builder</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/subagents-with-elastic-agent-builder</guid>
    <category><![CDATA[Agentic AI]]></category>
    <dc:creator><![CDATA[Gustavo Llermaly]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt75bf7ebc5c2c72a8/6a170cc26f7f04f6ba9148b4/bfeb78b687bd930371364ee7dd0341ae90004349-1280x720.png" length="0" type="image/png"/>
    <pubDate>Tue, 03 Mar 2026 00:00:00 GMT</pubDate>
  </item>
  <item>
    <title><![CDATA[Building multilingual RAG with Elastic and Mistral]]></title>
    <description><![CDATA[Building a multilingual RAG application using Elastic and Mixtral 8x22B model]]></description>
    <content:encoded><![CDATA[<p><a href="https://mistral.ai/news/mixtral-8x22b">Mixtral 8x22B</a> is the most performant open model, and one of its most powerful features is fluency in many languages; including English, Spanish, French, Italian, and German.</p><p>Imagine a multinational company with support tickets and solutions in different languages and wants to take advantage of that knowledge across divisions. Currently, knowledge is limited to the language the agent speaks. Let's fix that!</p><p>In this article, I’m going to show you how to test Mixtral’s language capabilities, by creating a multilingual RAG system.</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt4116efa3368e0387/6a17117a1949f76a59e7ab36/27ba7e0cdf3d484b5c9e697702b9a63bff49b82b-1440x868.png" alt="Building multilingual RAG with Elastic and Mistral diagram" /><p><em>You can follow the notebook to reproduce this article's example </em><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/building-multilingual-rag-with-elastic-and-mistral/building_multilingual_rag_with_elastic_and_mistral.ipynb"><em>here</em></a></p><h3>Steps</h3><ol><li><p><a href="https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral#creating-endpoints">Creating embeddings endpoint</a></p></li><li><p><a href="https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral#creating-mappings">Creating mappings</a></p></li><li><p><a href="https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral#indexing-data">Indexing data</a></p></li><li><p><a href="https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral#asking-questions">Asking questions</a></p></li></ol><h2>Creating embeddings endpoint</h2><p>Our support tickets for this example will come in English, Spanish, and German. The Mistral embeddings model is not multilingual, but we can generate <a href="https://www.elastic.co/search-labs/blog/multilingual-vector-search-e5-embedding-model">multilingual embeddings</a> using the e5 model, so we can index text on different languages and manage it as a single source, giving us a much richer context.</p><p>To create e5 multilingual embeddings you can use Kibana:</p><img src="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt0aadfb7eeddd9754/6a17117c6234e00fc6db1ae8/a691763d2976a23d7d82177b6a7e8ad31051b913-800x549.gif" alt="Creating a multilingual endpoint with Kibana" /><p>Or the _inference API:</p>PUT _inference/text_embedding/multilingual-embeddings
 {
    "service": "elasticsearch",
    "service_settings": {
        "model_id": ".multilingual-e5-small",
        "num_allocations": 1 ,
        "num_threads": 1
    }
}
<h2>Creating Mappings</h2><p>For the mappings we will use <a href="https://www.elastic.co/search-labs/blog/semantic-search-simplified-semantic-text">semantic_text</a> mapping type, which is one of my favorite features. It handles the process of chunking the data, generating embeddings, and querying embeddings for you!</p>PUT multilingual-mistral
{
  "mappings": {
    "properties": {
      "super_body": {
        "type": "semantic_text",
        "inference_id": "multilingual-embeddings"
      }
    }
  }
}
<p>We call the text field <code>super_body</code> because with a single mapping type it will handle chunks and embeddings.</p><h2>Indexing data</h2><p>We will index a couple of support tickets with problems and solutions in two languages, and then ask a question about problems within many documents in a third.</p><p>The following documents will be added to the index:</p><p></p><p>1. English Support Ticket: Calendar Sync Issue</p><p></p><p><em>Support Ticket #EN1234</em> <strong>Subject</strong>: Calendar sync not working with Google Calendar</p><p><strong>Description</strong>: I'm having trouble syncing my project deadlines with Google Calendar. Whenever I try to sync, I get an error message saying "Unable to connect to external calendar service."</p><p><strong>Resolution</strong>: The issue was resolved by following these steps:</p><ol><li><p>Go to Settings &gt; Integrations</p></li></ol><p></p><ol><li><p>Disconnect the Google Calendar integration</p></li></ol><p></p><ol><li><p>Clear browser cache and cookies</p></li></ol><p></p><ol><li><p>Reconnect the Google Calendar integration</p></li></ol><p></p><ol><li><p>Authorize the app again in Google's security settings</p></li></ol><p>The sync should now work correctly. If problems persist, ensure that third-party cookies are enabled in your browser settings.</p><p></p><p>2. German Support Ticket: File Upload Problem</p><p></p><p><em>Support-Ticket #DE5678</em> <strong>Betreff</strong>: Datei-Upload funktioniert nicht</p><p><strong>Beschreibung</strong>: Ich kann keine Dateien mehr in meine Projekte hochladen. Jedes Mal, wenn ich es versuche, bleibt der Ladebalken bei 99% stehen und dann erscheint eine Fehlermeldung.</p><p><strong>Lösung</strong>: Das Problem wurde durch folgende Schritte gelöst:</p><ol><li><p>Überprüfen Sie die Dateigröße. Die maximale Uploadgröße beträgt 100 MB.</p></li></ol><p></p><ol><li><p>Deaktivieren Sie vorübergehend den Virenschutz oder die Firewall.</p></li></ol><p></p><ol><li><p>Versuchen Sie, die Datei im Inkognito-Modus hochzuladen.</p></li></ol><p></p><ol><li><p>Wenn das nicht funktioniert, leeren Sie den Browser-Cache und die Cookies.</p></li></ol><p></p><ol><li><p>Als letzten Ausweg, versuchen Sie einen anderen Browser zu verwenden.</p></li></ol><p>In den meisten Fällen lag das Problem an zu großen Dateien oder an Interferenzen durch Sicherheitssoftware. Nach Anwendung dieser Schritte sollte der Upload funktionieren.</p><p></p><p>3. Marketing Campaign Ideas (noise)</p><p></p><p><em>Q3 Marketing Campaign Ideas</em></p><ol><li><p>Social media contest: "Share Your Productivity Hack"</p><ul><li><p>Users share tips using our software, best entry wins a premium subscription.</p></li></ul></li></ol><p></p><ol><li><p>Webinar series: "Mastering Project Management"</p><ul><li><p>Invite industry experts to share insights using our tool.</p></li></ul></li></ol><p></p><ol><li><p>Email campaign: "Unlock Hidden Features"</p><ul><li><p>Series of emails highlighting lesser-known but powerful features.</p></li></ul></li></ol><p></p><ol><li><p>Partner with a productivity podcast for sponsored content.</p></li></ol><p></p><ol><li><p>Create a "Project Management Memes" social media account for lighter, shareable content.</p></li></ol><p></p><p>4. Mitarbeiter des Monats (noise)</p><p></p><p><em>Mitarbeiter des Monats: Juli 2023</em></p><p>Wir freuen uns, bekannt zu geben, dass Sarah Schmidt zur Mitarbeiterin des Monats Juli gewählt wurde!</p><p>Sarah hat außergewöhnliche Leistungen in folgenden Bereichen gezeigt:</p><ul><li><p>Kundenbetreuung: Sarah hat durchschnittlich 95% positive Bewertungen erhalten.</p></li></ul><p></p><ul><li><p>Teamarbeit: Sie hat maßgeblich zur Verbesserung unseres internen Wissensmanagementsystems beigetragen.</p></li></ul><p></p><ul><li><p>Innovation: Sarah hat eine neue Methode zur Priorisierung von Support-Tickets vorgeschlagen, die unsere Reaktionszeiten um 20% verbessert hat.</p></li></ul><p>Bitte gratulieren Sie Sarah zu dieser wohlverdienten Anerkennung!</p><p>This is how a document will look like inside Elasticsearch:</p>{
    "took": 9,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": 0.9155389,
        "hits": [
            {
                "_index": "multilingual-mistral",
                "_id": "1",
                "_score": 0.9155389,
                "_source": {
                    "super_body": {
                        "text": "\n        _Support Ticket #EN1234_\n        **Subject**: Calendar sync not working with Google Calendar\n\n        **Description**:\n        I'm having trouble syncing my project deadlines with Google Calendar. Whenever I try to sync, I get an error message saying \"Unable to connect to external calendar service.\"\n\n        **Resolution**:\n        The issue was resolved by following these steps:\n        1. Go to Settings &gt; Integrations\n        2. Disconnect the Google Calendar integration\n        3. Clear browser cache and cookies\n        4. Reconnect the Google Calendar integration\n        5. Authorize the app again in Google's security settings\n\n        The sync should now work correctly. If problems persist, ensure that third-party cookies are enabled in your browser settings.\n    ",
                        "inference": {
                            "inference_id": "multilingual-embeddings",
                            "model_settings": {
                                "task_type": "text_embedding",
                                "dimensions": 384,
                                "similarity": "cosine",
                                "element_type": "float"
                            },
                            "chunks": [
                                {
                                    "text": "passage: \n        _Support Ticket #EN1234_\n        **Subject**: Calendar sync not working with Google Calendar\n\n        **Description**:\n        I'm having trouble syncing my project deadlines with Google Calendar. Whenever I try to sync, I get an error message saying \"Unable to connect to external calendar service.\"\n\n        **Resolution**:\n        The issue was resolved by following these steps:\n        1. Go to Settings &gt; Integrations\n        2. Disconnect the Google Calendar integration\n        3. Clear browser cache and cookies\n        4. Reconnect the Google Calendar integration\n        5. Authorize the app again in Google's security settings\n\n        The sync should now work correctly. If problems persist, ensure that third-party cookies are enabled in your browser settings.",
                                    "embeddings": [
                                        0.0059651174,
                                        0.0016363655,
                                        -0.064753555,
                                        0.0093298275,
                                        0.05689768,
                                        -0.049640983,
                                        0.02504726,
                                        0.0048340675,
                                        0.08093895,
                                        ...
                                    ]
                                }
                            ]
                        }
                    }
                }
            }
        ]
    }
}
<h2>Asking questions</h2><p>Now, we are going to ask a question in Spanish:</p>Hola, estoy teniendo problemas para ocupar su aplicación, estoy teniendo problemas para sincronizar mi calendario, y encima al intentar subir un archivo me da error.<p>The expectation is retrieving documents #1 and #2, then sending them to the LLM as additional context, and finally, getting an answer in Spanish.</p><h4>Retrieving documents</h4><p>To retrieve the relevant documents, we can use this nice and short query that will run a search on the embeddings, and return the support tickets most relevant to the question.</p>GET multilingual-mistral/_search
{
   "size": 2,
   "_source": {
    "excludes": ["*embeddings", "*chunks"]
   },
  "query": {
    "semantic": {
      "field": "super_body",
      "query": "Hola, estoy teniendo problemas para ocupar su aplicación, estoy teniendo problemas para sincronizar mi calendario, y encima al intentar subir un archivo me da error."
    }
  }
}
<p><em>Notes about the parameters set:</em> <code>size: 2</code> Because we know we want the top 2 documents. <code>excludes</code> For clarity in the response. Documents are short so each one will be one chunk long.</p><h4>Answering the question</h4><p>Now we can call the Mistral completion API using the Python library to answer the question.</p>from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage

api_key = os.environ["MISTRAL_API_KEY"]
model = "open-mixtral-8x22b"

client = MistralClient(api_key=api_key)

system_message = "You are a helpful multilingual agent that helps users with their problems. You have access to a knowledge base of different languages and you must answer in the same language the question was asked."

user_message = """
## Question:

Hola, estoy teniendo problemas para ocupar su aplicación, estoy teniendo problemas para sincronizar mi calendario, y encima al intentar subir un archivo me da error. 

## Related knowledge:

Support Ticket #EN1234 Subject: Calendar sync not working with Google Calendar...
(the rest of the content of the document)

\n

Support-Ticket #DE5678 Betreff: Datei-Upload funktioniert nicht... 
(the rest of the content of the document)

ANSWER:

"""

messages = [
    ChatMessage(role="system", content=system_message),
    ChatMessage(role="user", content=user_message)
]

chat_response = client.chat(
    model=model,
    messages=messages,
)

print(chat_response.choices[0].message.content) 
<p>The answer is in perfect Spanish and on point!</p><p></p><p>Show answer</p><p></p><p>Hola, me alegra que te hayas comunicado con nosotros. Parece que hay dos problemas distintos.</p><p>En cuanto a la sincronización del calendario, puedes seguir estos pasos para resolver el problema:</p><ol><li><p>Ve a Configuración &gt; Integraciones</p></li></ol><p></p><ol><li><p>Desconecta la integración del Calendario de Google</p></li></ol><p></p><ol><li><p>Borra la caché y las cookies del navegador</p></li></ol><p></p><ol><li><p>Vuelve a conectar la integración del Calendario de Google</p></li></ol><p></p><ol><li><p>Autoriza de nuevo la aplicación en la configuración de seguridad de Google</p></li></ol><p>Si sigues teniendo problemas, asegúrate de que las cookies de terceros están habilitadas en la configuración de tu navegador.</p><p>En cuanto al problema de subir un archivo, hay varias cosas que puedes probar:</p><ol><li><p>Comprueba el tamaño del archivo. El tamaño máximo de carga es de 100 MB.</p></li></ol><p></p><ol><li><p>Desactiva temporalmente el antivirus o el cortafuegos.</p></li></ol><p></p><ol><li><p>Intenta cargar el archivo en modo incógnito.</p></li></ol><p></p><ol><li><p>Si eso no funciona, borra la caché y las cookies del navegador.</p></li></ol><p></p><ol><li><p>Como último recurso, prueba a usar un navegador diferente.</p></li></ol><p>En la mayoría de los casos, el problema se debe a archivos demasiado grandes o a interferencias causadas por software de seguridad. Al seguir estos pasos, deberías poder cargar el archivo correctamente.</p><p>¡Espero que esto te ayude a resolver tus problemas! Si tienes alguna otra pregunta, no dudes en preguntar.</p><h2>Conclusion</h2><p>Mixtral 8x22B is a powerful model that enables us to leverage data sources in different languages, being able to answer, understand, and translate in many languages. This ability– together with multilingual embeddings– allows you to have multilingual support both in the data retrieval and the answer generation stages, removing language barriers entirely.</p><p><em>If you are interested on reproducing the examples of this article, you can find the Python Notebook with the requests </em><a href="https://github.com/elastic/elasticsearch-labs/blob/main/supporting-blog-content/building-multilingual-rag-with-elastic-and-mistral/building_multilingual_rag_with_elastic_and_mistral.ipynb"><em>here</em></a></p>]]></content:encoded>
    <link>https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral</link>
    <guid isPermaLink="true">https://www.elastic.co/search-labs/blog/building-multilingual-rag-with-elastic-and-mistral</guid>
    <category><![CDATA[AI]]></category>
    <category><![CDATA[Vector Database]]></category>
    <category><![CDATA[Python]]></category>
    <dc:creator><![CDATA[Gustavo Llermaly]]></dc:creator>
    <enclosure url="https://static-www.elastic.co/v3/assets/bltefdd0b53724fa2ce/blt9cf558f36ced44dc/6a17117dd7c022520cde65a2/7dd63f367670175590e30927ef432ff93e166c84-1440x809.png" length="0" type="image/png"/>
    <pubDate>Fri, 02 Aug 2024 00:00:00 GMT</pubDate>
  </item>
  </channel>
</rss>