30
Backend
06
Security
12
iOS
21
Infra

Let the in-app agent propose one modification per turn for the user to apply

ADR-0100 ACCEPTED · 2026-11-14
Let the in-app agent propose one modification per turn for the user to apply

Amends ADR-0062: the server now runs an agent loop for the in-app chat, though still not for MCP.

Decision

Run the agent loop on the server for the in-app chat. Each turn sends the model the transcript the app supplies, the trip as the agent may see it, the planning tools MCP serves, and the provider's built-in web search. The loop is bounded by a fixed number of model rounds, a turn timeout and input size. The turn streams to the app over the existing subscription transport, because turns that search take longer than the app's request timeout. The model's reasoning summary, tool activity and reply text stream as they happen; the citations and the proposal arrive only on the final event. Dropping the subscription cancels the turn.

The agent never writes to the trip. Each write tool call is built by the code MCP uses, applied to a scratch copy of the trip so later calls in the turn see earlier ones, and added to one proposal: a modification id minted at the start of the turn, the head that turn read, the resolved effects, and a summary. The app shows the proposal as a card. Accepting enqueues it as an ordinary pending modification under that id, marked as the agent's, so it replays offline and meets the same ancestry and authorship checks as a hand edit. Dismissing discards it.

The agent's view of the trip leaves out confirmation numbers, document contents, contact details and all generated destination text. The server keeps no conversation; the app owns the transcript.

Why

An MCP user brings a model and pays for it, which is why ADR-0062 rejected our own agent. An app user brings neither.

Entity ids derive from the modification id, so the ids minted while the proposal is built are the ids replay produces on accept. A proposal is a modification not yet written, and needs no draft state in the log.

The agent reads untrusted web pages next to private trip data. Review before writing keeps a person between an injected instruction and the trip, and the narrowed view limits what a search query can leak.

Rejected alternatives

  • Let the agent write directly. One injected page or misread request would change the trip with nothing to undo.
  • A separate, create-only tool schema for the agent. It cannot update or remove a booking, and it drifts from the MCP tools.
  • Store conversations on the server. That needs a table and a retention policy before any memory exists to justify them.

Consequences

Each turn spends model money, bounded per turn by the round cap and per user by a fixed-window turn budget. A search query can still carry trip details the model chose to include.

Every MCP write tool becomes an agent tool unless a test lists it as left out, so a new MCP tool forces a decision. The ancestry check passes while the head the turn read is still an ancestor of the branch's tip, so a proposal is refused only when the user switched versions; a stale proposal still applies over newer edits on the same branch, provided every entity it targets still exists.