What The Hack - Context Quest: Optimizing AI Agents with Microsoft Foundry and Elastic Context Engine

Introduction

Precision Labs sells a business-to-business operations intelligence platform that customers use for analytics dashboards, workflow automation, and data reporting. Precision Labs keeps CRM accounts, support tickets, and knowledge base (KB) articles in Elasticsearch. Precision’s Support Copilot is built and hosted in Microsoft Foundry.

We’re going to learn how to connect a Foundry agent to an Elasticsearch datastore using the Model Context Protocol (MCP). And then we’re going to learn how you can use Elastic Context Engine to optimize your agent’s performance and token usage.

You will build two agents to answer support questions using Precision Labs’ data. First, connect Agent Mole directly to Elasticsearch and measure the work it does to discover and query the available data. Then, use Elastic’s Context Engine to build an AI Index with Knowledge Indicators (KIs). Agent Optimus will use that AI Index and its KIs to help it navigate the same sources. Run the same questions through both agents and compare their discovery calls, token usage, answer correctness, and latency to see how added context changes their behavior.

Learning Objectives

Challenges

Prerequisites

Contributors