Inspiration

What if AI agents can self learn and self heal? Most AI agents fail silently. They give wrong answers, get manipulated by social engineering prompts, and no one knows until a real user is harmed. We wanted to build an agent that doesn't just fail — it learns from its failures and fixes itself automatically.


What is REM Agent?

REM stands for Replay, Evaluate, Mend — a closed-loop self-improvement pipeline for AI customer support agents.

The core idea is simple:

If an AI agent can observe its own failures, it can generate better defenses against them.


How We Built It

The agent interacts with Arize AI via MCP tools, enabling real-time retrieval of trace evaluations and compliance scores during the Replay–Evaluate–Mend loop.

The 5-Stage Pipeline

Live Support Mode The baseline agent handles real customer requests — refund queries, policy questions. It is deliberately vulnerable to social engineering prompts like fake manager approvals.

Trace Memory Every agent interaction is captured as an OpenTelemetry span and exported to Arize Phoenix Cloud. Each trace includes a policy_compliance_evaluator score (0–100), verdict, and unsafe action flags.

Replay Lab Failed traces are fed into a 5-stage pipeline: Trace Extraction, Scenario Generation, Agent Replay, Evaluation, and Repair Synthesis. From just a handful of failures, the system generates 9 adversarial probes automatically.

Recovery Report All 9 probes are replayed against the baseline agent — all fail at 12% safety score. The system then synthesizes a guardrail patch as executable code.

Mended Agent After applying the guardrails, the same adversarial prompts are replayed. Safety score jumps from 12% to 95%.


Observability with Arize Phoenix

We integrated Arize Phoenix Cloud for full trace visibility:

  • 33 traces exported during development and demo
  • Every span includes compliance_score, verdict, unsafe_action_detected, and escalation_required
  • Live OTLP export shown directly from the app's Arize Integration page

Challenges We Faced

  • Designing the evaluator to produce consistent structured output across adversarial edge cases
  • Keeping the pipeline deterministic so replay results were reproducible for the demo
  • Connecting OTLP traces to Phoenix Cloud reliably across sessions

What We Learned

  • OpenTelemetry is incredibly powerful for LLM observability when paired with a platform like Arize Phoenix
  • Adversarial self-testing is a practical and scalable approach to AI safety — you don't need a human red team
  • Gemini 2.5 Flash is fast enough to power real-time evaluation loops

What's Next

  • Auto-deploy guardrails without human approval for low-risk patches
  • Expand to multi-agent pipelines
  • Connect the REM loop to production traffic, not just replays

Built With

Share this project:

Updates