Repository navigation
Two modes for the language model, a benchmark of an AI agent's calls, and far fewer words masked
for nothing; nothing that worked before stops working, so this is a patch release, as
CONTRIBUTING.md describes. The spaCy guard now leaves out what it reads as a name in English
prose, code and identifiers, a place typed in lowercase among them, so an agent's prompt, tools
and results stay readable: in the benchmark's calls 5 of 307 token uses hide nothing, against 110
of 410 in 0.3.5. mode="paranoid", polanon-gateway --paranoid and polanon --ner --paranoid
mask all of it instead. A birthday under a JSON key and a login made of a known surname are now
masked, and the gateway can send images and files on unmasked when told to.
Added
-
polanon --ner --paranoidmasks with the spaCy guard inmode="paranoid". Without--ner
the flag is refused, since it changes nothing without the model. -
polanon-gateway --paranoidmasks with the spaCy guard inmode="paranoid", and the banner
says so. Without the model the flag changes nothing, and the banner says that too. -
mode="paranoid"masks every name the spaCy model finds. The filters that keep an AI
agent's English, code and identifiers readable let a little through by design: a name opening
an English sentence, a word in inline code, a place typed in lowercase.default_guards(mode= "paranoid")andNerGuard(mode="paranoid")keep every span with a letter in it instead. On
the agent's calls of the benchmark only what no guard finds leaks, 1 of 243 marked
occurrences against 3 in the defaultmode="normal", and 386 of 696 token uses hide nothing,
against 5 of 307. On the sample
documents it masks the same 187 values, with 8 over-masked spans instead of 6. The rules are
the same in both modes.benchmarks/run.pyandbenchmarks/run_agent.pytake--paranoid. -
A benchmark of an AI agent's calls, and of what comes back.
benchmarks/agent_corpus.py
holds eight invented calls of a personal assistant as its client sends them to a model, seven
to Chat Completions and one to the Responses API: an English system prompt with a Polish memory
of its user, sixteen tool definitions, and the JSON its tools return from a smart home, a web
search, a shell, a mailbox, a contact book and a file, with code, a traceback, a system log,
keys, a lease with two PESEL numbers, and mail in German and Ukrainian among it. The 103 values
that must not reach the model are marked where they are written.benchmarks/run_agent.py
masks each call as the gateway does and counts what still reaches the model and the tokens
that hide nothing, with their uses. It then restores the model's answer to each call, written
with the call's tokens and the cases the Polish note asks for, as text, as a whole response and
as a stream cut at every place, and scores each line and argument against what a reader should
get back. Withpl_core_news_md, 3 of 243 occurrences reach the model and 5 of 307 uses hide
nothing, against 5 and 110 of 410 in 0.3.5; 39 of 40 lines come back exact and none wrong.
tests/test_agent_benchmark.pyholds all of it as bounds, and CI prints the tables. -
The gateway can send what it cannot mask, when told to.
polanon-gateway --pass-unsupportedsends an image, a file or another part it cannot mask to the provider as it
is, unmasked, and masks the text around it, for an operator who wants the model to see a photo
or a document sent to an agent. The banner says so.MaskedTurn(unknown_blocks="keep")and
mask_responses_request(pass_unsupported=True)do the same in code. Without the flag such a
call is still refused, and--drop-unsupportedstill leaves the content out; the two flags
exclude each other.
Changed
-
WELL_KNOWN_NAMESholds hardware an agent names: Dell, Lenovo, Samsung, Roborock and HACS,
the store of Home Assistant's add-ons. In the agent's calls of the benchmark "Dell" was masked
as a company eight times in one call, "Roborock" as a person and "HACS" as a place. -
WELL_KNOWN_NAMESholds the platforms an AI agent names: OpenRouter, DeepSeek, Hugging
Face, Ollama, LM Studio, Claude Code, Hermes Agent, Nous Research, Home Assistant and its "HA",
GitHub, GitLab, Docker, Linux and Ubuntu. An agent driving a smart home named "HA" 117 times in
one call, and the Polish model took it for a place each time: the model saw a token in every
tool description and result in place of Home Assistant. With the list, as the gateway uses it,
they go out as written. -
spaCy reads a text once. A chat sends its whole history with every call, and an agent its
system prompt and the descriptions of its tools too: masking an agent's call of 105 messages
took 28 seconds, 20 of them in spaCy reading some two thousand texts it had read in the call
before.NerGuardnow remembers what it found in up to 20 000 texts (cache_texts, 0 turns it
off), under each text's SHA-256 digest, never the text itself; the same call took 13 seconds. -
The search for known values is prepared once per set of values. Every text of a call is
masked and checked against the whole mapping, and the search for its few hundred values, with
each value's keys, was built anew for each of some 2,700 texts. It is now kept for the latest
values, and the gateway drops it after each call (polanon._matching.forget), so a call's
values stay in memory no longer than the call. Masking the agent's call of 105 messages now
takes 8 seconds and its last check 1 instead of 13 and 3.5.
Fixed
- The gateway's last check no longer refuses an agent's history over names from code. With
Home Assistant's tools, a word of a tool's JSON result the masking took for a name, "service"
or "text", also stood in a JSON key, a tool call's id, a type such as "reasoning.text", a
tool's name or the parameters a tool requires, which the masking leaves as they are, and every
call was refused. The check now reads the payload as the masking does: a JSON text value by
value, and those names from code, written without a space, not at all. Every other text, every
value and a key with a space in it are searched as before. - A value found while earlier messages are masked once more is masked in all of them. A
message masked before the mapping last grew is masked again with the whole mapping, and doing
so can make the mapping grow once more: in an agent's history of 115 messages a piece left over
from a losing detection became a new value then, a message re-masked just before kept it, and
the gateway's last check refused the call.MaskedTurn.mask_messagesand the gateway's
Responses API masking now repeat the pass until the mapping stops growing, at most four times
(polanon.turn.MASKING_PASSES). - A number, a quote, a literal of code and a small English word are no longer names. In an
agent's tool results the Polish model tagged "2026" as a company,File "of a Python
traceback and Python's "None" as people, and "has" and "before" on lines it read as Polish. A
span of digits alone, one with a double quote, a literal such as "None", "True" or "null", and
one English function word in lowercase are now dropped on a line of any language; the rules
still find the numbers that matter. The benchmark is unchanged. - A model's English with a Polish quote in it is read as English. An agent's model reasons in
English and quotes the user in Polish, and one Polish letter in the quote made the whole line
Polish, so "The user asks" and "the model" went out as tokens. A line is now Polish by its
Polish words, a word with a Polish letter counting as one, and what stands in quotation marks
is left out of the count. In a text that is plainly English as a whole, a model's reasoning or a
manual, a line too short to show a language, such as "Possible causes" or "Max", is read as
English too; in a Polish text it stays as it was. The benchmark is unchanged. - A piece of a longer word, a Python traceback and more small English words are no longer
names: "service" ofha_call_servicewas a company, "File" ofFile "/srv/app.py", line 12a
place, and "while" in a Polish sentence a place too. A span glued to a letter, a digit or a "_"
is dropped, but not after a line break written out as\n, as an escaped JSON string has it,
soKontakt:\nAnna Lindqviststill names her. The benchmark is unchanged. - A span that opens with an English small word is no name on a line that shows no language
either: a tool's description "That's the limit" gave the person "That's", masked 64 times in
one agent's call once it was known; "This Week" was a company. The benchmark is unchanged. - A place or a company of one word in lowercase is no longer masked, on any line. Polish
writes both with a capital letter, and in lowercase the Polish model found English words of
the manuals in an agent's tool results instead: "text", "context" and "service", masked 54, 25
and 38 times in one call once known. The price is a place or a company typed in lowercase in a
chat, "jadę do gdyni" or "pracuję w orlenie", which now goes out as written; a person in
lowercase is still masked. The benchmark masks what it did, with one stray span fewer. - An English small word ends a name on every line. A span that opens with one is dropped on
an English or a Polish line too: "That's" stood after a dash in mid-sentence on an English line
and was masked 76 times in one agent's call once known, and a Polish manual quoting English gave
"Before" and "the model". A span that holds one in lowercase is cut there, and a piece stays
when it has two capitalised words or a Polish first name: "Maria Lindqvist at Northwind
Traders" gives both names, "tokens and passwords" none. "Will" and "May" are first names too,
so a span they open with a capital letter is read as before. - A word in inline code is no name. An agent's Polish answers named a button
Uncheck, and
the Polish model took it for a person on line after line: masked 85 times in one call once
known. A span between two backticks of its line, a line break written out as\nending one
too, is now dropped, unless it holds a Polish first name, as the loginanna.nowakdoes. - A span without a letter is no name. Under a Python traceback in an agent's tool results the
Polish model took the carets for companies and places, a Markdown heading's "####" for a
company and the offset of a timestamp, "808+00:00", for a place. What used to be dropped for
digits alone is now dropped for having no letter at all. - The English name of a language is no place. A Polish manual in an agent's tool results
spoke of "Polish" and "English" texts, and the Polish model took both for places, "Polish
names" and "Polish-first" for companies, masked 33 times in one call once known. A place or a
company that opens with the English name of a language or a nation is now dropped; a real one,
"British Airways" or "Czech Republic", is no secret either. A person is left alone: "German" is
a Polish first name too. - A word after a model number is no person. An agent's tool results listed a laptop's "M4
Max" and a vacuum's "S8 Pro", and the Polish model took "Max" for a person, masked 44 times in
one call once known. A person right after a word of letters and digits is now dropped, unless
it holds a Polish first name: "12A Maja Nowak" is a house number and a woman. - A first name that is also a word, before a common surname in a chat, is masked with it:
maja nowakandmarek nowak, typed in lowercase, went out with only the surname masked. Nowak,
Wójcik, Woźniak, Kowalczyk, Kaczmarek, Krawczyk and Mazur in lowercase now settle the first
name before them, in agreement with it, and10 marek w ofercieis left alone. In text that
writes names with capitals they settle nothing, soani Kowalczykstays "nor Kowalczyk", and
majaafter a day, "od", "do", "końca" or "połowie" is May, not Maja:od 1 maja nowakkeeps
its month. Nor does such a surname claim a word in the next cell of a table. A thirteenth
benchmark document,common_surnames.txt, holds the cases. Contributed by louisss1016 in
#28, closing
#13. - A product's tier, an identifier of code and a word with a digit are no names. In the
agent's calls of the benchmark the Polish model took a vacuum's fan speed "Max" for a person,
masked 57 times once known, Python'sJSONDecodeErrorandHTTPErrortoo, and an invoice
number for a place. A span of one word is dropped when it is a tier such as Max, Pro or Ultra,
ends as the name of an error does, holds a digit without a Polish first name, or is written as
code writes a name, with two capitals inside,MediaPlayerEntity, or an abbreviation run into
a word,HTTPServer. One capital inside is not enough: a handle or a small company's name,
"AnnaLis" or "ZielonyDom", is written so too, and so are MacLeod and DeVito. A span
is cut at a semicolon, a pipe and a tab as at a line break, so a CSV row read as one company
gives its cells apart. Token uses that hide nothing fall from 83 of 382 to 22 of 321, with the
same values leaking, and the sample documents score as before. - The English of software is no name. An agent's answers name buttons and settings in
English inside Polish sentences, and the Polish model took "Uncheck" for a person, masked 48
times in one call once known, "Authorization", "Scheduling" and "Privacy Policy" too. A span
whose every word is a word of menus, settings and manuals, on a list of some 670 written for
this library, is dropped unless it holds a Polish first name. Words that are also first names
or surnames, such as Price, Grant or Page, are left off the list, so Hugh Grant is a person. - Chinese, Japanese and Korean text is no name. A page in Chinese in the agent's calls of
the benchmark gave the Polish model a "person" of six Chinese characters, and "Home
Assistant。" with the full stop, which the list of well-known names no longer matched. A span
whose every letter is Chinese, Japanese or Korean is now dropped, and the punctuation of those
languages is trimmed off the ends of every span, in either mode, as a space is. - The parties of a contract are no names. A Polish contract writes its parties with a
capital letter, as defined terms, and in the lease of the benchmark the Polish model took
"Najemcy" for a company. Najemca, Wynajmujący, Zleceniodawca, Zleceniobiorca, Zamawiający,
Wykonawca, Sprzedający, Kupujący, Pracodawca, Pracownik, Strony and the like, in their cases,
join the form words a span made only of is dropped; the person who is a party is still masked. - A birth date after "birthday", "birth_date" or "Geburtsdatum" is masked. A contact book in
the agent's calls of the benchmark gave the label "birthday", and the dates after it went out
in the clear. The rule for birth dates now also reads "birthday", "birth date", "birth_date",
"date_of_birth", "dateOfBirth", "Geburtsdatum" and "urodziny", with a quote or "=" between
the label and the date, as code and JSON write them. - A date under a key that names a birthday is a birth date. A tool's JSON is masked value
by value, so the guards saw "1961-11-21" without the key "birthday" before it, and the date
went out in the clear; in the agent's calls of the benchmark two birthdays of a contact book
did.MaskedTurn.mask_data,mask_messagesand the gateway now read a value under such a
key, "birthday", "birth_date", "dateOfBirth", "dob" or "data_urodzenia", after the label of a
birth date. A date under any other key stays readable. - A login made of a known surname is the person. A backup's settings in the agent's calls of
the benchmark held "user.name=Tomasz Malinowski" and the directory "/home/tmalinowski": the
name was masked, the login went out. A word in lowercase that is a known surname of six
letters or more with an initial, a dot, "", "-" or digits around it, "tmalinowski",
"t.malinowski" or "malinowski85", is now masked with the name. Letters after the surname count
only after a dot, "" or "-", so "malinowskie" stays the adjective it may be, and the surname
alone in lowercase is still left as it is, since Zima, Kot or Wilk are ordinary words too.