Before an agent gets a send-email tool

A five-minute design rule that turns the most common agent finding from high-risk to routine.

The pattern

The second most common significant finding in agent reviews: an assistant with a sendEmail(to, subject, body) tool, where to is chosen by the model from the same context window that holds untrusted text — intake forms, fetched pages, supplier emails. A note inside any of those can direct the tool to send clinic or client context to an outside address, and the operator never sees it happen.

It is rarely a bug in the tool itself. The bug is the schema.

The fix

Remove to (and subject, where it matters) from the tool schema entirely. Code resolves the recipient from a verified record — the appointment’s contact, the account owner — and the tool accepts only body. Queue the message as a draft with a human approval step in the UI, and only then call the mail provider.

Applied end to end as finding NPB-04 in the Northgate Physio review report and LMC-02 in the Ledgerline agent tool review.

Generalising it

The same shape covers most irreversible agent actions: the model proposes, deterministic code resolves the target, a human confirms what leaves the building. Any tool that spends money, writes to another system, or addresses the outside world deserves the question: who chose the destination, and can untrusted text influence that choice?

About this note

Written by Joshua Thweny, OHMYVIBECODE LTD. A defensive field note: it describes a defect class and its fix, with no client-specific detail beyond the published reports it links to.