Halfway through debugging, you paste a token straight into the chat and tell the agent to “try again with this.” We do it often enough ourselves. Few people stop to think, as they paste, that the string goes to the model provider along with the message, and that every request after it carries it again.
OpenViking Gateway is a proxy between your agent and the model provider. The agent sends its requests to the gateway, which adds memory and forwards them to the model. In v0.5.7 the gateway gained a switch called Seal secrets.
With the switch on, this is the same message on either side of the gateway. On top is what we typed into pi, an open-source command-line coding agent similar to Claude Code; below it is the version that leaves the gateway for the model.
The token is the only thing that changed. It's a fake we generated at random for this test, and only its first 8 characters are shown here. 127.0.0.1:8787 is a test service we ran on our own machine, and it accepts this one token and nothing else. The model also receives a separate note telling it what the reference is and how to use it.
Where that string would have gone
Every request an agent makes carries the full conversation history. Paste a token once and it is resent on every turn after that. If the agent reads .env, or runs a command that echoes the secret, the copy in the tool output goes out too.
We recorded the traffic from this test on both sides of the gateway. Across three turns and 8 model requests, the token appeared 18 times in the request bodies the client sent to the gateway. Without sealing, all 18 would have reached the model provider unchanged.
Once a request leaves, users can see almost nothing of who it passes through. In November 2026, HD Moore of Dragos published an experiment. Over five months, the team sent about two million prompts carrying decoy credentials to widely used AI services, and found attackers actively stealing data from three hosting providers. Some of the decoy AWS keys were tried within hours of the request going out. The write-up puts it bluntly: “every hop can see the entire prompt and response.”
How the model works with a reference
The simplest approach is masking: replace the token with asterisks before it goes out. But the agent's next step is to build a curl command with it, and a model that only has the asterisks writes a command that won't run. So the replacement has to be reversible, and the reversal has to wait until the moment a tool actually runs.
That is what Seal secrets does. Before a request goes to the model, the gateway hands its text to OpenViking Server (the Server from here on), which replaces the secrets with references:
{{ov_privacy:alice:viking://~/privacy/credential/github#/values/token}}A reference names the owner, the entry the secret is stored in, and the field. It is not the secret itself, and only alice's own OpenViking identity can turn it back into the real value.
The model gets the reference and writes tool calls as usual. Below is one recorded tool call on both sides of the gateway, cut down to the curl part: we removed the directory change before it and the command that printed the response body after it.
Before handing the reply to pi, the gateway turned the reference in the tool arguments back into the real value, so pi ran curl with the real token. The test service accepts only the real token, and it answered:
HTTP 200
{"login": "alice", "scopes": ["repo", "read:org"]}References are turned back into real values only in the arguments of client tool calls. The real value never appears in the text the model writes for you, and the gateway's own records keep only the reference.
It works in the other direction too. Later we had the agent write the token into .env, get the deploy script working, and then read the file back.
Its reply, translated from Chinese: “The file on disk really does hold the real token; OpenViking just sealed it into a reference on my side… If you want to see the real value, just run cat .env in your own terminal.”
Now back to the numbers. Over the same 8 requests, the token appeared 18 times on the client side and 0 times in the request bodies the gateway sent to the model. We later recorded the session three more times with other models, and the steps the model took differed a little each time. Across the four recordings, the client-side count ranged from 18 to 28. The model side was 0 every time.
- Turn 1 · requests 1–4User pastes the token and asks the agent to test it against the API
- Turn 2 · requests 5–6Write it to .env, run the deploy script
- Turn 3 · requests 7–8Ask the agent to read .env back
Here is the whole trip a token makes, from being pasted in to being used:
Chinese writing on privacy-preserving computation has a phrase for this, 可用不可见, roughly “usable but not visible”: the agent can use the secret, and the model can't see it. The idea isn't new. 1Password's op:// references and op run have long done this on the command line: the config holds a reference, which is resolved to the real value only when the command runs. Seal secrets brings the same idea to the gateway. It applies to every message and every tool call that passes through, and the client needs no changes.
The model named a secret it never saw
In the comparison at the top, the reference pointed to auto/github-6t8f24. The token hadn't been stored before. OpenViking's detector recognized it as a GitHub token, stored it in the auto category under a generated name, and appended a note to the message asking the model to save it under a proper name.
How does a model save a value it can't see? It passes the reference itself as the value. Here are the recorded call arguments:
{
"category": "credential",
"target_key": "github",
"values": {
"token": "{{ov_privacy:alice:viking://~/privacy/auto/github-6t8f24#/values/token}}"
},
"description": "GitHub PAT used by acme-site deploy.sh (scopes: repo, read:org)"
}The Server sees that the value is a reference to the caller's own entry, so it moves the real value to credential/github on the server side and deletes the temporary entry in auto. From that point on, the conversation uses the credential/github reference. It's the one the model saw when it read .env earlier.
{{ov_privacy:alice:
token = ghp_JY0g…
token = ghp_JY0g…
token = ghp_JY0g…
Rotating the token takes no extra work either. If you switch to a new token later, the old value left in earlier messages is still replaced with this field's reference.
By this point the model had used the token in a working API call, given it a name, and written a description of it from the project's deploy script, without seeing it once.
Automatic detection works for credentials with a fixed format, such as GitHub, OpenAI, Anthropic and Slack tokens, and AWS and Volcengine access key IDs. There are 207 built-in rules, 191 of them from the open-source project Betterleaks (MIT licensed). The detector can't recognize values with no fixed format, such as database passwords or AWS secret access keys. Store one by hand once, and it is sealed from then on:
ov privacy upsert credential prod-db --field password='<your database password>'Turning it on
You need OpenViking Server 0.5.7 or later. If you haven't used the gateway yet, follow the gateway quickstart to enable it, issue a gateway key, and point your agent's model endpoint at the gateway. With Claude Code, for example:
export ANTHROPIC_BASE_URL=https://ov.example.com/gateway
export ANTHROPIC_AUTH_TOKEN='<gateway key>'
export CLAUDE_CODE_GATEWAY_HINT_HEADERS=1Then, in Studio (OpenViking's web console), go to OpenViking Gateway and open the Profiles tab. Every gateway key is bound to a context profile, which tells the gateway how to handle that key's requests. Pick the profile your key uses and turn on Seal secrets.

| Studio label | API name | Default | What it does |
|---|---|---|---|
| Seal secrets | seal_secrets | Off | Replaces registered secrets, and new tokens the user types, with references; client tools get the real value |
| Also store secrets found in tool output | enroll_tool_secrets | Off | Also stores new tokens found in tool results and attached content. Only works while Seal secrets is on |
A change takes effect right away, including in conversations already under way. Clients cannot change either switch with a request header.
To check that it's working, look at the gateway's request log. For each request it records how many texts were sealed, how many values were newly stored, how many references were turned back into real values, and how long sealing took. Studio's Requests page doesn't show these fields yet; read them through the management API at GET /gateway/admin/logs. Here is the entry for the first request above, trimmed to the sealing fields:
{"secrets_sealed": 1, "secrets_enrolled": 1, "secrets_unsealed": 0, "seal_calls": 2, "seal_cache_hits": 22, "seal_ms": 25.59}The log records only counts, never a value or a reference. In this recording, sealing took between 3.7 and 25.6 ms per request across the 8 requests. The gateway and the Server ran on the same laptop, so treat these numbers as a rough reference only.
What it does not cover
Sealing guards against secrets being sent out by accident during normal use. These things are outside its scope:
- A malicious model, or an untrusted local machine. In the end the real value is handed to the tools on your machine. If that machine can't be trusted, sealing can't help.
- The client's own transcript. The text you pasted and the tool arguments with real values swapped back in both stay in the client's local history. The command that wrote
.env, for example, shows the real token in pi's interface. - Values it doesn't recognize. These include values shorter than 6 characters, values with no fixed format that were never stored, and values you have added to
never_mask. - Non-JSON request bodies. File uploads, for example, are forwarded unchanged.
- OpenViking tools without
openvikingin their name. The gateway recognizes OpenViking's own tools by name. If you registered the MCP server under a different name (ov, say), calls such asprivacy_upsertandwriteare treated as ordinary tool calls. The references in their arguments are turned back into real values like any others, instead of reaching the Server unchanged as they did earlier.
The full list is in the documentation.
Try it
Upgrade the Server to 0.5.7, turn on the switch in Studio, paste in a test token, then call GET /gateway/admin/logs and look for secrets_sealed in the request log it returns.
You can also do without the gateway. The Claude Code memory plugin and the pi extension got the same feature in this release, as a sealSecrets setting that is off by default. Sealing and unsealing happen in local hooks, which call the same Server endpoints. Their coverage is narrower than the gateway's: the Claude Code plugin, for example, doesn't handle the system prompt, slash-command arguments, or messages from before the setting was turned on. See each one's README for details.
A stored secret isn't limited to this one agent, either. Any other agent or script using the same OpenViking identity can use it with just the reference, through ov privacy run. The command contains the reference, the real value is injected only into the child process, and if the real value turns up in output printed to the terminal, it is replaced with the reference again.
ov privacy run --env GITHUB_TOKEN='{{ov_privacy:alice:viking://~/privacy/credential/github#/values/token}}' -- gh api user