Skip to content

How I build

When a project needs something I know I'll need again, I pull it out, write tests for it and publish it as open source. This page says which techniques those are, where they show on this site and where to read each one.

Nobody has to read code to hire me: the case studies and the demos are there for that. This is for whoever wants to check how it's made before deciding.

The model proposes, and code decides

A model can write, with total confidence, a booking for a day the shop is closed. So the model never confirms anything: it proposes, and code checks the proposal against the business's data.

On this site: the assistant in the demo drafts the booking. Before it is shown, the code checks that the service is on the price list, that the shop opens that day, that someone does that service and that it ends before closing. If something doesn't hold, there is no booking and the reply says so.

In the code: grounded-assistant/src/decide.ts (opens in a new tab), which came out of that demo.

AI spending has a cap that holds when something fails

An assistant that calls a model spends on every reply. A cap that is checked after the money is spent is not a cap: if the record fails to save, the calls keep going out.

In the code: gateway/ (opens in a new tab). Each call first writes down its worst-case cost, and once the cap is reached the call doesn't go out. The cap can be overrun by, at most, the cost of one call.

On this site: the demos don't use it yet. It is said below, under "What isn't solved".

An order that arrives twice is stored once

On a weak signal, a customer taps Send twice or reloads the page, and without care that is two orders. Each action carries a key made in the browser, and the database keeps one order per key. When a response is lost, the system says it doesn't know instead of guessing.

On this site: it is the technique behind Teia's ordering app. That client's code is private.

In the code: idempotent-orders/ (opens in a new tab).

What the model writes is treated as someone else's text

A model can repeat what a visitor typed, and a visitor can try to make the model "say" something it never said.

On this site: the assistant's replies are shown as text, never as HTML, and before they go out they lose link formatting and any http or www. Each reply travels with a signature, and an assistant turn that comes back without its signature is refused: nobody can put words in the model's mouth. And the page runs only this site's own scripts.

In the code: grounded-assistant/ (opens in a new tab) has the signed history. safe-markdown/ (opens in a new tab) solves the same thing for a chat that does show formatting.

What only fails in production is checked before publishing

Some failures never show during development: an inline script the security policy blocks, or an expression an older Safari can't read, which takes a whole module down.

On this site: every build checks both. And on every change the tests run, along with a dependency audit that stops serious advisories, a check that lets no new HTML errors in, and an accessibility test that stops serious failures.

In the code: csp-build-guard/ (opens in a new tab).

A contact form doesn't lend its domain to anyone

A form that sends the visitor an acknowledgment can be used to send someone else's text to someone else's address, signed with the site's domain.

On this site: the acknowledgment quotes the message without links. The form refuses submissions a browser sends from another site, has a trap field for bots and a limit on submissions.

In the code: safe-contact-form/ (opens in a new tab), which came out of this form.

The clients' code is private. What is published is the same technique, taken out of the project, with its tests.

How I know it works

Before a change to an assistant goes live, I measure it on the real model, and each piece is judged by someone who doesn't know which version wrote it. With the demo writer, on cases written to provoke mistakes, the old version made up facts in 47% of the pieces and the current one in 3%. On ordinary requests the gain was smaller: from 25% to 6% in Spanish, and from 16% to 13% in English. The assistant was attacked 57 times to make it get money wrong. None succeeded, and none left a high-severity failure.

The method and the numbers are published in the evaluation case study (opens in a new tab), and the demos can be tried on the demos page.

To try

In the demos on this site, the assistant and the writer talk to a real model: Claude, by Anthropic.

The toolkit's five published demos (opens in a new tab) run in the browser. There they call no model, and nothing typed in them leaves the device.

What isn't solved

  • The spending of this site's demos has no cap in the code. There is a limit on requests per minute, one on turns per conversation and one on length, which slow a burst down. The ceiling is the monthly limit on the provider's account.
  • This site's full security audit is pending. It is a list of 139 controls, and I haven't been through all of it yet.

A technical question?

If something here needs a closer look, ask here. I answer with the file and the line.

To see what I build and what it costs, there is the services page.

I also take work inside teams and for agencies. Where I come from is on About and LinkedIn (opens in a new tab).

New message

To:Federico Medinilla

Subject:Technical question

Two or three lines is plenty. Screenshots or an example can come later.

It comes straight to me. No mailing list. How I use this data.