Skip to main content

What a good data layer looks like for AI agents

· Do Minh Tuan · Tech Made Simple 💡

What a good data layer looks like for AI agents

Fabiane Nardon, who works on data at the Brazilian software company TOTVS, gave a talk at InfoQ about how large organisations are rebuilding their data layers for AI agents. What caught my eye was how little of it was about models. Almost all of it was about plumbing.

That matches how these projects usually go. The model choice gets argued over for weeks, then the thing ships and the real problems appear. The agent reads a stale table. It pulls half the customer database into its context because nobody built a narrower query. The monthly API bill quietly doubles and everyone looks at the ML team.

An AI agent, in this context, is a program that decides which steps to take and which tools to call instead of following one fixed path. Everything it knows about your company arrives as text in its context window, the fixed amount of text a model can consider at once. Providers charge by token, roughly a word or a fragment of one, so padding that window with irrelevant rows costs real money.

Keeping the database and the model in their lanes

The most useful idea in the talk was the split between deterministic logic and the non-deterministic behaviour of a large language model. A database returns the same answer to the same query every time. A model does not, and that variation is the whole reason you use one. The trick is deciding which questions go where.

If an agent needs last quarter's revenue, that is a query. If it needs to judge whether a support ticket sounds furious, that is a job for the model. Agents get asked to 'remember' figures that sit one SELECT away, and they invent plausible numbers instead. Nobody catches it for a week, because the numbers look reasonable.

This sounds obvious when it is written down. In delivery it is not, because the two halves usually belong to different teams with different release cycles, and the handoff between them is where the mistakes live.

Nardon described data mesh as the organisational answer to part of this. Instead of one central team owning every table, domain teams publish their own data products that other teams can discover and use. I like the framing because it puts quality where the knowledge is. The finance team understands finance data better than a central platform group ever will. The catch is governance. Without naming conventions and a catalogue someone actually maintains, a mesh turns into a pile of undocumented tables with nicer labels, and your agent is back to guessing.

She also covered low-latency database architecture. An agent that answers in real time, whether for customer support or anything resembling trading, cannot wait on a nightly batch. The database has to return the current state in milliseconds. That is an infrastructure decision, and it is much cheaper to make it before the agent exists than after.

The third piece was semantic ontologies, which is a heavy name for a shared vocabulary. An ontology defines the entities in your business and how they relate, so that 'customer' in the billing system and 'client' in the CRM resolve to the same thing. For an agent this matters because it turns three guesses into one lookup. Building one is slow, unglamorous work, and I would not start it until two systems genuinely disagree about the same noun.

The part that decides your bill

Then there is the context window and token overhead. Nardon's suggestion was to filter before you feed, using dynamically selected tools rather than dumping raw results into the prompt. The write-up used MCP for this piece, and I will flag that the acronym gets used loosely in these discussions. Treat the label as 'tool selection' and ask what a vendor actually means by it. The underlying advice holds. A pre-processing step that aggregates, filters or embeds data before the model sees it cuts cost and improves answers at the same time.

On the engineering side, two habits pay for themselves. Validate and sanitise anything a user can type before it reaches the model, because prompt injection is still the easiest way to make an agent misbehave. And build narrow endpoints instead of handing over whole tables. A route like GET /api/customer-summary/:id that returns only the fields a task needs beats a general 'get customer' call on both tokens and response time.

One thing I would add: version your prompts and your data contracts together. When a field gets renamed, the agent's behaviour changes, and nobody notices until a customer does.

Where the money argument gets shaky

The business case usually lands on three claims. Lower token spend, better customer answers, more automation. The first one is real and you can measure it. The other two depend on data quality, which is exactly what was broken before AI arrived. Buying an agent does not fix a CRM where half the records are duplicates.

If I were advising a small team, I would spend the first month on one well-defined workflow with clean inputs. Measure the token cost per task before and after. Then widen the scope. The projects that struggle are usually the ones that buy a platform first and go looking for a use case afterwards.

What I still want to know is how you keep a data mesh honest when every domain team has its own deadlines and none of them are rewarded for publishing clean data. That, more than any model release, decides whether the agent is still useful in a year.

Written with AI assistance, reviewed and edited by Do Minh Tuan.