# Let Your Agent Use Your Secrets Without Showing Them to the Model OpenViking v0.5.7 adds Seal secrets to the gateway: the model provider receives a reference, while your tools still get the real value when they run. 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. ```text # What you typed (client → gateway) deploy.sh keeps returning 401. Try this new token against http://127.0.0.1:8787/whoami and see if it works: ghp_JY0g… # OpenViking Gateway · seal: token swapped for a reference # What the model receives (gateway → model) deploy.sh keeps returning 401. Try this new token against http://127.0.0.1:8787/whoami and see if it works: {{ov_privacy:alice:viking://~/privacy/auto/github-6t8f24#/values/token}} ``` *Recorded from a real request pi sent through OpenViking Gateway. The message was typed in Chinese and is translated here. The token is a randomly generated fake; only its first 8 characters are shown.* 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](https://www.dragos.com/blog/ai-supply-chain-security-canary-tokens) 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: ```text {{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. ```bash # What the model wrote (model → gateway) curl -sS -o /tmp/whoami_body.txt -w "HTTP %{http_code}\n" -H "Authorization: Bearer {{ov_privacy:alice:viking://~/privacy/auto/github-6t8f24#/values/token}}" http://127.0.0.1:8787/whoami # OpenViking Gateway · unseal: only tool-call arguments are swapped # What pi runs (gateway → client) curl -sS -o /tmp/whoami_body.txt -w "HTTP %{http_code}\n" -H "Authorization: Bearer ghp_JY0g…" http://127.0.0.1:8787/whoami ``` *Only the curl part is shown. The test service accepts only the real token, and it returned HTTP 200.* 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: ```text 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. ```text # The .env on disk (tool result → gateway) GITHUB_TOKEN=ghp_JY0g… # OpenViking Gateway · seal: registered values in tool output are replaced too # What the model reads (gateway → model) GITHUB_TOKEN={{ov_privacy:alice:viking://~/privacy/credential/github#/values/token}} ``` *The deploy script ran with the real value on disk; the model only ever saw the reference.* 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. Occurrences of the full token string (`ghp_JY0g…`) in each request body. Sent by the client (client → gateway): 18 times in total. Received by the model (gateway → model), after the OpenViking Gateway sealed every token into a reference: 0 times. | Model request | Turn | Client → gateway | Gateway → model | | --- | --- | --- | --- | | 1 | Turn 1 (requests 1–4): user pastes the token and asks the agent to test it against the API | 1 | 0 | | 2 | Turn 1 | 1 | 0 | | 3 | Turn 1 | 2 | 0 | | 4 | Turn 1 | 2 | 0 | | 5 | Turn 2 (requests 5–6): write it to `.env`, run the deploy script | 2 | 0 | | 6 | Turn 2 | 3 | 0 | | 7 | Turn 3 (requests 7–8): ask the agent to read `.env` back | 3 | 0 | | 8 | Turn 3 | 4 | 0 | | Total | | 18 | 0 | Same three turns, re-recorded with other models (client side / model side): | Re-recording | Model requests | Client side | Model side | | --- | --- | --- | --- | | 1 | 10 | 28 | 0 | | 2 | 12 | 27 | 0 | | 3 | 12 | 23 | 0 | *Counts are occurrences of the full token string in request bodies. Every request carries the whole conversation history, so the counts add up turn by turn.* Here is the whole trip a token makes, from being pasted in to being used: The figure has three lanes: you and your tools (the client, where the real value is used); OpenViking Gateway and Server (the sealing layer); and the model provider, which sees only references. With sealing on, only references cross the line into the model provider's lane. 1. You and your tools: you paste a token into the chat (`ghp_JY0g…`). The real value goes to the gateway. 2. OpenViking Gateway and Server: the gateway sends the request text to the Server to seal. The new token is stored as `auto/github-6t8f24` and replaced with a reference, which goes to the model. 3. Model provider: the model receives the reference and a note (`{{ov_privacy:…}}`). 4. Model provider: the model writes the reference into a tool call: `curl … Bearer {{ov_privacy:…}}`. The reference goes back to the gateway. 5. OpenViking Gateway and Server: the gateway gets the real value back from the Server, in tool-call arguments only, and hands the call to the client. 6. You and your tools: your tool runs with the real value (`ghp_JY0g…`) and gets `HTTP 200`. The tool output, with the real value, goes back to the gateway. 7. OpenViking Gateway and Server: the tool output comes back through the gateway and is sealed again. The model still reads only the reference. Full reference: `{{ov_privacy:alice:viking://~/privacy/auto/github-6t8f24#/values/token}}` *One new token through one turn. The real value only ever travels between your machine and OpenViking.* 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: ```json { "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. The rename in three moments, on the model's side (references only) and inside the Server (the real value lives here): - A, stored automatically. - The model's side, sees only a reference: the token in the message is already a reference, `{{ov_privacy:alice:viking://~/privacy/auto/github-6t8f24#/values/token}}`. A note follows it: save this token under a proper name. - Inside the Server, stored under a temporary name: `auto/github-6t8f24`, token = `ghp_JY0g…`. - B, calls `privacy_upsert`. - The model's side: calls `privacy_upsert` with the reference as the value (the arguments above). Gateway: an OpenViking tool, so the reference passes through unchanged. - Inside the Server, recognizes a reference to its own entry: `auto/github-6t8f24`, token = `ghp_JY0g…`. - C, moved to the proper name. - The model's side: gets a new reference back and uses it from then on, `{{ov_privacy:alice:viking://~/privacy/credential/github#/values/token}}`. - Inside the Server, real value moved under the proper name: `credential/github`, token = `ghp_JY0g…`. `auto/github-6t8f24`: temporary entry deleted. *The model wrote the description itself after reading the project's deploy script. Throughout, only references ever appeared on the model's side.* 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](https://github.com/betterleaks/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: ```bash ov privacy upsert credential prod-db --field 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](https://docs.openviking.ai/en/gateway/02-quickstart) to enable it, issue a gateway key, and point your agent's model endpoint at the gateway. With Claude Code, for example: ```bash export ANTHROPIC_BASE_URL=https://ov.example.com/gateway export ANTHROPIC_AUTH_TOKEN='' export CLAUDE_CODE_GATEWAY_HINT_HEADERS=1 ``` Then, 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. *Screenshot: two switches on a context profile page in Studio. "Seal secrets" is on, and "Also store secrets found in tool output" is off. The second one is off by default.* | 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](https://docs.openviking.ai/en/api/25-gateway) at `GET /gateway/admin/logs`. Here is the entry for the first request above, trimmed to the sealing fields: ```json {"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 `openviking` in 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 as `privacy_upsert` and `write` are 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. > Tip: New tokens are stored automatically, with no confirmation step. If something is stored by mistake, run `ov privacy delete auto --yes` to delete the entry, then add the value to `never_mask`. The full list is in the [documentation](https://docs.openviking.ai/en/gateway/14-seal-secrets). ## 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. ```bash ov privacy run --env GITHUB_TOKEN='{{ov_privacy:alice:viking://~/privacy/credential/github#/values/token}}' -- gh api user ```