DEV Community

Cover image for Your data agent can have perfect context and still be wrong
Conor Bronsdon
Conor Bronsdon

Posted on Originally published at chainofthought.show

Your data agent can have perfect context and still be wrong

WisdomAI sponsored this episode.

If you connect an LLM to your warehouse and pour in schema, catalogs, and docs, the model still has to guess which of it matters. You have not guaranteed that the number in chat matches what finance would sign off on.

On Chain of Thought, WisdomAI co-founder and CPO Kapil Chhabra argues that enterprise stacks are settling into three layers: raw data, a shared context layer, and a task-specific harness on top. Context stops the model from guessing what ARR or churn means. The harness is what plans queries, catches dialect mistakes, and repairs failures before the user sees an answer. His analogy is a hospital: the model is the surgeon, the context is the patient history, and you still cannot operate without the hospital around them.

Why does more context not fix wrong answers?

Context is how you encode company truth: metric definitions, fiscal calendars, and examples of queries that look right in your environment. Kapil Chhabra says that without it, models are flying blind on accuracy. He also warns that stuffing the context window with everything you own is a bad trade. You burn tokens, and the model still has to guess which slice matters for this prompt.

That matches how I think about context relevance in RAG evals. A high score means retrieval returned passages that actually bear on the question. A low score means the model is reading noise. Fixing a bad answer starts with knowing whether retrieval or generation failed. Padding context with marginal text can make both worse.

For analytics agents, the gap shows up in SQL and Python as well as prose. Kapil Chhabra gives a concrete tripwire:

time zone conversion in Clickhouse, LLMs, even the best LLMs right now are making a mistake three out of 10 times.

Kapil Chhabra, CPO, WisdomAI

Same question, same context fed to a frontier model versus a specialized analytics harness: Kapil Chhabra reports a 3x difference in time to the first answer and a 3.4x difference in cost in their side-by-side test. Context was held constant. The difference was workflow around the model.

Is a semantic layer enough for chat over data?

Data teams already maintain semantics for BI tools. Chat breaks the old contract. Users ask anything. Q1 might mean fiscal quarter to finance and calendar quarter to marketing. Kapil Chhabra is blunt about the old stack:

It is necessary, but it is not sufficient.

Kapil Chhabra, CPO, WisdomAI

What he puts in the broader context layer includes natural-language rules (when finance asks about a quarter, it may mean the fiscal quarter, while marketing may mean the calendar quarter), plus worked examples that convey the nuances of good SQL and Python queries. That layer has to stay current as definitions drift. He calls that context drift and treats updates as a multiplayer problem: an SME signs off on shared definitions, while personal prefs stay in user memory, not institutional context.

If you are standing up governance for this, context management is the thread to follow across episodes on memory, harness design, and who owns definitions.

What should the harness do after context is injected?

Kapil Chhabra describes an analytics loop:

  1. Decompose the question into sub-questions aligned to each data source (warehouse SQL, Python, MCP-backed systems, docs).
  2. Generate and run those queries.
  3. Verify results before recomposing an answer.
  4. Repair errors (for example, inject deterministic timezone handling before a ClickHouse query runs).

Trust, in his framing, needs accuracy, consistency across repeated asks, governance that respects row-level access, and explainability you can audit. High criticality use cases need all four, not a one-off artifact.

Humans should still own decisions. Agents increasingly fetch and act on data without a human re-reading every row. That is why verification inside the harness matters more than another paragraph in the system prompt.

How do I tell if a fluent answer is also a good one?

Grounded text can still miss the question. Answer relevance scores whether the reply addresses what was asked, separate from whether claims match sources (faithfulness) or whether retrieval was on-topic (context relevance). Kapil Chhabra's product pattern mirrors that split: after a Live App is generated, the system can flag widgets built with full context versus widgets where it had to assume. You review assumptions, correct them, and approved fixes feed back into the context layer.

I'd treat automated judges as hints until you spot-check against humans on real business questions, the same way you would before trusting any RAG eval pipeline.

A sketch of post-answer checks:

# Sketch: separate "did we fetch the right stuff" from "did we answer the ask"
def review_agent_answer(question: str, answer: str, sql: str, ctx_used: dict) -> list[str]:
    flags = []
    if ctx_used.get("assumptions"):
        flags.append("review_assumptions:" + ", ".join(ctx_used["assumptions"]))
    if "Q1" in question and "fiscal" not in ctx_used.get("calendar_rule", ""):
        flags.append("missing_fiscal_calendar_rule")
    # Run sql in read-only sandbox; compare aggregates to a golden query when you have one
    return flags
Enter fullscreen mode Exit fullscreen mode

Checklist

  • Separate failures: low context relevance points at retrieval and chunking; plausible but wrong numbers point at harness verification and dialect-specific repair.
  • Widen context past the semantic layer: definitions plus calendar rules, ownership, and query examples SMEs would approve.
  • Require decompose, execute, verify, repair for federated questions instead of one-shot SQL from the model.
  • Score answer relevance as well as faithfulness before anyone acts on the output in Slack or a live app.
  • Flag low-confidence widgets and close the loop with SME-approved context updates when definitions drift.

The full conversation, with the transcript, is on Chain of Thought.

Subscribe to the Chain of Thought newsletter for new episodes and write-ups like this one.

Drafted with AI assistance from the episode transcripts.

Top comments (0)