Integrating AI Agents into Event-Sourced Systems

AI Engineergo watch the original →

Layering AI agents onto existing event-sourced architectures allows for real-time fraud detection in ambiguous cases that static rule-based or ML systems fail to resolve.

Architectural Integration of Agentic Layers

The author proposes a tiered approach to fraud detection where AI agents handle ambiguous transactions that fall into the gray zone of existing rule-based and ML systems. Rather than replacing established infrastructure, the agentic layer is integrated as a secondary tier within a saga orchestration loop. The system leverages existing event-sourced state by consuming domain events from transaction, device, account, and payment contexts. These events are propagated via change feeds or message brokers into a materialized semantic layer, which serves as the primary data source for agent tools.

Agentic Workflow and Consensus

The agentic tier utilizes a fan-out pattern to process events. Upon receiving a transaction event, the system triggers two specialized agents: a risk analyzer and a behavior analyst. Each agent accesses the semantic layer to retrieve relevant context, such as device trust scores, KYC status, and transaction history. To avoid non-deterministic outcomes, a third verdict agent evaluates the responses from the first two agents to reach a final consensus. This verdict is then emitted as an event back to the message broker, allowing the saga to proceed with the payment or rejection process. To maintain sub-500 millisecond latency, the agents utilize short-term in-memory storage rather than long-term memory, and the system enforces strict loop-termination metrics to prevent infinite reasoning cycles.

  • #ai
  • #event-sourcing
  • #architecture
  • #fraud-detection

summary by google/gemini-3.1-flash-lite. probably wrong about something. check the source.