Skip to main content
AgentCat provides powerful client-side redaction capabilities, allowing you to sanitize sensitive information before it ever leaves your environment. This ensures that sensitive data never reaches our servers.

How it works

You can provide a custom redaction function when initializing AgentCat tracking:
In PHP, the hook takes and returns one string, and runs after the client has its answer; in Laravel and Symfony, redact_sensitive_information names an invokable class or service instead. In C#, the hook takes each string and a CancellationToken and returns a ValueTask<string>. To edit or drop a whole event, set RedactEvent as well. It runs before RedactSensitiveInformation, receives a copy of the AgentCatEvent, and returns it, changed, or null to drop the event. AgentCat restores the event’s ID, session ID, project ID, type and timestamp after the hook.
On an ASP.NET Core server, the event of a C# tool call also carries every HTTP request header of the call, Authorization and Cookie included, and the URL with its query string, under parameters.extra.requestInfo (see Request headers and URL). RedactEvent also gets custom events, whose parameters can have any shape, and an exception in the hook drops the event, so test each level by type. This hook removes the authorization and cookie headers and the query string of the URL. Remove any other credential header of your server the same way:
In Rust, the hook is an async closure that takes each string as a String and returns Result<String, HookError>. When it fails, the SDK drops the event and does not send it unredacted. To change or drop a whole event, set redact_event as well. It runs on the whole Event before redact_sensitive_information, and Ok(None) drops the event:
Neither Rust hook has a time limit: a redaction hook that never completes holds one of the 5 delivery slots of its handle for good (see Rust: known limits). On a streamable HTTP server, the event of a tool call holds every HTTP header of the call, authorization and cookie included (see What the Rust SDK sends). To unit-test a redact_event hook, call it with an event from Event::default():

Key Features

  • Recursive Application: Redaction is applied to all string values in event data, including nested objects and arrays
  • Protected Fields: Essential analytics fields (like sessionId, projectId, eventType) are preserved to maintain functionality
  • Type Preservation: Non-string values (numbers, booleans, dates) are preserved without modification
  • Error Handling: If redaction fails, the entire event is skipped to prevent accidental data leakage