2026-11-27 16:22 UTC

Swapback offers a local proxy to mask sensitive data in LLM traffic

state: expiredheat: lowuncertainty: mediumrelevance: mediumprompt-privacy local-proxy llm-securityrmpmrepo1278

What is this?

Swapback is an MIT-licensed Python local proxy by GitHub user rmpmrepo1278, intended to sit between an app or agent and an LLM provider. The project says it replaces values from a user-maintained list and detected items such as emails, phone numbers, payment-card numbers, IBANs and API keys with placeholders, then restores placeholders in replies. It also says an egress check blocks requests if listed data remains, and that certain tool calls keep placeholders by default. The GitHub README describes support for OpenAI-compatible APIs and Anthropic, and provides an installable package and setup instructions. The supplied evidence is primarily the project’s own documentation and a Hacker News link, not independent validation. The README describes version 0.4.2, while web results also list a 0.4.6 release; the available evidence does not establish what changed in that later release.

Why it matters

A local proxy could let people use hosted LLMs with some sensitive information masked, without changing their client integration substantially; restoring values in replies and constraining tool calls are especially relevant for agent workflows. This may lower the friction of using powerful cloud models with private data, but it is a safeguard rather than a guarantee: detection coverage, configuration and behavior need independent scrutiny, and the supplied sources provide no adoption evidence.

Current assessment

The reported development is an installable, locally running privacy proxy, not a new model or provider-side privacy feature. According to its README, users configure values to mask and can also rely on pattern-based detectors; the project says it rechecks outgoing requests and fails closed when listed values remain. It claims byte-exact restoration in replies, including streams and tool-call arguments, while leaving placeholders in selected potentially exfiltrating tool calls by default. These are project claims, not independently verified security results. The README documents Python 3.11+, a loopback proxy, OpenAI-compatible and Anthropic interfaces, and a self-test using made-up data; the described demo does not contact a provider. A web result identifies PyPI 0.4.2, while search results list GitHub releases through 0.4.6, without details sufficient to establish their changes or current package parity. Key uncertainties include what sensitive content detectors miss, whether masking preserves task quality, and how reliably tool policies prevent disclosure. If effective, the approach could make cloud-model use more practical for personal or work data, but it does not prevent disclosure through unrecognized data, unsafe configuration, or other channels.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p17momentum: steady2 platformsage 336h
points/hour across evidence · reading as of 2026-11-26 11:23:00.801938+11:00 · deterministic, not a model opinion

How the heat travelled

11-12 00:21 (minted)⭐ origin echo-reconstructedThe repository describes an installable local proxy that masks personal data and secrets in LLM requests, restores them in replies, and bloc
rmpmrepo1278 on github (echo) · attributed from hn.story.50460951 · published time unknown
—
11-12 00:09first on hacker news · published · lag ?Keeping names, emails and phone numbers out of LLM prompts with a local proxy
rohitmishra1278
—
11-12 00:09amplified on hacker news 👑hn.story.50460951
rohitmishra1278
peak 1 · 0 comments · 104% of case engagement
11-12 00:20our radar first saw it · lag ?discovery anchor: hn.story.50460951—

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnKeeping names, emails and phone numbers out of LLM prompts with a local proxy
Retrieved article excerpt

Open article · Retrieved 2026-11-12T00:21:32.414664+00:00

# swapback

**Your data stays yours.** A local proxy that swaps names, emails, phones and keys for placeholders before a prompt reaches an LLM provider, and puts them back in the reply.

[PyPI version](https://pypi.org/project/swapback/)
[tests](https://github.com/rmpmrepo1278/swapback/actions/workflows/tests.yml)
[License: MIT](https://github.com/rmpmrepo1278/swapback/blob/main/LICENSE)
[Python versions](https://pypi.org/project/swapback/)
[Downloads](https://pepy.tech/projects/swapback)

Terminal: pip install swapback, then swapback demo. The app sends a made-up name, email and phone; the model receives PERSON\_1, EMAIL\_1 and PHONE\_1 placeholders; the app gets the original values back. PASS.

## Quickstart

```
pip install swapback
swapback demo
swapback init && swapback-proxy
```

Python 3.11 or newer. `swapback demo` runs a fake model with made-up data: no key, no network. The proxy listens on
`127.0.0.1:8787`; point your client at it and change nothing else:

```
from openai import OpenAI
client = OpenAI(
    base_url="http://127.0.0.1:8787/v1")
```

### Set it up for a real provider

`swapback init` writes `swapback.yaml` and `known.yaml`. Put the names, emails, phones and IDs that must never reach a
provider in `known.yaml` (or build it from a contacts export with `swapback known init --vcf contacts.vcf`), set
`upstream:` in `swapback.yaml`, run `swapback check-config`, then start `swapback-proxy`. The full steps, including
OpenRouter and Anthropic base URLs, are in the [guide](https://github.com/rmpmrepo1278/swapback/blob/main/docs/guide.md#set-it-up-for-a-real-provider).

## Works with

- **[OpenClaw](https://github.com/openclaw/openclaw)**: tested end to end (2026.10.7) with one provider block; its
  `exec`, `web_fetch`, `web_search`, `browser` and `message` tools keep placeholders by default.
  [Config](https://github.com/rmpmrepo1278/swapback/blob/main/docs/guide.md#use-with-agents).
- **[Hermes Agent](https://github.com/NousResearch/hermes-agent)**: runs in front of the maintainer's own Hermes agent
  every day, on real email and calendar traffic.
- **Any OpenAI-compatible client**: OpenAI Chat Completions and Responses (the official SDKs, OpenRouter, LiteLLM
  clients). Set the base URL, change nothing else.
- **Anthropic Messages**: the Anthropic SDK, plain and streamed, including `tool_use`.
- Tool-policy recipes for Claude Code and Codex CLI: [framework recipes](https://github.com/rmpmrepo1278/swapback/blob/main/docs/guide.md#framework-recipes).

## How it works

```
flowchart LR
    A["Your app or agent"] -- "Email Jane Q Doe" --> S["swapback (127.0.0.1:8787)"]
    S -- "Email «PERSON_1»" --> P["LLM provider"]
    P -- "Hi «PERSON_1» ..." --> S
    S -- "Hi Jane Q Doe ..." --> A
```

 Loading

1. **Swap.** Values from your own list are matched in their common spellings (case, separators, escapes, nested JSON);
   detectors catch phones, emails, cards, IBANs and API keys you did not list. Each becomes a typed placeholder.
2. **Check.** An egress re-check scans the outgoing request again. If anything listed is still there, or the scrub
   fails, the request is blocked (`503`). It fails closed.
3. **Restore.** Placeholders in the reply are put back byte-exact, in plain and streamed replies and in tool-call
   arguments. Network, shell and send-style tool calls keep the placeholder unless you allow the tool, so a
   prompt-injected `web_fetch` cannot carry your email out.

No model to download and nothing probabilistic: exact matching plus patterns, about 5,900 lines of Python, 3
dependencies. Re-run the leak test yourself with `swapback selftest` (made-up data, 7 request paths, about 12 s).

## Documentation

| Topic | Where |
| --- | --- |
| Why swapback, setup, agents, tool calls, configuration, hooks | [docs/guide.md](https://github.com/rmpmrepo1278/swapback/blob/main/docs/guide.md) |
| What it does not catch, and security notes | [docs/limits.md](https://github.com/rmpmrepo1278/swapback/blob/main/docs/limits.md) |
| Leak test, performance, detection score | [docs/testing.md](https://github.com/rmpmrepo1278/swapback/blob/main/docs/testing.md) |
| Comparison with PasteGuard, Maskit, Veil, piighost and Kiji | [docs/comparison.md](https://github.com/rmpmrepo1278/swapback/blob/main/docs/comparison.md) |
| Changes per release | [CHANGELOG.md](https://github.com/rmpmrepo1278/swapback/blob/main/CHANGELOG.md) |
| Reporting a vulnerability | [SECURITY.md](https://github.com/rmpmrepo1278/swapback/blob/main/SECURITY.md) |

Project facts: Python 3.11+, about 5,900 lines (302 KB), 3 dependencies (PyYAML, phonenumbers, pyahocorasick), stdlib
HTTP server, MIT.

## Development

```
pip install -e ".[test]"
pytest -q                      # the full suite, including the holdout score as a regression floor
python evals/run_holdout.py    # the detection score table in docs/testing.md (--misses lists the cases not caught)
python examples/smoke.py       # end-to-end: mock upstream + proxy, plain and streamed
```

The vendored rule sets live
in `swapback/vendor` (see `THIRD_PARTY_NOTICES.md`); `tools/build_vendor.py` regenerates the Presidio patterns.

See [CONTRIBUTING.md](https://github.com/rmpmrepo1278/swapback/blob/main/CONTRIBUTING.md) and the [changelog](https://github.com/rmpmrepo1278/swapback/blob/main/CHANGELOG.md).

## Roadmap

- ~~Restore Anthropic Messages streams.~~ Done in 0.1.1.
- ~~Catch separator and case variants of listed values (NBSP, `.`, `_`, `-`, `%20`, all caps) under one placeholder.~~
  Done in 0.1.1.
- ~~Restore OpenAI Responses API streams.~~ Done in 0.3.0.
- ~~Keep placeholders in tool calls that could send data out.~~ Done in 0.3.0.
- ~~Build the known-values file from a contacts export.~~ Done in 0.3.0 (`swapback known init`).
- Optional, pluggable NER for names you never listed, off by default.
- More national ID and address patterns, with tests from synthetic data.
- ~~Release on PyPI.~~ Done: `pip install swapback`.
- ~~Hooks for spend caps, local fallback and usage accounting.~~ Done in 0.4.0.
- ~~A public, re-runnable leak test.~~ Done in 0.4.2 (`swapback selftest`).

Ideas and pull requests are welcome; open an issue first for anything large.

## License

MIT, see [LICENSE](https://github.com/rmpmrepo1278/swapback/blob/main/LICENSE). Bundled rule data: gitleaks (MIT) and Microsoft Presidio (MIT), see
[THIRD\_PARTY\_NOTICES.md](https://github.com/rmpmrepo1278/swapback/blob/main/THIRD_PARTY_NOTICES.md).
rohitmishra127810
🟧 echo.github ⭐The repository describes an installable local proxy that masks personal data and secrets in LLM requests, restores them in replies, and blocrmpmrepo1278——

Interpretation history

Decision trace