---
title: "Keeping secrets out of synced agent transcripts"
description: "What AgentDrive syncs from your agent sessions, which files it never uploads, exactly which secrets the redactor catches, and the habits that cover the rest."
canonical: "https://agentdrive.sh/blog/secrets-in-agent-transcripts"
last-updated: "2026-11-18"
---
# Keeping secrets out of synced agent transcripts

> For the complete documentation index, see [llms.txt](https://agentdrive.sh/llms.txt). Every docs page is also served as markdown at its URL plus `.md`, and the full docs are in one file at [llms-full.txt](https://agentdrive.sh/llms-full.txt).

> What AgentDrive syncs from your agent sessions, which files it never uploads, exactly which secrets the redactor catches, and the habits that cover the rest.

By Rakesh Roushan, November 18, 2026. Source: https://agentdrive.sh/blog/secrets-in-agent-transcripts

AgentDrive keeps secrets out of synced transcripts with three layers that run on your machine: a built-in deny list and your `.adriveignore` decide which files may upload, a pattern-based redactor replaces known secret shapes in whatever does upload, and Private Workspace encrypts it. The redactor is best-effort, so a few habits still matter.

I built session sync so I could stop pasting context between Claude Code, Codex and the rest. The first thing I had to get right was what leaves the machine. The rules live in the Apache-2.0 client code: [`redactor.ts`](https://github.com/agentdrive-sh/agentdrive/blob/main/packages/mcp-server/src/redactor.ts), [`ignore.ts`](https://github.com/agentdrive-sh/agentdrive/blob/main/packages/cli/src/lib/ignore.ts) and the sync and watch commands in `packages/cli`.

## What does AgentDrive actually sync? [#what-does-agentdrive-actually-sync]

Two things, each behind its own switch.

**Transcripts.** The sync reads the agent's own session file, renders it as markdown and uploads it to `sessions/<project>/<harness>/<session-id>.md`. That markdown has the user and assistant text of every turn and a one-line summary of each tool call. Tool lines are built from a fixed set of input fields such as `command`, `path`, `query`, `url` and `description`, so the body of a file the agent writes never becomes a tool line. The command text does, though. If the agent ran `export STRIPE_KEY=...`, that line is in the transcript.

**Artifacts.** These are files the agent touched in the session that git doesn't track. They upload to `sessions/<project>/files/`.

A fresh `adrive init` turns both on and prints a notice saying so. If you already had preferences saved, it keeps them.

## What does `adrive watch` upload? [#what-does-adrive-watch-upload]

`adrive watch [path]` is a different tool, and it's broader. It needs artifact sync on. It's meant to upload every file under the folder (the current one by default), existing files first, then each change as it happens, skipping what the built-in deny list, that folder's `.adriveignore` or its `.gitignore` exclude. In CLI 1.4.0 it uploads nothing, because of a bug fixed in the next release. Use hook sync or `adrive push` meanwhile.

What it doesn't do matters more. Watch doesn't check whether git tracks a file, it has no size cap and it doesn't skip binary files. Once the fix ships, run `adrive watch --dry-run` first and read the list before you let it upload anything. In 1.4.0 the dry run lists nothing either.

## Which files are never uploaded? [#which-files-are-never-uploaded]

During hook sync, a touched file uploads only if every check passes:

- It is inside your home directory or the session's project.
- It doesn't match the built-in deny list.
- It doesn't match the project's `.adriveignore`.
- It is untracked and not ignored by git, or it sits outside any repository. Gitignored files are where secrets tend to live, so they are skipped. If `git status` fails for any reason other than "not a git repository", the file is skipped too.
- It is 1 MB or smaller, with no NUL byte in its first 8 KB.

The deny list covers, among others:

| Kind | Patterns |
|---|---|
| Env files | `.env`, `.env.*`, `.envrc`, `.dev.vars` |
| Keys and certificates | `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.crt`, `*.keystore`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `id_dsa` |
| Credential stores | `.ssh/`, `.aws/`, `.gcp/`, `.kube/`, `.gnupg/`, `.password-store/`, `.docker/config.json`, `.git-credentials`, `.config/gh/` |
| Package registry auth | `.npmrc`, `.pypirc`, `.netrc` |
| Named credential files | `credentials`, `credentials.json`, `.credentials.json`, `service-account*.json`, `serviceAccount.json`, `auth.json`, `oauth_creds.json`, `.claude.json` |
| Infrastructure state | `*.tfvars`, `*.tfstate`, `*.tfstate.*`, `secrets/` |
| Other | shell history (`*_history`), `*.sqlite`, `*.sqlite3`, `*.db`, AgentDrive's own config folder, build output and `node_modules/` |

In hook sync, this list is a hard gate. It runs as its own rule set before `.adriveignore`, so a `!` line in a project's ignore file can't re-include `.env`. The code treats project ignore files as untrusted for that reason: you might clone a repo whose `.adriveignore` you didn't write.

In CLI 1.4.0's `adrive watch`, the deny list is the first set of rules, followed by `.adriveignore` and then `.gitignore`, and the last matching rule wins. A negation such as `!.env.example` in your `.gitignore` re-includes that file for watch. That's usually what you want for an example file. It also means `!.env` would re-include the real one. From `@adrive/cli` 1.5.0, the deny list comes last and always wins, in any letter case, and watch reads only the folder's top-level `.gitignore` and `.adriveignore`.

## How do I write an `.adriveignore`? [#how-do-i-write-an-adriveignore]

Put it in the project root. It uses a subset of gitignore syntax: `#` comments, `!` negation, a leading `/` to anchor a pattern to the root, `*` within a path segment and `**` across directories. A trailing `/` matches a directory and everything inside it.

```
# local fixtures with real customer data
fixtures/prod-*/
# scratch notes I keep next to the code
/notes.md
**/*.har
```

It applies to files only. Ignore rules never filter transcript text.

## What exactly does the redactor catch? [#what-exactly-does-the-redactor-catch]

Every transcript and every synced file passes through `redact()` before upload, in hook sync and in `adrive watch`. It replaces each match with a marker such as `[redacted:github-token]`:

| Kind | What it matches |
|---|---|
| `aws-access-key-id` | `AKIA` followed by 16 uppercase letters or digits |
| `aws-secret` | `aws_secret_access_key` or `AWS_SECRET_ACCESS_KEY` followed by a 40-character value |
| `gcp-service-account` | the `"private_key"` field of a service-account JSON file |
| `stripe-secret`, `stripe-restricted` | `sk_live_`, `sk_test_`, `rk_live_` and `rk_test_` keys |
| `github-token` | `ghp_`, `gho_`, `ghu_`, `ghs_` and `ghr_` tokens |
| `github-fine-grained` | `github_pat_` tokens |
| `anthropic-key` | `sk-ant-` keys |
| `openai-key` | `sk-` and `sk-proj-` keys |
| `agentdrive-key` | `agentdrive_live_` keys |
| `slack-bot-token` | `xoxa-`, `xoxb-`, `xoxp-`, `xoxr-` and `xoxs-` tokens |
| `jwt` | three base64url segments, the first two starting with `eyJ` |
| `private-key-pem` | a whole `-----BEGIN ... PRIVATE KEY-----` block |
| `env-secret` | an uppercase name ending in `_KEY`, `_SECRET`, `_TOKEN`, `_PASS`, `_PASSWORD`, `_PWD` or `_CREDENTIAL`, then `=` or `:`, then a value of 16 or more characters |

The version message on each synced upload records which kinds were found and how many, for example `session sync (github-token×1)`. It never records the values.

## Why is redaction only best-effort? [#why-is-redaction-only-best-effort]

Because it's pattern matching, and plenty of secrets don't match a pattern. I ran the redactor against a few lines that would worry me, and it left all of these untouched:

- `DATABASE_URL=postgres://admin:<password>@db.example.com/app`. The name doesn't end in `_KEY` or `_PASSWORD`, and a password inside a URL has no pattern.
- `api_key=...` in lowercase, or `"apiKey": "..."` in JSON. The generic rule only matches uppercase names.
- `TOKEN=...` with no prefix, and `DB_PASSWORD=` with a value shorter than 16 characters.
- Google API keys (`AIza...`), Hugging Face tokens (`hf_...`) and npm tokens (`npm_...`). There is no pattern for them.

Redaction is one layer, not a security boundary. That's why the path rules come first and why Private Workspace exists. One more gap worth knowing: `adrive push`, which uploads a single file you name, doesn't run the redactor at all.

## Which `adrive privacy` settings should I change? [#which-adrive-privacy-settings-should-i-change]

Run `adrive privacy` with no flags to step through the toggles, or `adrive privacy --show` to print them:

| Toggle | What it controls |
|---|---|
| Always-on context | the session-start hint listing recent sessions from your other agents |
| Sync artifacts | uploading untracked files your agents write, and allowing `adrive watch` |
| Sync transcripts | uploading session transcripts |
| Private Workspace | encrypting synced content on your machine before upload |
| Connect new agent tools | wiring agent tools you install later |

With both sync toggles off, hooks upload nothing. With Private Workspace on, transcripts and synced files are encrypted with AES-256-GCM after redaction and before upload, and project and file names are hashed in storage paths. Turning it on doesn't encrypt anything uploaded earlier. The [security page](https://agentdrive.sh/security) covers what stays readable.

## What habits actually help? [#what-habits-actually-help]

These do more than any regex:

1. **Keep secrets in files the deny list already covers.** `.env`, `.dev.vars` and `*.pem` never upload through hook sync. A key in `config.ts` can.
2. **Don't paste keys into a prompt.** Point the agent at the variable name. Anything you type is transcript text, and only the redactor stands between it and the upload.
3. **Ask agents to reference variables, not print them.** `echo $STRIPE_KEY` puts the command in the transcript, and its output may land in the agent's reply.
4. **Know what "off" means.** In CLI 1.4.0, with "Sync transcripts" off but "Sync artifacts" on, each session is still logged as a run, and its metadata carries the session title (usually the first prompt, redacted, up to 120 characters), the working directory and the touched paths. With both off, hooks upload nothing, but the skipped sessions aren't marked either: when you switch sync back on, the next sweep uploads sessions that changed while it was off. For a conversation that must never leave the machine, remove its transcript from the agent's own store before you turn sync back on, or keep Private Workspace on so its content leaves only as ciphertext. From `@adrive/cli` 1.5.0, a session that runs while sync is off stays local and no run is sent for it; see the [session sync reference](https://agentdrive.sh/docs/concepts/sessions) for the edge cases.
5. **Preview before you trust it.** `adrive sync --dry-run` parses your sessions and reports what it would upload without uploading anything. From the next release, `adrive watch --dry-run` prints each file with the redactor's result.
6. **Rotate anything that leaked.** If a secret reached a synced transcript in plaintext, treat it as exposed and rotate it at the provider.

## FAQ [#faq]

### Is `.env` ever uploaded? [#is-env-ever-uploaded]

Not by hook sync: it's on the deny list, and the deny list can't be overridden there. In CLI 1.4.0, `adrive watch` skips it too unless a `!` line in that folder's `.gitignore` or `.adriveignore` re-includes it. From `@adrive/cli` 1.5.0, watch always skips it.

### If I turn sync off for one session, does it stay off? [#if-i-turn-sync-off-for-one-session-does-it-stay-off]

In CLI 1.4.0, not on its own. Sync off stops uploads while it's off. When you turn it back on, the next sweep picks up sessions that changed in the meantime. From `@adrive/cli` 1.5.0, a session that runs while sync is off stays local, even after you turn sync back on. See habit 4 above.

### Can I see what was redacted? [#can-i-see-what-was-redacted]

Each upload's version message lists the kinds and counts, never the values. `adrive watch` is meant to print them as it uploads too, but in CLI 1.4.0 it uploads nothing.

### Does Private Workspace replace redaction? [#does-private-workspace-replace-redaction]

No. Redaction still runs first, then the redacted content is encrypted. Encryption decides who can read the upload. Redaction decides what is in it.

### Can I use AgentDrive without uploading anything? [#can-i-use-agentdrive-without-uploading-anything]

Yes. Local mode resumes sessions between agents straight from their transcripts on disk, with no account.

## Preview what would upload [#preview-what-would-upload]

```bash
adrive sync --dry-run
```

It parses sessions changed since the last sweep, or the last 14 days on a first run, and reports what it would upload without uploading anything. The [sessions docs](https://agentdrive.sh/docs/concepts/sessions) list every sync rule in reference form.