<- all tokdocs

How Self-Improving RAG Systems Diagnose and Fix Their Own Weaknesses

Watch on TikTok

View on TikTok ->

Most RAG systems produce an answer and move on. A self-improving agentic RAG system does something different: it scores its own output, identifies the weakest dimension, and rewrites its internal instructions to address that weakness on the next run. The result is a system that evolves instead of staying static.

The Agent Team

The example here is legal contract review. Picture a team of AI agents, each with a specific role:

  • A case law researcher pulling relevant decisions from Westlaw
  • A compliance checker scanning ABA rules and state bar guidelines
  • A risk assessor flagging potential liability issues
  • A precedent analyst digging through LexisNexis for similar cases
  • A legal memo writer bringing everything together into a final document

Presenter introduces self-improving agentic RAG with legal-themed icons

These agents don't freelance. They follow a review protocol, which acts as the system's operating manual. It tells each agent exactly how to do its job, what sources to prioritize, and how to format findings.

The Agent Pipeline

A contract enters the system and flows through each agent in sequence. The case law researcher queries Westlaw, the compliance checker scans ABA rules, the risk assessor flags liability issues, the precedent analyst searches LexisNexis, and the legal memo writer compiles everything into a final document.

Diagram showing the agent pipeline from contract input through each agent to legal memo output, with data sources below

Grading the Output

Once the team finishes, the system grades the output across five dimensions:

  1. Legal Accuracy (85%) - Is the law cited correctly?
  2. Bar Compliance (78%) - Does everything follow professional rules?
  3. Risk Coverage (62%) - Did we catch all the danger zones?
  4. Precedent Support (80%) - Are conclusions backed by real cases?
  5. Clarity (70%) - Can a human lawyer actually understand the memo?

Scorecard showing all five grading dimensions with percentage bars and a gauge

In legal work, you cannot max out everything at once. Citing more precedent makes the memo longer and harder to read. Being thorough on risk might slow down turnaround. There are always trade-offs.

The Self-Improvement Loop

This is where the system gets interesting. A weakness detector looks at those five scores and finds the lowest one. If risk coverage is tanking, it figures out why. Then a protocol editor rewrites the review protocol to fix that specific weakness. Maybe it tells the risk assessor to cross-reference court docket systems more thoroughly.

Optimization loop diagram showing score output feeding back into protocol revision across versions

The system tests this new protocol, scores the output again, and stores the results. After running multiple versions, you don't get one perfect answer. You get a set of optimized trade-offs. One version might nail accuracy but sacrifice speed. Another might balance everything evenly. A human lawyer picks the version that fits their specific case.

Key Takeaways

  • The inner loop executes the work; the outer loop learns how to do the work better
  • Self-improving RAG scores its own output across multiple dimensions and rewrites its own instructions to fix weaknesses
  • In domains with inherent trade-offs (like legal work), the system produces multiple optimized configurations rather than a single "best" answer

Resources

  • Westlaw -- Legal research database referenced in the agent pipeline
  • LexisNexis -- Legal precedent search tool used by the precedent analyst agent

Published May 25, 2026. Writeup generated from a favorited TikTok.