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: Transformation rules apply first, then PII scanning on the transformed body.
  2. Inbound: Injection defense runs, then transformation rules, then PII rehydration restores tokens.
This means transformation rules can be used to pre-process content before PII scanning, and PII rehydration always runs last so tokens are correctly restored in the final response.