Kishore Kanthan

KPI assistant

An assistant that finds, explains, debugs and creates KPIs and charts from questions in plain words. A fixed set of test chats decides when it is ready.

A made-up question goes to the job that fits it. Find names one KPI and runs it with the user's own access.

The problem

People ask about KPIs in their own words. Which KPI shows this? How is it worked out? Where is it used? The answers were spread over many places.

The assistant is the user-facing one of the analytics AI agents. It answers them in plain words. Ask “How many customer visits did my team make last month?” and it finds the right metric, runs it and explains the answer. But an answer can sound right and still be wrong. “It feels better” is not a release test.

Who it is for

Five groups of people use it, and each asks different questions:

  • Business users find a KPI and learn what it means.
  • Content authors find where a KPI is used, and draft new cards, charts and KPIs.
  • Data engineers see what breaks if a column changes.
  • Platform leads plan renames and moves across many pages.
  • Data product managers assess the assistant before people use it.

Safety guardrails

The assistant reaches live KPIs and content, so guardrails sit around every job:

  • It runs as the user. It has no access of its own. It shows only what the person who asks can already see.
  • It drafts, and people decide. In the first release, it never writes to the live system.
  • It never approves its own work. A person reviews every draft before anyone uses it.
  • It does not guess. When nothing matches, it says so. It never invents a KPI.
  • It does not make duplicates. Before it drafts a KPI or a chart, it looks for one that already exists. If it finds one, it points to it and does not draft a copy.
  • It does not promise what it cannot check. It never calls a change safe without the data to know.
  • The guardrails are tested. The test set has a safety group, and a safe refusal counts as a pass.

My part

An engineer on my team built the first version and laid a solid foundation. I built on it to take the assistant to a release.

The upgrade gave the assistant five jobs, and each question goes to the job that fits it:

  • Find: find the right KPI and explain what it means and how it is worked out.
  • Plan: plan a rename or a move across many pages.
  • Debug: find out why a KPI gives a wrong answer, or none. It uses the debug option built into the KPI engine.
  • Migrate: move a KPI or a page to the new setup.
  • Create: draft a new KPI, card or chart for a person to review. A developer starts from a draft, not a blank page.

My part in the release covered four things. They are the pipeline that explains each KPI, the searchable metadata, the regression agent and the test set.

A shared content library

A chart that the assistant drafts does not stay in one chat. A person reviews the draft and publishes it to a shared content library. Then everyone can find it and reuse it. The assistant checks the library first, so it never drafts a second copy of the same content.

The metadata is the product

To answer a question, the assistant must first find the right metric. It searches the names and descriptions of all the metrics. If a description is missing or vague, it picks the wrong metric, or no metric.

The assistant finds a metric by its description. A metric with no description cannot be found.

The list of metrics had two problems:

  • Missing descriptions. Many metrics had no text that explained them. A pipeline now drafts the text and a person approves it. Read KPI metadata drafts.
  • Duplicates. Many metrics were near copies of each other, and the assistant could not tell which one to use. Duplicates need a person to decide, so we grouped them and sent each group to the metric owners.

Explaining how a KPI is worked out

To explain a KPI, the assistant must see exactly how the KPI gets its number. I built the pipeline that gives it that logic.

Most KPIs come from the KPI engine. The engine already works out their logic from the parameters, so these KPIs need no extra work.

Some KPIs are too complex for the engine, so they are written in TypeScript or Python. Their code is spread across many functions. The pipeline flattens that code and parses each KPI together with every function it depends on. The model then gets the full logic in one context, not a fragment. So it can explain exactly what happened to get each number.

How a KPI written in code gets explained. Engine KPIs skip these steps, because the engine works out their logic from the parameters.

The summer interns I mentored built a related pipeline. It drafts the metadata for each KPI, and a person approves it. Read KPI metadata drafts.

The test set

Each test has a question in the user’s own words and a short note that says what a pass looks like. The tests are grouped by user and by task. The tasks are find, explain, impact, create, migrate, safety, and routing to the right part of the assistant.

Made-up tests in the same shape as the real set. A safe refusal is a pass.

Before a release, the assistant must pass a set share of the tests in each group. If one group falls below the bar, the release waits.

Real users ask follow-up questions, so the set also has short chats of five or six turns. A later turn refers back to an earlier one: “where is that used?”, “the first one”, “save it”.

One made-up test chat. Each turn has its own pass, and later turns depend on earlier ones.

Regression tests

The assistant depends on the metrics underneath it. When a metric changes, an answer can change too.

A regression agent runs after each change to the metrics or to the assistant. It asks the golden questions again. Each golden question has an answer that people agreed is correct. Some are single questions, and some are chats of many turns.

An LLM acts as the judge. It compares each new answer with the agreed answer. A match or a close match passes. Anything else fails, and a person looks at the change and decides if the new answer is correct.

Access stays with the user

The assistant never runs a metric under its own account. It runs the metric with the access of the person who asks. A shared account that can see all the data is a risk. With the user’s own access, the assistant shows only what that person can already see. Read how the data protection model works.

Made-up data. Two people ask the same question. The assistant runs it with each person's own access, so each one sees only their own rows.

Key decisions

  • Write the pass before the answer. Each test says what a good answer looks like, so a reviewer checks against it, not by feel.
  • Test chats, not only questions. People refer back to earlier answers, so the tests do too.
  • A safe refusal is a pass. “No clear match” and “I cannot save that” are correct answers, and the set tests for them.
  • Split by user and by task. A weak area shows up on its own and holds the release.
  • Run as the user. The assistant has no access of its own, so it can never show more than the person asking can see.

What I’d do differently

Build the test set before the first prompt. It is the only way to tell whether a change made the assistant better.