[agenticwork]
← blog

AgenticLoops: Event-Driven Intelligence for Human-in-the-Loop Automation

Most AI agent frameworks treat human-in-the-loop as a confirmation dialog. The agent wants to do something, it asks the user “are you sure?”, the user clicks yes. This is HITL as UI. It is not HITL as architecture.

AgenticLoops is the platform's event-driven engagement engine. It powers the policy-based HITL automation that governs agent behavior — not through confirmation dialogs, but through behavioral rule evaluation, user identity resolution, and webhook-driven workflows that trigger when specific conditions are met.

How AgenticLoops Works

AgenticLoops is a Go service that runs as part of the platform infrastructure. It polls analytics events at 30-second intervals, evaluates trigger rules against those events, resolves user identities, and dispatches webhooks when rules match. Here is the pipeline:

1. Event Polling

AgenticLoops polls event data from the analytics system (Umami). It processes identify events to resolve anonymous visitors to known user profiles, then evaluates all active trigger rules against the latest event batch. The polling cursor is checkpointed in PostgreSQL so the service resumes where it left off after restarts.

2. Trigger Rule Evaluation

Trigger rules are conditional logic definitions that describe when a specific action should fire. Rules can evaluate conditions like:

  • Page visits: user visited a specific page N times
  • Event counts: user triggered a specific event more than N times
  • Company tier: user is from a Fortune 500 or enterprise-tier domain
  • Engagement score: user's accumulated engagement exceeds a threshold
  • Form abandonment: user started but did not complete a form
  • Time-based: user has been active for more than N minutes this session

Rules support cooldown periods (do not fire more than once per N hours), maximum fires per user, and custom webhook payloads with template variable substitution.

3. Identity Resolution

AgenticLoops maintains a merged user identity system. Anonymous Umami sessions and visitors are mapped to company-level user profiles through identify events. This means the rules engine knows not just what “session-abc” did, but what “Jane from Acme Corp” did across all her sessions.

Company tier classification (Fortune 500, Enterprise, Mid-Market) enables rules that trigger differently based on the user's organization. A high-engagement visit from a Fortune 500 domain can trigger different workflows than the same engagement from a personal email.

4. Webhook Dispatch

When a rule matches, AgenticLoops dispatches an HTTP POST webhook with the configured payload. Webhooks support:

  • Configurable headers: Authentication tokens, content types, custom metadata
  • Template payloads: Dynamic variable substitution from user and event data
  • Exponential backoff retry: 1min → 5min → 30min → 4 attempts max
  • Delivery tracking: Every webhook dispatch is recorded with status, response, and retry count

The retry logic with exponential backoff means transient failures (network blips, target service restarts) are handled automatically. Permanent failures are logged and surfaced in the delivery dashboard.

The API

AgenticLoops exposes a REST API for managing rules and monitoring the system:

  • GET /status — polling cursor, rule count, fire count, pending deliveries
  • GET/POST /rules — list and create trigger rules
  • GET/PUT/DELETE /rules/:id — CRUD operations on rules
  • GET /rules/:id/evaluate — manually trigger rule evaluation
  • GET /deliveries — webhook delivery history with status and retry info
  • GET /users — identified users with engagement scores and tier classification
  • POST /refresh-scores — recalculate engagement scores

Why This Matters for AI Agent Governance

AgenticLoops is not just a marketing automation engine. It is the event-driven backbone for the platform's HITL governance model. Consider these use cases:

  • Approval routing: When an agent requests a high-risk action, AgenticLoops routes the approval request to the right reviewer based on RBAC policies, company tier, and escalation rules.
  • Anomaly response: When the Audit System detects unusual agent behavior (unexpected tool invocations, credential access patterns outside norms), AgenticLoops can trigger investigation workflows automatically.
  • Engagement-driven onboarding: When a user reaches specific engagement milestones, AgenticLoops triggers personalized onboarding steps — capability unlocks, training content, or team invitations.

Infrastructure

AgenticLoops runs as a lightweight Go service on the K8s cluster. The deployment spec:

  • 50m CPU request, 200m limit
  • 64Mi memory request, 200Mi limit
  • Health checks at /healthz (5s interval) and /readyz
  • PostgreSQL for state (cursor, users, rules, fires, deliveries)
  • Multi-stage Docker build (golang:1.22-alpine → scratch) for minimal image size

The service is intentionally small. It does one thing well: evaluate behavioral rules against events and dispatch actions. The complexity lives in the rules themselves, not the engine.

Part of the Platform

AgenticLoops is one component of the platform. It works alongside SmartModelRouter (model selection), OATS (tool synthesis), the Workflow Builder (visual orchestration), credential isolation (scoped tokens), the Audit System (immutable logging), and DLP scanning (data protection). Each component handles a specific concern. Together they provide the governed, auditable, multi-model AI agent infrastructure that enterprise teams need.