Skip to main content
Transformation rules let you rewrite HTTP request and response bodies using regular expressions. They are direction-aware: outbound rules apply before a request leaves the sandbox, and inbound rules apply before a response reaches your agent code. Use them to strip credentials from outbound headers, mask tokens in logs, or remove known injection patterns from responses.

Basic configuration

TransformationRule model

TransformDirection enum

Multiple rules

Rules are applied in the order they are listed.

Common patterns

For SSN redaction with response rehydration, use PIIConfig instead. Transformation rules are one-way and do not support rehydration.
Attackers sometimes embed invisible Unicode characters in text to manipulate LLM context windows.

Combining with PII redaction

Transformation rules complement PII redaction. Use PII redaction for structured sensitive data (SSNs, credit cards) that benefits from response rehydration, and transformation rules for patterns that should be permanently removed.

When TLS interception activates

Transformation rules require reading the request or response body, which means the security proxy must decrypt HTTPS traffic. TLS interception (Stage 3 of the pipeline) activates automatically when any transformation rules are configured. A per-sandbox CA certificate is generated at creation time and injected into the VM trust store. The proxy terminates TLS from the sandbox, applies transformations, and re-encrypts to the real destination. The agent code sees the destination’s certificate as usual.
Regex patterns use Go’s regexp package syntax, which is RE2-compatible. Backtracking patterns like (.+)+ are not supported. Test your patterns at regex101.com with the Go flavor selected.

Order of operations

When both PII redaction and transformation rules are active:
  1. Outbound (sandbox → destination): invisible-text stripping, then PII redaction, then transformation rules last.
  2. Inbound (destination → sandbox): untrusted-content capture (for the optional LLM judge’s session store — this observes, it does not block), then PII rehydration, then transformation rules last.
In both directions transformation rules run last, on a body that PII has already rewritten.
Transformation rules cannot pre-process content before PII scanning. By the time an outbound rule runs, PII redaction has already replaced matching values with tokens such as REDACTED_EMAIL_ADDRESS_1.A rule written to match text that PII also matches — an API key, an email, an account number — may therefore never fire, because the value it targets is no longer there. If a rule must see the original text, do not rely on ordering: narrow the PII scanner’s types, or scope it to different domains, so the two are not competing for the same content.

Streaming (SSE) responses

Inbound transformation rules are not applied to text/event-stream responses. Only PII rehydration is supported on SSE, because applying transformations would require buffering an unbounded stream. The same exception applies to untrusted-content capture: a streamed response is not recorded in the LLM judge’s session store, so indirect injection delivered over SSE will not arm the indirect trigger. Direct-egress injection defense still applies to the agent’s subsequent outbound requests. This matters because most LLM chat APIs stream by default. If you configure direction="inbound" rules to process model output, they will silently not run on a streamed response — there is no error and no log entry indicating the rule was skipped.
Do not rely on inbound transformation rules as a control on streamed LLM responses. Either request a non-streaming response from the upstream API, or enforce the requirement outbound instead, where transformations always apply.