The Gray Zone Problem
Traditional fraud detection relies on rule-based engines and ML models. While these handle clear-cut cases effectively, they fail in the "gray zone"—ambiguous transactions where neither system can reach a confident verdict. Instead of replacing these existing systems, you can layer an agentic AI tier on top to handle these edge cases, leveraging the rich history already present in your event-sourced architecture.
Architecting for Agentic Context
To make agents effective, they require access to data across disparate bounded contexts (e.g., transaction, device, account, payment).
- Semantic Layer: Use Change Data Capture (CDC) or message brokers to propagate domain events into a materialized view or "semantic layer." This layer denormalizes data from various contexts into a format the agents can query.
- Event-Sourced Foundation: Because the system is event-sourced, the state is not mutated but appended. This provides the agent with a complete, immutable history of business facts, which is critical for reasoning about complex fraud patterns.
- Saga Orchestration: Integrate the agentic tier within a saga-style loop. The orchestrator receives events, triggers the agents, and emits a final verdict event back to the message broker to continue the business workflow.
Agentic Execution and Guardrails
When implementing the agentic tier, prioritize performance and reliability:
- Fan-Out Pattern: Use multiple specialized agents (e.g., a Risk Analyzer and a Behavior Analyst) to evaluate the transaction from different perspectives. A third "Verdict Agent" then synthesizes these responses to reach a final consensus.
- Short-Term Memory: Given the need for sub-500ms latency, rely on in-memory storage for agent state rather than long-term memory.
- Loop Control: Agents are non-deterministic, which risks infinite loops. Implement strict metrics and thresholds to force the agent to break out of its reasoning loop, ensuring the system remains responsive and predictable.
- Tooling: Equip agents with specific tools to query the semantic layer and execute business logic, effectively migrating static rules into dynamic, context-aware agentic tools.