Skip to content
Last updated December 3, 2026

PromptGate 0.3 — changelog

Archived from CHANGELOG.md, which keeps the unreleased changes and the latest release.

The guardrails release: every request can be inspected before a provider sees it — in any API format, including tool results and attachments — for secrets, personal data and prompt injection; keys can be limited to networks and office hours; tool output is trimmed to save tokens; and personal data can be redacted reversibly, so users still read it in the answer. Guardrails apply globally, per model alias or per key, reload without a restart, and are measured on every build with pgfuzz.

  • Guardrails — guardrails: inspects every request before a provider sees it, in any API format: messages, system prompts, tool calls and results, Responses and embeddings input. Actions block (422 in the SDK’s error shape), mask ([KEYWORD]) and log; per-guard roles (user, assistant, system, tool); overrides per model alias and pg_ key, field by field. Findings (never the matched text) appear in the console, the request log (guard, schema v3) and the promptgate_guardrail_findings_total metric. First guards: keywords (whole words, case-insensitive) and length. 4 µs for a 2 KB request.

  • Attachments are inspected — text, docx, xlsx, pptx and PDFs with a text layer in requests (Anthropic documents, OpenAI file parts, Responses input files) are read in-process and checked by every content guard; text files can be masked. guardrails.attachments sets action: block to refuse all attachments, unreadable: block to refuse images, scans, remote URLs and file ids, and max_bytes. Formats are recognised by content; extraction is bounded against decompression bombs and isolated against malformed PDFs. New dependency: github.com/ledongthuc/pdf (BSD-3-Clause, pure Go).

  • Secret scanner — guardrails.secrets finds API keys, tokens, private keys and passwords in connection strings in messages, tool results and attachments: PromptGate’s curated rules (incl. current OpenAI sk-proj- keys, LLM providers and pg_ keys) plus 221 gitleaks formats with their entropy thresholds and allowlists. Block (default), mask ([AWS_ACCESS_KEY]) or log; kinds, exclude, custom patterns. Rules run only around literals every match must contain: 14 µs per 2 KB request, 2.5 ms per 200 KB of code; adversarial input is cut off and refused rather than scanned unbounded. pgfuzz recall 100%, no false positives on 1.4 MB of real code.

  • PII filter — guardrails.pii masks e-mail addresses, phone numbers (international, US, national with trunk 0), IBANs, credit card numbers, US SSNs and IP addresses as [EMAIL], [PHONE], …; block and log too. Checksums and ranges (mod-97, Luhn, SSA ranges, issuer lengths) are on by default (validate); loopback and 0.0.0.0 are skipped; allow exempts values or whole domains; custom adds patterns (RE2 or v1’s /re/flags). Hand-written scanners instead of regular expressions: 2.6 µs per 2 KB request. pgfuzz recall 100% over 5,000 values, no false positives on 2.6 MB of real code and docs.

  • Prompt-injection detection — guardrails.prompt_injection blocks attempts to take over the model in English and German: ignoring or forgetting previous instructions, overriding rules, role assumption (“you are now …”), system-prompt leaks, jailbreak modes and smuggled chat-template tokens ([INST], <|im_start|>, …). Phrases match word by word with gaps, so single words never trigger; zero-width characters, soft hyphens and odd spaces are stripped first. kinds, languages, custom phrases in a small syntax or regular expressions; user content by default, mask/log for tool results. pgfuzz recall 100% over 4,200 payloads incl. zero-width obfuscation; only real injection text found in 3.4 MB of code and docs. ≈ 6 µs for a 2 KB user message.

  • Reversible redaction — action: redact on any guard that can mask replaces findings with numbered tokens ([[EMAIL_001]], the same token for the same value) and puts the originals back into the answer: buffered JSON and event streams, every API format, after translation, in text and tool-call arguments. Tokens split across stream events are reassembled — an event ending in a token start waits for the next piece; text that isn’t a token passes unchanged. The mapping lives only for the request. ≈ 0.5 µs per streamed event.

  • Token saver — guardrails.token_saver trims tool results before any provider sees them: terminal escape codes and progress-bar redraws, trailing whitespace and blank-line runs, repeated outputs (the first copy stays, so prompt caches keep hitting) and, with truncate_bytes, oversized output (head and tail kept, cut at line ends). action: log is a dry run. Savings appear in the request log (token_saver: trimmed duplicate×2 (41.7 KB)) and in promptgate_token_saver_bytes_total{key,mode}. Transformers are a new guard kind: they run before every detector, which then scans the trimmed text.

  • Access rules — guardrails.ip_allowlist (allow / deny with IPs and CIDRs) and guardrails.time_window (weekly windows with days, from, to, timezone; windows past midnight belong to the day they start) refuse with 403, globally, per alias or per key. server.trusted_proxies names reverse proxies whose X-Forwarded-For is read, from the right, so clients can’t claim an address themselves. Guards may now set their block status.

  • Contextual PII — guardrails.pii_contextual finds names, postal addresses, dates of birth and kinds you describe (custom) by asking a model through any configured provider. The model only lists what it found; PromptGate locates those strings as whole words and masks, redacts, blocks or logs them, so the model never rewrites a request and can’t invent what gets changed. One call per new text, in parallel; answers cached by text, so a resent conversation costs a call for its new messages only. on_error: allow|block. Guards can now prepare per request (see guard.Preparer) and call providers with their server-side keys; the provider is checked when the config loads.

  • Guardrail quality gate — scripts/pgfuzz-gate.sh runs pgfuzz against the built binary: recall of secrets, PII and prompt injection (≥ 99%) and, new, the false-positive rate on a negative corpus of benign look-alikes (100% must pass). CI runs it on every push once the pgfuzz deploy key is set.

  • promptgate licenses and THIRD_PARTY_NOTICES.md — licenses of all third-party modules and data in the binary, generated by tools/gennotices and checked in CI; deb/rpm/apk packages install them under /usr/share/doc/promptgate.

  • The secret scanner’s own rules ignore placeholders in docs and examples — sk-xxxxxxxx…, ghp_YOUR_TOKEN_HERE…, long runs of one character — as the gitleaks rules already did. Found by the new negative corpus.

  • The keyword index of the secret scanner is a byte-class DFA with premultiplied states: ≈ 10% faster.

  • Guardrails decode escaped JSON strings themselves instead of through encoding/json: 200 KB of source code is scanned 20–40% faster by every guard (PII 1.2 → 0.7 ms).

  • Translated answers escape U+2028 and U+2029 as encoding/json does, and write backspace and form feed as \b / \f; a round-trip test couldn’t tell the difference, a byte-for-byte comparison now does.
  • THIRD_PARTY_NOTICES.md covers the modules of every release target (it missed mousetrap, linked into Windows builds only).
  • Guardrails read a message’s role even when content comes before role (clients that sort keys), and a content block’s type even when it comes last; such messages and tool_result blocks were treated as user content, so roles settings didn’t apply to them.
  • promptgate logs -f no longer exits with “context canceled” when stopped while it reads the log.
  • pii_contextual is tested against an OpenAI-compatible mock, not yet against a live model; detection quality depends on the model chosen.
  • Prompt-injection detection matches known phrasings in English and German; paraphrases and other languages can pass. Spelled-out e-mail addresses (ana at firma dot de) are not detected.
  • Images and scanned PDFs are not read (no OCR); files uploaded through a provider’s Files API reach PromptGate as ids only.
  • Redaction restores exact tokens only; a model that rewrites one (EMAIL_001) leaves it as written.

Every v0.2 feature plus every in-process guardrail on at once (bench/results/2026-10-19-go-v0.3.0-release.md):

  • Overhead at p50 for a short request: 0.16 ms buffered, 0.15 ms streamed (v0.2.0: 0.15 / 0.13 ms); ≈ 32,500 req/s with 16 clients.
  • A 26 KB coding-agent request — tool result with source code and colour codes — 0.69 ms, of which the guardrails take ≈ 0.3 ms.
  • Restoring redacted values in a stream: ≈ 0.01 ms per answer.
  • Per 2 KB: keywords 4 µs, PII 3 µs, injection 6 µs, secrets 13 µs.
  • 16.5 MB binary (6.6 MB gzip); with guardrails on, ready in ≈ 65 ms and ≈ 52 MB RAM at idle (without: 44 ms, 36 MB).
Was this page helpful?