← Back to Research

Reinforcement Learning · Agent Systems

RL Feedback Systems for Self-Evolving Agents

We built a production system that closes the user feedback loop – rewriting its own prompts in real time, validating them automatically, and compounding improvements across sessions without human intervention.

Nablon ResearchMay 12, 202612 min read
10×
cheaper per prompt improvement – every cycle reuses prior work
100%
of user feedback converted into training signal
0
human interventions once the self-healing loop is running

01 – Problem

The Prompt Drift Problem

Prompts are the steering wheel of every production LLM deployment – yet in most organisations they are written once, tested informally, and committed to version control without a principled evaluation framework. The result is a quiet, compounding failure: prompts degrade as model weights update, user query distributions shift, and product requirements evolve. We call this accumulation of untracked quality erosion prompt drift.

Three empirical observations motivate this research. First, user feedback signals – thumbs-down ratings, correction submissions, satisfaction scores – are routinely collected but almost never fed back into prompt improvement loops. Second, manual prompt engineering is non-reproducible; it depends on tacit knowledge held by whoever last touched the file. Third, even when teams do iterate on prompts, they lack a principled metric to know whether a rewrite actually helped.

Every user correction is a free training signal. Self-healing AI agents are systems that have learned not to waste it – rewriting their own instructions in response to feedback, validating the improvement, and deploying the result without manual intervention.

02 – Architecture

Real-Time Prompt Optimization

The real-time system addresses the most latency-sensitive case: a user has just received a poor output and signalled dissatisfaction. The architecture borrows from reinforcement learning – a policy (the current prompt) generates outputs, a reward model evaluates them, and a policy-update step proposes an improvement. Convergence criteria gate how many rounds execute before the improved prompt is deployed.

Real-Time Optimization Pipeline – RL-Style Six-Agent Loop
  1. 01

    Input Layer – Feedback Ingestion & Intent Extraction

    Haiku / GPT-4o-mini

    Converts raw user feedback into a structured task_goal. Initialises AgentPayload.

  2. 02

    Actor Agent – Parallel Beam Executor ×3

    Sonnet / GPT-4o

    Runs 3 prompt candidates in parallel; all outputs forwarded to the Judge.

  3. 03

    Judge Agent – Calibrated Reward Model

    Opus / o1

    Scores 1–5 with a calibration anchor injected each call; cites output lines per weakness.

  4. ◇

    Early Stop – Convergence Check

    stateless
    convergeplateau Δ<0.3regression rollbackmax iterations
  5. ↑

    Non-converged rounds loop back to the Actor for another beam

  6. 04

    Rewriter Agent – Reasoning-Powered Policy Update

    o3 / Opus – always

    Traces the causal chain: feedback → structural failure → fix. Outputs 3 new candidates.

  7. 05

    Regression Test – Golden-Set Gate

    same as Judge

    ≥ 80% pass threshold across typical, edge, and adversarial cases.

  8. 06

    Prompt Registry – Versioned Storage & Embedding Index

    deployed π*

    Full provenance: score history, reasoning traces, task embeddings for future seeding.

The Actor runs three prompt candidates in parallel; the Judge scores them against a fixed calibration anchor; an early-stop gate decides whether to converge, loop back for another round, or roll back. The Rewriter – always a reasoning model – traces each failure to its cause before proposing new candidates. Nothing deploys without passing the golden-set regression gate.

The Actor agent runs three candidates in parallel – not sequentially – eliminating exploration latency while tripling the optimization surface. The Judge injects a fixed calibration anchor on every call: a known (prompt, output) pair that should score 3.0. If drift exceeds ±0.3, an offset correction re-anchors the reward signal.

The Rewriter is the cognitive core and the only role for which model assignment is non-negotiable: it always uses a reasoning model. Fast models perform surface-level rewrites. Reasoning models plan architecturally – tracing the causal chain from feedback signal to structural failure mode and generating structurally distinct beam candidates.

03 – Batch Optimization

Four Optimizers, One Benchmark

Where real-time optimization responds to a single feedback event, batch optimization aggregates signals from production traffic over days and runs structured optimizer trials – a scientific experiment conducted against accumulated evidence. We evaluated four optimizers on a document-summarization benchmark: 50 feedback events (25 positive, 25 negative), scored on a composite ROUGE-1 F1 / TF-IDF metric weighted against purely lexical matches.

The four optimizers

COPRO

Clean rewrite

Coordinate ascent

Proposes 3 instruction variants per round, scores each, picks the best, repeats up to 3 rounds. Conservative and stable – refines rather than replaces.

MIPROv2

Best overall

Bayesian optimization · Optuna TPE

Joint search over (instruction, few-shot demonstration) space. The only optimizer in the benchmark that can optimize demonstrations alongside instructions.

TextGrad

Style tuning

Textual gradient descent

Computes a natural-language critique as a loss function, then applies a rewrite as the gradient step. High coverage gain but structurally aggressive.

APO

Hard constraints

Beam search over failure cases

Extracts per-failure instruction gradients and generates candidates addressing specific failures. Theoretically strong for constraint tasks – empirically fragile.

Each optimizer searches the prompt space differently – from conservative coordinate ascent to Bayesian joint search over instructions and demonstrations, textual-gradient descent, and beam search over failure cases.

04 – Evaluation Framework

Weighted 10-Metric Scoring

A single coverage metric is insufficient – an optimizer that is accurate but runs for 20 minutes is not viable in a production feedback loop. Our aggregate score weights ten metrics, with the top three accounting for 56% of total weight.

A critical methodological control: the baseline integrity check. A 100% similarity score between the optimized and original prompts is a failure signal, not a success. The optimizer consumed its full budget and produced no change. This is precisely APO’s result.

Aggregate score – metric weights
Semantic similarity
22%
Execution efficiency
18%
Cost efficiency
16%
Essential detail recall
12%
Coverage delta
10%
Instruction retention
8%
Length compliance
6%
Specificity · format · gen.
8%
022%

Top three – semantic similarity, execution efficiency, cost efficiency – account for 56% of total weight.

05 – Results

Benchmarking Four Optimizers

Results reveal a nuanced relationship between aggregate score, execution time, and cost that defies simple single-dimension ranking. COPRO leads overall – but the more interesting finding is the APO result, which exposes a structural failure mode latent in every optimizer that lacks baseline integrity controls.

OptimizerScoreTimeCostKey finding
COPRO – winner0.50462.8 s$0.86Fastest; highest instruction retention & semantic similarity
MIPROv20.496132 s$0.32Near-COPRO quality; only optimizer with joint demo search
APO – fallback0.4261,190 s$0.16Silent reversion – 100% similarity to original; zero genuine gain
TextGrad0.398179 s$0.10+12% coverage; only 20% instruction retention – fragile
Aggregate score comparison
COPRO
0.504winner
MIPROv2
0.496
APO
0.426fallback
TextGrad
0.398
00.504

Composite of ten weighted metrics, 50-event benchmark. Higher is better.

COPRO achieved the highest aggregate score (0.504) with the fastest execution (62.8 s) and strongest instruction retention. Its coordinate-ascent strategy resists over-correction – it refines rather than replaces – producing prompts that stay structurally recognizable to downstream systems while addressing identified weaknesses.

APO ran for 1,190 seconds – nearly 20× slower than COPRO – and returned a prompt with 100% similarity to the original. The beam search found no improvement path and reverted silently. Without baseline integrity checking, this result is indistinguishable from a valid optimization.

Failure signal

A 100% similarity score between the optimized and original prompts is a failure signal, not a success. The optimizer consumed its full computational budget and produced no actionable change.

TextGrad achieved the largest genuine coverage gain (+12%) but retained only 20.2% structural similarity to the original. This divergence introduces integration risk: downstream systems depending on stable instruction patterns may behave unexpectedly. All four optimizers consistently violated output length bounds – a systemic blind spot that remains an open research problem.

06 – Architecture

A Unified Self-Healing Architecture

Real-time and batch optimization are not competing approaches – they operate at different timescales and address different signal types. A unified self-healing agent deploys both, connected through a shared Prompt Registry that accumulates optimization provenance, version history, and task embeddings. Future runs are seeded from the best known prompt for a given task context, creating a compounding improvement dynamic.

The unified self-healing loop

User feedback & signals

seconds

Thumbs-down ratings, correction submissions, satisfaction scores – the raw material of optimization.

Layer 1 · Real-time optimization

session

Six-agent RL pipeline fires on explicit negative feedback. Improved prompt deployed before the next request.

Layer 2 · Batch optimization

nightly

Aggregates production traffic, identifies systematic failure patterns, runs optimizer trials overnight.

Prompt Registry

always-on

Version history, score trajectories, rewrite reasoning traces, task embeddings.

seeds every future run – improvements compound across sessions

User signals feed both a session-scale real-time loop and a nightly batch loop. Both write to the always-on Prompt Registry, which seeds every future run – so improvements compound rather than reset.

Three guardrails bound autonomous operation. The regression gate – the golden-set evaluation from the real-time pipeline – is non-negotiable: no optimized prompt deploys without it. Score-regression monitoring extends this gate to live traffic, triggering automatic rollback. For high-stakes task types, optimized prompts queue for human review – the system reduces engineering effort but does not displace human judgement where stakes are highest.

07 – Open Problems

Limitations and Research Gaps

  1. 01
    Length complianceNo current optimizer reliably enforces output length constraints through instruction rewriting. Optimizers treat length as a downstream concern rather than a first-class optimization objective – a structural gap, not an implementation quirk.
  2. 02
    Distribution shiftOptimizers trained on historical feedback degrade when user query distributions change. Adaptive re-triggering policies that detect distribution shift and re-initiate optimization cycles remain an open problem.
  3. 03
    Adversarial feedbackSystems optimizing against user ratings are potentially vulnerable to deliberate misratings intended to steer prompts. Robust reward-modeling techniques from RLHF research apply directly but have not been validated in this setting.
  4. 04
    Multi-objective optimizationCurrent optimizers minimize a scalar score. Production constraints – quality, cost, latency – are inherently multi-objective. Pareto-front approaches from numerical optimization should be imported into the text-space setting.

Generalising the Self-Healing Pattern

Prompt quality is the most underengineered dimension of production LLM systems. The gap between a well-optimized prompt and a static, hand-crafted one is large, measurable, and growing as deployment contexts become more demanding.

The benchmark results are clear for most production use cases: COPRO is the right default, offering the best combination of quality, speed, and cost. MIPROv2 is the right upgrade when demonstrations are available. APO and TextGrad require deployment controls – baseline integrity checking and structural stability monitoring respectively – before safe use at scale.

The deeper contribution is conceptual. Framing prompt optimization as a closed feedback loop – where user signals drive autonomous policy updates and every deployed prompt seeds the next improvement cycle – transforms what has been an ad-hoc craft into an engineered discipline. Self-healing AI agents are not a distant research vision. The components exist today.

The gap is architectural, not algorithmic. Every user correction is a free training signal. Systems that close the loop – automatically, verifiably, and without human intervention – compound quality improvements that static-prompt systems cannot match.

References

  1. 01Khattab et al. DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines. Stanford NLP, 2023. github.com/stanfordnlp/dspy
  2. 02Yuksekgonul et al. TextGrad: Automatic Differentiation via Text. 2024. github.com/zou-group/textgrad
  3. 03AgentLightning – APO optimizer. github.com/SciPhi-AI/agent-lightning
  4. 04Christiano et al. Deep Reinforcement Learning from Human Preferences. NeurIPS 2017.
  5. 05Zhou et al. Large Language Models Are Human-Level Prompt Engineers. ICLR 2023.
  6. 06Akiba et al. Optuna: A Next-generation Hyperparameter Optimization Framework. KDD 2019.
  7. 07Lin, C-Y. ROUGE: A Package for Automatic Evaluation of Summaries. ACL Workshop, 2004.

Keep reading

We Trained a Small Model to Detect Sensitive Data – Without Sending That Data Anywhere

Read the paper →

Partners

  • OpenAI
  • Anthropic
  • Microsoft
  • Databricks
  • AWS
  • ElevenLabs
  • OpenAI
  • Anthropic
  • Microsoft
  • Databricks
  • AWS
  • ElevenLabs

Investors

  • Nexus Venture Partners