> Source: https://vitna.ai/docs/runtime/redaction
> Raw Markdown: https://vitna.ai/docs/runtime/redaction.md
> Corpus index: https://vitna.ai/llms.txt

# Redaction

Known credential formats lifted out of a request before it leaves your machine,
and put back into the answer, streams included. Off unless you turn it on, for
the lanes you name or for traffic that names a model, except in
[Relay](relay.md#redaction-is-on), which turns it on for you.

```bash
VITNA_REDACT_LANES=deep-research,agent vitna-runtime   # these lanes
VITNA_REDACT_LANES='*' vitna-runtime                   # every lane
VITNA_REDACT_PASSTHROUGH=1 vitna-runtime               # every request naming a model
vitna-relay                                            # the same, on unless you pass --no-redact
```

It exists for the case a coding agent makes common: the agent reads a `.env`
file, a config or a shell history into its context, and the next request carries
your production keys to a model provider. With redaction on, the provider sees a
stand-in for each, and the file the agent writes back gets the real value.

## What it lifts

Formats with a shape of their own, and nothing found by guessing:

| Kind | What is recognised |
|---|---|
| Provider keys | OpenAI (`sk-proj-`, `sk-svcacct-`, `sk-admin-` and the older `sk-`), Anthropic (`sk-ant-api03-` and the admin form), OpenRouter (`sk-or-v1-`) |
| Cloud and service tokens | AWS access key ids (`AKIA`, `ASIA`), GitHub tokens (`ghp_` and its siblings, `github_pat_`), Slack (`xoxb-` and its siblings), Stripe (`sk_live_`, `sk_test_`, `rk_`), Google API keys (`AIza`) |
| Signed tokens | JWTs, the three dot-separated parts each starting as base64 JSON does |
| Private keys | A PEM `PRIVATE KEY` block, header to footer |
| Connection strings | The password in `scheme://user:password@host`, and nothing else of the URI |
| Assignments | The value of a secret-named assignment: `STRIPE_KEY=...` on a line of its own, as an env file writes it, or a quoted value given to a key named like `api_key`, `secret`, `token` or `password` in code, JSON or YAML |

What it leaves alone, on purpose:

- **Code that only mentions a secret.** `token = await getToken()`,
  `password: string`, `max_tokens: 1024`, `process.env.OPENAI_API_KEY` and
  `${GITHUB_TOKEN}` are not secrets, and a rule loose enough to catch them would
  rewrite code the model needs to read. An assignment's value is lifted only
  when it is quoted, or on an env-file line of its own, and at least eight
  characters long.
- **Anything found by entropy alone, and personal data.** A hash, a UUID or a
  base64 blob looks like a secret to a scanner, and rewriting one hands the model
  a commit it cannot find. Personal data waits for a constraint vocabulary in the
  policy, which the runtime's plan keeps out of scope until then.
- **Images and documents, tool definitions, and thinking.** A thinking block
  carries a signature over its text, so it goes as it was written, in both
  directions.

A secret in a format not in the table leaves as it was. Redaction reduces what a
provider sees; it is not a promise that nothing sensitive leaves.

## The stand-ins

Each secret is replaced by a surrogate of the same kind: the same prefix, the same
length, and a random letter or digit wherever the secret had one, with its
punctuation kept. `sk-proj-` stays `sk-proj-`, so a model reads it as the key it
is and writes it into code as it would the real one. A secret shorter than twelve
letters and digits gets a longer surrogate, since a short one could turn up in an
answer by chance.

The same secret gets the same surrogate for as long as the process runs. So every
turn of a conversation sends the same text, and a provider's prompt cache keeps
hitting; after a restart the surrogates are new, and the first turn misses the
cache once. A surrogate that comes back in a later request, because the client
kept one somewhere, is left as it is.

The pairs live in the serving process's memory and nowhere else: not on disk,
not in the ledger, not on `/status`, not in a log.

## Putting them back

Wherever an answer carries a surrogate, the runtime writes the secret in its
place before the client sees it: in text, and inside a tool call's arguments or a
tool's input, where it is escaped as JSON needs.

A stream is handled the same way, per choice and per content block. When a piece
ends with what could be the start of a surrogate, that tail is held back until the
next piece says whether it is one, so a surrogate the provider sent across two
chunks, or two events, is restored whole. Whatever is held is released when its
block or choice ends, so nothing the model wrote is withheld.

A model that alters a surrogate (shortens it, splits it with spaces, encodes it)
writes something the runtime cannot recognise, and the client receives that as
written.

## What the ledger says

Two counts on every row of a request redaction applied to: `secretsLifted`, how
many secrets its body had taken out, which is the same on every attempt since each
sends the same body, and `secretsRestored`, how many surrogates the answer had put
back. Both are null on a request redaction did not apply to, and `0` on one it
applied to that carried none. `/status` totals them. Nothing else about a secret,
not its kind and not its length, is written anywhere.

## When a request cannot be read

A request redaction applies to and cannot read is refused with a 422 and a ledger
row, and nothing is sent. It fails closed: sending it as it was would be the one
thing the operator turned redaction on to prevent.

## What it costs

It reads what the caller wrote, which the runtime otherwise does not: it reads to
find credentials, routes on nothing it reads, and keeps what it finds in memory.
The `VITNA_REDACT_LANES` names are checked against the policy at start, and one
the policy does not carry refuses to start, because a typo there is a lane whose
secrets leave while you believe otherwise. On Relay, which has no lanes, it is
on unless `--no-redact` or `VITNA_REDACT_PASSTHROUGH=0` says otherwise.
