Solutions · Data Agents & Text-to-SQL

The context layer for the data agent you’re building

Analytics platforms sell your team a place to ask questions. BrainBox is for the teams building that place: an AI analyst inside your product, or an internal agent for your own team. It gives the agent the business meaning your schema doesn’t carry, separately for each customer if you need it.

Business meaning, not just schema

Definitions, join paths, metrics, and rules, built from the schema and docs you already have. No months-long modeling project first.

One brain per customer

Model a data source once and reuse it for every customer. Each customer adds their own definitions on top, and isolation is enforced on the server.

Learns from every miss

Corrections and context gaps flow back into the Brain, so the agent stops repeating the same mistake.

Who it’s for

You’re not buying an analytics tool. You’re building one.

You sell analytics

An AI analyst inside your product

Your customers ask questions about their own data, and every customer is different. One calls a customer "active" after a first payment, another after thirty days of usage. One starts the fiscal year in February. Your agent needs a shared model of the sources you support, plus each customer’s own definitions, and the two can never leak into each other.

You build for your own team

An internal data agent

You already have a model, a warehouse, and a Slack channel full of data questions. You don’t want to move the team onto a new BI platform just to get context. You want the context inside the agent you’re building, over MCP or an SDK, next to the tools you already run.

The problem

Correct SQL, wrong answer

Text-to-SQL rarely fails on syntax. It fails on meaning: the agent picks a plausible table, a plausible flag, and a plausible definition, then confidently answers a different question than the one asked.

Schema only

# “How many active customers do we have in EMEA?”

SELECT COUNT(*) FROM crm_accounts
WHERE is_active = true
  AND region = 'EMEA';
  • ✗ crm_accounts is a nightly CRM mirror. Billing is the system of record.
  • ✗ is_active is a sales flag, not the definition finance reports.
  • ✗ region is the sales rep’s territory, not the customer’s billing country.

With the Brain

→ recall_domain("active customer")

← Customer: billing.customers (system of record)
  active: status = 2 AND churned_at IS NULL
          source: RevOps policy doc
  EMEA:   billing_country → ref.regions
          source: finance handbook
SELECT COUNT(*) FROM billing.customers c
JOIN ref.regions r ON r.country_code = c.billing_country
WHERE c.status = 2 AND c.churned_at IS NULL
  AND r.region = 'EMEA';

Illustrative example. A better model can’t fix this. The knowledge was never in the schema.

What the agent gets

Start from the business logic you already have

Connect Postgres or Trino, your dbt project, and the docs that explain them, such as metric definitions, data dictionaries, and policy pages. BrainBox builds one model from all of them. Each source adds to the model instead of replacing it, and every fact keeps a link to the source it came from.

Entities bound to tables

Customer, Invoice, and Subscription, each mapped to the table that backs it, with the keys and join paths that connect them. The agent stops picking the legacy table with the friendlier name.

Definitions and rules

What "active," "churned," and "settled" mean, written as conditions the agent can turn into a WHERE clause, with the doc each one came from.

Metrics

Grain, expression, and time field for each shared measure, plus a metric-to-SQL compiler. If you already have dbt or MetricFlow definitions, import them.

Column semantics

Profiles (enum values, cardinality, null rate, format hints) and annotations for units, encodings, and caveats. The agent knows status 2 means active before it runs a query to find out.

Vocabulary and aliases

The words your users actually type, such as "ARR," "logo," and "book of business," mapped to the entities and fields they mean.

Lineage

Column-level lineage across the ETL boundary, recording what fed each column upstream. This helps when two columns look identical but aren’t.

For databases, BrainBox reads schema metadata and, if you opt in, column profiles (sampled statistics). Your experts review what ingestion proposes, and their edits survive the next re-ingest.

If you sell analytics

Model each source once, then compose per customer

Your product supports a set of sources, such as Shopify, Stripe, or a standard ERP schema. Build a brain for each source once. Each customer gets a tenant that reads the shared brains it uses and writes only to its own private brain on top.

SharedShopify brain
SharedStripe brain
SharedERP brain
read by ↓
Tenant · Customer AShopify + Stripe, plus: “active means 30 days since last order,” “fiscal year starts Feb 1”
Tenant · Customer BShopify + ERP, plus: “exclude wholesale accounts,” “GMV is net of refunds”

Isolation that doesn’t depend on the agent

A tenant API key resolves on the server to that customer’s brain and the shared brains it may read. Nothing your agent passes as a parameter can reach another tenant.

Customer lessons improve the shared brain, with an admin’s approval

When one customer’s correction applies to everyone using the same source, an admin can promote it into the shared brain. Agents can’t promote anything with their own tokens.

More on this pattern: multi-tenant agent context.

Beyond one query

Text-to-SQL answers a question. Research answers why.

Questions like “why did mid-market retention drop in Q3?” take twenty queries, three dead ends, and a chart. An agent with a code sandbox can run that loop on its own. Without context, most of the loop goes to rediscovering your business: which customer table is real, whether refunds are already netted out, what status 4 means.

  1. 1Experimental

    Plan

    research_task

    The Brain assembles the entities, metrics, rules, past findings, and saved procedures relevant to the question before the agent writes any SQL.

  2. 2

    Query and compute

    your sandbox

    The agent writes SQL and Python, runs them against a read-only warehouse role, looks at the result, and decides what to try next.

  3. 3

    Resolve, don’t rediscover

    recall_domain

    When it reaches an unfamiliar term or table, it asks the Brain. It doesn’t run SELECT DISTINCT queries to guess what a column means.

  4. 4

    Write back

    save_wiki_page · create_learning

    Findings are filed as a wiki page, and corrections become learnings. The next investigation starts from this one.

Without a context layer

Every investigation starts from zero. The agent spends its first dozen steps on exploratory queries, and what it figures out is lost when the session ends. Next week, a teammate’s agent pays the same cost again.

With one

Every step starts grounded, and every investigation leaves something behind: a finding in the Wiki, a corrected definition, a saved procedure for “how we investigate a retention drop.” Research builds on earlier research instead of repeating it.

The build guide: an internal research agent

BrainBox supplies the context and the memory, and the sandbox is yours. The guide covers the architecture, sandbox guardrails, the tool surface, what to write back, and how to tell whether it’s working.

Read it ↗
Improves with use

Every wrong answer becomes context

When the agent is corrected, the correction is recorded. When it can’t find something, the gap is logged. Your team approves what changes, and the Brain absorbs it.

Learnings

A user says “that’s gross, we report net.” The agent records it with create_learning. Once a reviewer promotes it, the Brain absorbs it.

Context gaps

report_context_gap files what the agent couldn’t find into a review queue that removes duplicates, so you fix the gaps users actually hit.

Staleness signals

Definitions that recent events keep contradicting are flagged for review, so they don’t quietly go out of date.

Change history

Every change records what was added, by which source, and why. You can see exactly what moved and who approved it.

On the roadmap: evals grounded in the Brain, and the exact facts behind each answer returned with the answer. See what’s shipped and what isn’t on the Capability Map.

Fits your stack

Use it from the agent you already have

MCP, three endpoints

One project, a whole org, or one tenant’s brain plus the shared brains it may read. Works with Claude, ChatGPT, Codex, or your own orchestrator.

SDK and REST

The same tools from your backend, for when grounding runs inside your product rather than through an agent.

CLI

Push a schema, run a connector, and inspect the Brain from the terminal or from CI.

Local dev server

brainbox-mcp serves SQL data tools alongside the Brain on a developer’s machine, which is the fastest way to prototype a data agent.

Developer platform · Quickstart

Example deployment

A text-to-SQL company uses BrainBox to give its structured-data agent the business context that the schema alone doesn’t carry: definitions, rules, and vocabulary.

FAQ

Questions teams ask

Do we need a semantic layer or dbt before we start?
No. Connect a schema and the docs that explain it (metric definitions, data dictionaries, policy pages) and BrainBox builds the model from those. If you already have dbt or MetricFlow metrics, import them so you don’t maintain two copies.
Does BrainBox see our data?
For databases, BrainBox reads schema metadata and, if you opt in, column profiles, which sample rows for statistics. Your agent runs queries against your warehouse with your credentials, and BrainBox supplies the context.
Does BrainBox run the SQL?
In production, no. Your agent or harness executes queries, which keeps credentials, row limits, and cost controls with you. For local development, the brainbox-mcp dev server includes SQL tools so you can try the full loop on your own machine.
How is this different from a BI tool with an AI assistant?
A BI tool is where your users go to ask questions. BrainBox has no user interface for asking questions. It is the context layer inside whatever agent you build, served over MCP and an SDK, and it can run as a separate brain per customer if you’re selling that agent.
How is each customer’s context kept separate?
Each customer gets a tenant with a private brain that sits on top of the shared brains you choose. A tenant API key resolves on the server to that customer’s brain and nothing else, so no parameter your agent passes can reach another tenant. Only an admin can promote what you learn from one customer into the shared brain.
Can we measure answer accuracy?
Today, misses are captured as learnings and context gaps, and you can review both. Evals grounded in the Brain are on our roadmap, as is attaching the exact facts behind each answer.

Your agent writes the SQL. The Brain knows what it means.

Bring the agent you’re building. We’ll show you its context layer on your own schema and docs.

Book a Demo