Pattern · last reviewed 2026-11-10

Every hop keeps a copy: map where your prompts persist

What this pattern is

A prompt retention map is a table with one row per hop a prompt crosses, and four questions per row: does a copy exist, who set that default, does your erasure and export path reach it, and is the feature you just switched on eligible for the retention arrangement you rely on. Your privacy page says you delete a user's data. Your prompts pass through a gateway, a router and a model provider, and each one keeps what its own default says. Draw the map before an auditor, an incident or a vendor changelog draws it for you.

Context & problem

Deleting a user's rows from your own database is the part you control. A request to a hosted model leaves your database and lands in places with their own storage, their own defaults and their own deletion routes. Most teams find that out by reading one vendor page after a question from legal, and then assume the other hops behave the same way. They do not.

Two facts make this worth a page. First, a default is a setting you inherited, not one you chose, and it can change under you: Google's Gemini API changelog dated 2026-10-26 records a switch to storing Generate Content requests by default for paid-tier projects created from then on, with older projects left as they were. The same code, deployed into a new project, behaves differently. Second, turning on a feature can move you out of an arrangement you thought covered you: Anthropic's message threads beta is listed as not eligible for zero data retention.

Forces

  • Observability vs retention. A stored payload is what lets you debug a bad answer, and it is also the copy you must later delete.
  • Defaults vs intent. Each hop ships a default chosen for its own product, not for your privacy page.
  • Per-hop controls vs one promise. You make one promise to the user; five systems each hold a different switch for it.
  • Invisible state. Account-level settings at a vendor are dashboard state your code cannot read, so a map built from code alone is incomplete by construction.

The pattern

Build the map in four steps. Walk the real request path, not the architecture slide. At each hop answer the four questions with a sourced, dated fact. Mark every cell you cannot source as unknown rather than no. Then close the gaps you can close in code (a header, a request parameter, a feature you leave off) and write down the ones you can only close in a dashboard or a contract.

The map for a Claude-behind-a-router app, as documented on 2026-11-10
HopCopy by default?Who sets itControl
Your app store Yes, whatever you persist. You. Your erasure and export code. Covered in agent memory; not repeated here.
Gateway log (Cloudflare AI Gateway) Yes. Logs are on by default per gateway, and cf-aig-collect-log-payload defaults to true, so request and response bodies are stored. The gateway's default; overridable per request. Header cf-aig-collect-log-payload: false keeps metadata, skips bodies. cf-aig-collect-log: false skips the log entry (Unified Billing requests still log billing details).
Router (OpenRouter) Its FAQ says prompts and completions are not logged by default; opt-in input and output logging exists. The account (opt-in logging, privacy settings) and, per request, routing parameters. Data policy tiers per endpoint; ZDR can be enforced in privacy settings, guardrails or the per-request zdr parameter.
Model provider (Anthropic API) Depends on the arrangement. ZDR is an agreement, and feature eligibility is listed per feature. Your contract, then the feature. Check the eligibility table before enabling a feature.
Model provider (Google Gemini API) For new paid-tier projects from 2026-10-26, Generate Content requests are stored by default. Project creation date. The store setting; existing projects keep theirs.
Model provider (Amazon Bedrock) Depends on the model. Bedrock has a per-Region retention mode: a model that allows none persists nothing, a model under default may be retained for abuse detection, and a model that requires aws_review (Claude Fable 5, 5.1 and 5.2) is retained inside AWS for review. Model invocation logging is a separate switch and is off until you enable it. The model's allowed modes, then your account or project retention mode; and you, by enabling invocation logging. data_retention_mode (none where the model allows it). The invocation-log destination (S3, CloudWatch) becomes your own retention problem.

The router tiers

OpenRouter describes each endpoint's data policy as one of three tiers. ZDR means no routine storage after processing. Safety Retention allows OpenRouter or the provider to keep any request's prompt and response, whether or not it was flagged, for abuse prevention only, and not for training. Retention and Training means data may be stored and used for training under the provider's policy. The tier is a property of the endpoint your request is routed to, so a model that is ZDR on one provider can be Safety Retention on another. If you pin neither the provider nor the policy, you inherit whichever endpoint the router picks.

The feature hop

The least visible copies come from features, not from hops. Three documented examples:

  • Message threads (Anthropic beta, 2026-11-02). Anthropic keeps a thread in memory only, encrypted, with nothing written to disk, and it is gone within an hour of the last call. It is still excluded from ZDR, although turning it on leaves your other ZDR-covered features as they were. A short in-memory lease is a better story than a database, and it still sits outside an arrangement some teams treat as blanket.
  • Gateway log classification (Cloudflare). Off by default, per gateway. When on, Cloudflare may process the stored prompts and responses to classify tasks.
  • Bedrock retention mode. Choosing a model can choose the copy: the Claude Fable 5.x models are available on Bedrock only under aws_review, so using one means accepting retention for human review inside AWS. A model released before Fable 5 has no such change, per the same guide.
  • Bedrock model invocation logging. Off by default. When on, prompts and completions go to the S3 or CloudWatch destination you configure, where they are pre-guardrail user input.

Trade-offs

  • You lose payload-level debugging. Turning off gateway payload storage means a bad answer in production cannot be replayed from the gateway log. You need your own capture, with its own retention clock, or you accept the blind spot.
  • The map goes stale. Vendors change defaults. A map without dates and a re-check trigger is a snapshot of one afternoon.
  • Some cells stay unknown. Dashboard and account state cannot be read from code. The map records the question and the person who answers it; it does not pretend to know.
  • It does not make deletion complete. It tells you which copies exist and which control you hold. A copy at a provider you have no deletion route into is a finding, not a fix.

When not to use this

Skip the map when the model is fully self-hosted and no third hop sees the prompt: there is nothing to map beyond your own stores. Skip the per-hop work when you hold a signed zero-retention contract with the provider that covers every feature you use, because the contract is the map and the job reduces to checking each new feature against its eligibility list. Do not use it as a compliance conclusion: it is an engineering inventory and does not replace legal review of a data processing agreement.

As-built evidence

aiArch sets one retention header on every gateway-path model call. In src/lib/llm.ts, headers() sets cf-aig-collect-log-payload to false whenever the gateway is in use:

// src/lib/llm.ts, headers(): gateway path only
if (onGateway(env)) {
  h['cf-aig-collect-log-payload'] = 'false';
}

The reason is in the decision record dated 2026-07-25: the gateway's default stores full prompts and responses, and that log store sits outside both our retention job (src/lib/retention.ts) and our GDPR erasure path (src/lib/erasure.ts), so text we promise to delete would survive in a place neither routine reaches. Metadata (tokens, model, provider, status, cost, duration) is still logged, plus the cf-aig-metadata we send: a caller label and, on coach and injection-judge calls, the learner's account id, which gateway spend rules can scope on (whether any such rule is configured is dashboard state this page cannot read). That learner id is a copy our erasure path does not reach either; it is an identifier, not learner text. The header covers every gateway call, not just the coach, because short-answer and practical grading, the public guide assistant and the injection judge also send user-written text. A unit test pins the header on the gateway path and its absence on a direct call (test/llm.test.ts). The cost is the one named above: no payload-level debug on the gateway path.

What this does not establish: we send no per-request router privacy parameter, and whether any account-level retention or privacy setting exists at the router or the gateway is dashboard state that code and this page cannot read. We do not claim one. Our own tables are the app-store row, and the public statement of which processors we use is the privacy policy and the subprocessors page; this page is the engineering reasoning behind one header, not that statement.

Changelog

  • 2026-11-10 — Initial publication. Vendor facts checked against the sources below on 2026-11-10, including the Gemini changelog entry dated 2026-10-26.
Sources & provenance
  • AI Gateway logs on by default per gateway; cf-aig-collect-log-payload default true, false skips payload storage and keeps metadata; cf-aig-collect-log; headers do not change what Logpush exports; log classification off by default: Cloudflare AI Gateway logging, changelog 2026-03-17 and log classification, accessed 2026-11-10.
  • OpenRouter data policy tiers (ZDR, Safety Retention, Retention and Training), default logging statement, opt-in input and output logging, per-request zdr: Zero Data Retention, data collection and FAQ, accessed 2026-11-10.
  • Message threads memory-only lease, deletion within one hour of last use, not eligible for ZDR; ZDR is per feature; on Bedrock and Google-managed Claude the cloud provider is the data processor: Message threads and API and data retention, accessed 2026-11-10.
  • Gemini Generate Content storing requests by default for new paid-tier projects from 2026-10-26, existing projects unchanged: Gemini API changelog, entry dated 2026-10-26.
  • Bedrock retention modes (none, default, aws_review) and per-model allowed modes: Amazon Bedrock User Guide, data retention. Model invocation logging disabled by default, destinations S3 and CloudWatch, and logs holding pre-guardrail input: AWS Security Blog, least privilege for Bedrock. Accessed 2026-11-10.
  • As-built: src/lib/llm.ts (headers()), src/lib/retention.ts, src/lib/erasure.ts, test/llm.test.ts, and the decision log entry "Coach payloads do not persist in AI Gateway logs", 2026-07-25.

The facts most likely to drift are the Gemini default and the OpenRouter tier wording. Re-verify both before relying on anything newer than the dates named. Corrections: hello@aiarch.dev.

Learn the architecture underneath the pattern.

aiArch teaches gateways, data handling and production AI architecture by building them, on a platform whose own LLM calls run behind a gateway with the payload header above.

Free with an account: Track 0 (The Mindset Shift) and the Track 0 coach allowance, no card · every claim cited · full curriculum with membership