Agent-first starts with getting your logic out of the UI
Picture this. (It’s made up, but you’ve probably lived it.)
A customer asks your new AI agent, “What was conversion last week?” Two seconds later, it confidently says 3.1%.
The dashboard says 2.7%. The agent is wrong.
Nobody wrote a bug. The agent did what it was told: it went to the data and did the math. What it couldn’t reach were the little rules the dashboard had been quietly applying for years.
Leave out that bot traffic. Count this event once per session. Round revenue the way finance does.
The dashboard knew all of that. The agent didn’t. And now the customer trusts neither of them.
Where your business logic actually lives
Probably not where you think.
Ask a team where a metric is defined and they’ll point at the database, or a doc. In ours, a lot of it lives in the front end.
Nobody was sloppy. The UI was where each rule was needed first, so that’s where it got written. Then written again, for ten years.
That’s fine while the UI is the only thing asking questions. It stops being fine the day something else wants the same answer: an API customer, an export… or an agent.
The two tempting fixes
When the agent’s number doesn’t match, there are two quick fixes. Neither holds.
- Reimplement the logic for the agent. Now you have two sources of truth. They agree on day one, and by day ninety they don’t.
- Wrap the UI for the agent. The wrapper inherits every assumption the UI makes about screens, clicks and state. Now it’s a third thing to keep in sync.
Both fixes treat the agent as a special case. That’s the mistake.
What we did instead
I led the architecture of the work to pull that logic out of the UI and into one canonical query layer: one place that owns how each metric is calculated and which rules apply to whom.
If that sounds like a semantic layer, that’s because it is one, built for a decade of product rules.
The UI is one consumer of that layer, alongside our API and our agentic AI. Same definitions, same answer, whoever is asking.
Ten years of logic doesn’t move in one go, so we move it in increments. And there’s one call I’d make again without thinking twice.
Canonical-only. No fallback. When something moves to the new layer, it runs on the new layer.
A silent fallback hides gaps. The old path answers, everything looks fine, and the two paths drift apart where nobody’s watching. With no fallback, a missing rule fails loudly, and each loud failure sets the next increment.
No fallback catches missing rules, not wrong ones. A rule that moved over wrong still returns a number, and catching that takes its own checks.
The agent is a peer. Our agent runs existing dashboard cards directly as steps in its workflows.
A card that runs on the layer gives the agent the same rules the dashboard uses. That’s why moving the cards onto it matters.
None of this is new on its own. Kiro’s frontier engineering principles include building your codebase for agents.
Here’s how that played out for us, one layer down. Before you hand the agent tools, make sure the tools and the UI read from the same place. Otherwise you’ve built the agent a very nice door into the wrong room.
The part I’m proudest of
The step that moved dashboard cards onto the layer shipped during a three-week break I took. It was the headline of my catch-up notes when I got back.
Before I left, I spent days going deep on the architecture. Then I left the team an initiative’s worth of Jira tickets and one document with the architecture and the plan.
I also left a chat bot, seeded with the plan and my reasoning behind it, so the team could ask it questions instead of waiting on me.
Tickets say what to do. The doc says how it fits together. The chat bot was for the WHY, the part that usually lives in one person’s head and goes on vacation with them.
The team did the work. What I left them was the context.
It’s the same lesson as the rest of this post. The agent needed the business logic out of the UI. My team needed the plan out of my head.
If you lead an engineering team
Before you buy an agent framework, ask one question: where does your business logic live?
If the answer is “the UI,” that’s your first AI project. It isn’t glamorous. There’s no demo.
But until it’s done, your agent will keep giving confident answers that don’t match your product. And your customers will notice before you do.