How to Add Compliance Audit Logging to AutoGen Multi-Agent Systems
AutoGen's conversational multi-agent model makes compliance logging more complex than single-step frameworks — the decision is the conclusion of a multi-turn conversation, not the output of a single function call. This guide explains three patterns: post-conversation decision capture (extract structured JSON from final agent message), ComplianceRecorder agent in GroupChat (dedicated agent extracts compliance record), and nested agent correlation IDs for multi-pipeline decisions. All patterns use Ghost SDK for fire-and-forget capture under 5ms.
The AutoGen Compliance Challenge
AutoGen provides complete conversation histories — role, content, timestamps for all messages, tool calls and returns, token costs. What compliance frameworks require but AutoGen does not structure: subject_id (who was this decision about?), decision_type (what kind of decision?), final action (the structured outcome, not just the last message text), confidence, tamper-evident record with cryptographic seal, and organization-controlled storage. The solution is extracting a structured decision record from the conversation and capturing it with Ghost SDK after each conversation.
Pattern 1: Post-Conversation Capture
The simplest approach: prompt the final decision agent to end with structured JSON containing decision, confidence, and reasoning fields. After the conversation completes, parse the JSON from the last message and call ghost.capture() with subject_id, decision_type, context (complete input to the conversation), reasoning, action, confidence, and metadata including model version. This pattern requires zero changes to existing agent logic — just add the post-conversation capture step.
Pattern 2: ComplianceRecorder in GroupChat
For complex GroupChat workflows, add a dedicated ComplianceRecorder agent. This agent monitors the conversation without participating in the substantive discussion. When the GroupChatManager signals the conversation is approaching its end (round limit or termination condition), the ComplianceRecorder outputs a COMPLIANCE_RECORD JSON. After the conversation, extract this record from the chat history and send it to Ghost SDK. The ComplianceRecorder pattern provides cleaner separation between decision logic and compliance capture.
Nested Agent Pipelines with Correlation IDs
When AutoGen conversations call other agent conversations as sub-tasks, use a UUID decision_id to link all sub-conversations to the parent decision. Generate the ID at the pipeline entry point, pass it to each nested conversation via context or config, and include it in every ghost.capture() call. When a regulator or auditor requests the complete decision trail for a specific case, querying by decision_id returns the full pipeline from orchestrator intent through each sub-conversation to the final outcome.