OpenSearch
← Back to Blog
OpenSearchNovember 21, 2026·4 min read

Spotting deceptive AI agent results in OpenSearch

From manual queries to AI‑driven agents

For years we typed Lucene queries, checked the syntax, and trusted the response. The new OpenSearch AI agents promise to translate natural language into queries for us, but that convenience can also hide mistakes. An answer that seems right may have been generated from a malformed query or from the wrong index.

Editorial illustration for Spotting deceptive AI agent results in OpenSearch

Why the illusion happens

The agent builds a query behind the scenes, runs it, and then formats the result. If the query returns zero hits, the agent often fills the gap with a plausible‑sounding paragraph. The output looks successful, yet the underlying data never supported it. Bianca Lewis of OpenSearch points out that "we are not querying like humans anymore" – the AI abstracts the query step, so we lose the visibility that used to protect us.

Symptoms of a hidden mistake

Auditing the query pipeline

The first line of defence is to log the exact query the agent sends to OpenSearch. Most vendors expose a debug flag or a request interceptor. If the platform does not, you can add a thin proxy that records the HTTP payload.

# Example: simple Node.js proxy that logs incoming OpenSearch requests
const http = require('http');
const { createProxyServer } = require('http-proxy');

const proxy = createProxyServer({ target: 'http://localhost:9200' });

http.createServer((req, res) => {
  let body = [];
  req.on('data', chunk => body.push(chunk));
  req.on('end', () => {
    const payload = Buffer.concat(body).toString();
    console.log('--- OpenSearch request ---');
    console.log(req.method, req.url);
    console.log(payload);
    // forward the request
    proxy.web(req, res);
  });
}).listen(9201, () => console.log('Proxy listening on 9201'));

With the raw JSON in hand you can verify:

Vendor‑agnostic safeguards

Even if your OpenSearch deployment is managed by a cloud provider, you can add checks that do not rely on proprietary tooling.

  1. Validate hit count – after the agent returns a summary, query _count with the same filter you extracted from the logs. If the count is zero, raise a warning.
  2. Cross‑reference document IDs – embed the first document ID in the agent's answer (e.g., "Document ID: abc123"). A downstream test can fetch that ID and compare fields.
  3. Time‑window sanity check – compare the earliest and latest timestamps in the result set with the window the user asked for.
  4. Require explicit provenance – configure the agent to always append a small block like "Source: index=logs‑2024‑11, hits=7" at the end of the answer.

Putting it into practice

Imagine a support dashboard that asks the agent: "How many failed login attempts did we see yesterday?" The answer reads, "We recorded 23 failed logins, most of them from IP 192.0.2.5." Without safeguards you might trust that number. Using the steps above you would:

  1. Pull the logged query from the proxy – it shows a range filter that ends at "2024‑11‑20T00:00:00Z" instead of the intended "2024‑11‑21".
  2. Run a manual _count with the same filter – the result is 0.
  3. Trigger an alert that the agent's answer is based on an empty set.

The dashboard can then surface a message like "No data found for the requested period; the previous answer was generated from a fallback template." This prevents a false sense of security.

Limitations to keep in mind

The approach assumes you have access to the HTTP traffic or can enable logging on the OpenSearch side. In highly restricted environments you may need to work with the security team to add a read‑only audit role. Also, the proxy adds a tiny latency; for real‑time alerting you might prefer a built‑in request interceptor if the vendor provides one.

Takeaway

AI agents make life easier, but they also hide the query step that used to be our safety net. By watching for overly smooth language, logging the generated query, and adding a few sanity checks you can catch the mistakes that look like successes before they cause damage.

Ready to find your automation candidates?

We run a structured AI Readiness Assessment for SMEs — two weeks, concrete output, no fluff. You’ll hear back directly from Kerim.

Start with an AI Assessment

Topics

OpenSearchAI AgentsObservabilityDebugging