From a button tap to a confirmed write: the full round trip through an AI agent

A button tap looks like it should trigger the action it obviously corresponds to. It shouldn't — it should re-enter the same conversation the model is already reasoning over. Here's the whole path, tap to database row, and the fallback for when the button itself never arrives.

Advanced

2 min read

Why a tap doesn't call the write directly

It's tempting to wire a button tap straight to the action it names — the user tapped a 3pm slot, so just go book 3pm. That bypasses the model entirely: no chance for it to notice the slot conflicts with something already discussed, no propose-then-confirm gate, no record of why this action is happening. The alternative, covered in the AI Agents domain's context-tools-vs-action-tools lesson: feed the tap back in as an ordinary message, through the exact same path a typed reply takes.

The tap didn't create a new code path. It produced a different kind of input into the one path that already existed — the model still decides whether and how to call the write tool, with the full conversation informing that decision.

Confirming it: one atomic claim, reachable two ways

The atomic-claim pattern (covered in depth in the AI Agents domain's idempotent-confirmation lesson) is what actually executes the write — and it doesn't care which trigger reached it. A button tap and a typed "confirm," matched against the session's most recent open pending action, both resolve to the identical claim. Neither gets its own bespoke confirmation logic; both converge on the one safe path.

Why the fallback exists at all

An interactive-buttons send is still just an API call, and API calls fail — a platform hiccup, a malformed request. Without a fallback, a failed buttons send leaves a real, valid PendingAction sitting in the database with no way for the user to ever act on it. The fix isn't a cleverer buttons send — it's a second, plainer entry point into the exact same confirm logic, so "the rich UI didn't arrive" degrades to "type a word" instead of "this booking is stuck forever."

Further reading