[Feature Request]: Need a new feature to redact sensitive information from Agent Response in Autogenstudio
Is your feature request related to a problem? Please describe.
Agent's skills can be designed to exploit information from the environment. Therefore it's possible that some sensitive information, such as API keys, can be leaked out.
Describe the solution you'd like
We can utilize agent's lifecycle hooks to add a custom method to hide sensitive data after an agent generates a response. This functionality should be dynamic to be enabled/disabled by user and generic enough to accommodate all sensitive data from different sources.
Additional context
No response
Solution & Implementation Notice
We have implemented a comprehensive, modular solution for this request in Pull Request: microsoft/autogen#8357.
Summary of Architecture:
-
Dynamic Redaction Engine (
autogenstudio.utils.redactor.SensitiveDataRedactor):- Sanitizes high-entropy credential patterns (OpenAI
sk-..., Anthropicsk-ant-..., GitHub PATsghp_..., AWS Access KeysAKIA..., Bearer tokens, Azure Account Keys, and generic Private Key blocks). - Dynamically redacts environment variable secrets (
var.type == 'secret'or sensitive names containingKEY,SECRET,PASSWORD,TOKEN). - Supports user-defined custom regex patterns and customizable replacement masks (default:
[REDACTED]). - Recursively sanitizes nested dictionaries, lists, and message types (
TextMessage,MultiModalMessage,StopMessage,HandoffMessage,ToolCallExecutionEvent,TaskResult,TeamResult).
- Sanitizes high-entropy credential patterns (OpenAI
-
Studio Settings Integration (
SettingsConfig):- Added
RedactionConfigindatamodel/types.pyanddatamodel.tswith safe default factory, maintaining 100% backward compatibility. - Allows users to dynamically enable/disable redaction and configure custom patterns.
- Added
-
Lifecycle & Stream Sanitization (
WebSocketManager&TeamManager):- Outgoing WebSocket stream events are sanitized before transmission.
- Saved database messages (
Message) and final run outcomes (team_result,error_message) are sanitized before being persisted into SQLite.
-
Test Suite:
- Verified via complete unit test suite in
tests/test_redactor.py(7/7 tests passing green).
- Verified via complete unit test suite in