autogen icon indicating copy to clipboard operation
autogen copied to clipboard

[Feature Request]: Need a new feature to redact sensitive information from Agent Response in Autogenstudio

Open Git-Noob123 opened this issue 2 years ago • 1 comments

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

Git-Noob123 avatar Jul 30 '24 19:07 Git-Noob123

Solution & Implementation Notice

We have implemented a comprehensive, modular solution for this request in Pull Request: microsoft/autogen#8357.

Summary of Architecture:

  1. Dynamic Redaction Engine (autogenstudio.utils.redactor.SensitiveDataRedactor):

    • Sanitizes high-entropy credential patterns (OpenAI sk-..., Anthropic sk-ant-..., GitHub PATs ghp_..., AWS Access Keys AKIA..., Bearer tokens, Azure Account Keys, and generic Private Key blocks).
    • Dynamically redacts environment variable secrets (var.type == 'secret' or sensitive names containing KEY, 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).
  2. Studio Settings Integration (SettingsConfig):

    • Added RedactionConfig in datamodel/types.py and datamodel.ts with safe default factory, maintaining 100% backward compatibility.
    • Allows users to dynamically enable/disable redaction and configure custom patterns.
  3. 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.
  4. Test Suite:

    • Verified via complete unit test suite in tests/test_redactor.py (7/7 tests passing green).

sparkysolutions10-pixel avatar Oct 16 '26 08:10 sparkysolutions10-pixel