jessyoungyu on X: when a masking rule hits, send the request to a
self-hosted model instead, so a prompt like 「百度这家公司怎么样」 gets an
answer about Baidu, not about a placeholder.
Settings › Privacy › Instead of masking, send to (settings
redactRouteTo). It is Off by default, and nothing changes for a user who
leaves it Off. It is picked in the app menu, and only models whose every
route is unmasked can be chosen: the provider is set to Send requests
unmasked, it is on this computer or the network, it has no account, and
any fallback or group member is unmasked too (gateway.MaskRoute, the
same rule as provider.SkipsRedaction). The setting is saved on its own
with POST /api/settings/redact-route, which checks it with MaskRoute.
The general settings save keeps the value.
Decisions:
- When a value would actually be masked on an agent's turn (maskHits.n
> 0), serve sends the request to the chosen model unmasked. Warn-only
hits don't count, and Block still answers 400.
- If that model fails, the request fails. It is never masked and re-sent
to the model the agent asked for, and never goes to a cloud model with
the unmasked text. Falling back to a masked cloud request would answer
a different question in the background. The user picked this route
because masking breaks the answer.
- Streaming works the same as on any route.
- The route is checked again on every request. A model that is gone or
no longer unmasked, or that the caller's gateway key may not use,
means the request is masked as before.
- Covered: agents' Messages, Chat, Responses and Gemini turns (serve,
marked by serveAgent), count_tokens, Codex magpie-model turns, and
Codex own-sign-in /responses (codexMaskRoute).
- Not covered: magpie's own asks (ownAsk clears the mark), embeddings,
audio, images and video. These stay masked.
GUI: redactRouteRow lives in plugins/redact/settings.js and wraps
renderRedact, so app.js is byte-for-byte unchanged and the core budget
is not raised. Strings are added in zh, zh-TW, ja and de. Docs: gateway-routing.md,
gui-shell.md, and site/public/docs masking (en, zh, ja).
Tests: internal/gateway/mask_route_test.go
(TestMaskedRequestGoesToTheModelSet: unset, set, streamed, nothing to
mask, local fails, falls back to a vendor, no longer unmasked,
count_tokens; TestCodexSigninTurnGoesToTheModelSet;
TestMaskRouteTakesOnlyUnmaskedRoutes; TestMaskRouteOnlyForTheAgentsTurn);
internal/gui/redact_route_test.go; settings_keep_test.go;
internal/gui/tests/redact-route.test.cjs (every language, chromium and
webkit, 1100 and 640 wide).
Broken by hand, each red:
- serveAgent without the agent mark;
- MaskRoute taking any route (TestMaskedRequestGoesToTheModelSet,
TestMaskRouteTakesOnlyUnmaskedRoutes; at the pushed head);
- the codex hook removed;
- count_tokens without the mark;
- ownAsk not clearing it;
- no key check;
- no reroute in serve;
- the GUI: no keep in the general save, no MaskRoute check on save, and
the picker listing every model;
- the plugin script left out of index.html (redact-route.test.cjs 22 of
24 red; at the pushed head).
Run on mote:
- at 221ede767's tree, this change on f5806ed21 (pushed on 44d697993,
which adds only app.css lines and a Gateway page GUI test):
go test -tags nogui ./internal/gui ./internal/settings ok (the core
budget is green again since ec789445d; #4307, filed and closed);
the mask-route tests in ./internal/gateway ok; GOOS=linux go vet
-tags nogui ./internal/gui ./internal/gateway ok; GUI: node --test of
redact-route, redact-*, privacy-*, mask-*, masking-*, settings-*,
i18n-keys, account-discovery, sessions-reads and gui-de/ja/zh-tw:
643 pass, 0 fail. gofmt -l clean.
- at the same change on af8f3a939, one rebase back (the only
difference is index.html's script order and main's own commits):
go test -timeout 45m ./internal/gateway (488s) ./internal/redact
./internal/settings ./internal/provider ok; GOOS=linux go vet -tags
nogui ./..., GOOS=windows go vet ./..., go vet ./... ok.
The whole Go suite was not run; every package this change touches was
run above.
Not tried: a real self-hosted model (Ollama) with a real agent. The
local model is a fake Chat server in the tests.