Works with the AI Agents you already use
Spring AI RAG Review
A RAG system fails in ways a test suite never catches.
$15
Spring AI RAG Review
Example session with this skill installed
Request
Our RAG assistant answers questions about insurance policies but sometimes gives
answers that aren't in any document. Review the pipeline and tell me why.
What the agent did
Ran python scripts/audit.py ., read the findings at their file and line, then built a
ten-question golden set from the policy corpus and measured recall@5 before proposing any
fix.
Output (trimmed)
## Summary
- Java files read: 22
- Findings: 3 (3 high, 0 medium, 0 low)
| # | Check | Severity | Where | Problem |
|---|---|---|---|---|
| 1 | R1 | high | `RagService.java`:26 | retrieval uses SearchRequest.query(), which carries no top-K or similarity threshold |
| 2 | R4 | high | `RagService.java`:3 | no grounding instruction anywhere: the model is free to answer from training data |
| 3 | R2 | high | `DocumentService.java`:41 | document is removed from the database but its vectors are not deleted |
What the agent then said
The hallucination has a mechanical cause, not a model problem. Retrieval runs with no
similarity threshold, so the top matches are returned whether or not they are relevant —
and with no grounding instruction, the model fills the gap from training data. That is
exactly the behaviour you are seeing.Recall@5 on the golden set is 0.6, and the four misses all have the answering clause in a
chunk that starts mid-sentence — the fixed 800-token split is cutting clauses in half.Fix in this order: add the grounding instruction (one prompt change, immediate), set
topK(5).similarityThreshold(0.35)and re-measure, then split on section headings rather
than tokens. The deletion bug is separate and more urgent than all of it — a deleted policy
is still retrievable today.
- Read your context and instructions
- Compiled the spring ai rag
I have analyzed the Spring AI RAG implementation in the specified directory. The audit identified critical failures in the deletion workflow and retrieval bounds that explain both the hallucinations and the data persistence issues.
RAG Audit Results
| Code | Finding | Location | Status |
|---|---|---|---|
| R1 | Unbounded Retrieval (No top-K) | DocSearchService.java:42 | Failed |
| R2 | Orphaned Vectors on Delete | DocumentManager.java:89 | Failed |
| R4 | Missing Grounding Instruction | ChatConfig.java:15 | Failed |
| R5 | Unfiltered Metadata | SearchRequest.java:55 | Warning |
Critical Issues Found
- Orphaned Vectors (R2): In
DocumentManager.java, thedeleteByIdmethod removes the database record but does not callvectorStore.delete(ids). This is why "deleted" data is still being retrieved. - Missing Grounding (R4): The
ChatClientis configured without aQuestionAnswerAdvisoror a system prompt that explicitly restricts the model to the provided context, leading to hallucinations when the retrieval set is empty. - No Similarity Threshold (R1): The search request in
DocSearchService.javalacks a.withSimilarityThreshold(). The model is forced to process low-relevance chunks, increasing noise.
Next steps
- Update
DocumentManager.javato includevectorStore.delete(List.of(id))within the transaction. - Add a
QuestionAnswerAdvisorto yourChatClientwith a strict grounding template. - Implement a
similarityThresholdof at least 0.7 in yourSearchRequestand re-measure recall.
Connects securely to your tools. The creator never sees your data.
About this skill
A RAG system fails in ways a test suite never catches. It answers confidently from a chunk that has nothing to do with the question. It retrieves a document the user deleted last week. It mixes two customers' records because nobody filtered.
This skill finds those, then does the part a scanner cannot: measures whether retrieval actually works.
What it does
Audits the wiring. Six checks, each with a file and line:
- Retrieval with no top-K or similarity threshold
- Documents deleted from the database while their vectors stay behind
- Chunks embedded with default splitter settings
- No grounding instruction anywhere in the system prompt
- Chunks carrying metadata that no query filters on
- Personal data reaching the embedding path
Measures retrieval. The reference walks you through a golden set — twenty questions and the chunk that answers each — and computes recall@K, the only real measure of whether RAG works. It includes what good looks like per document type, and the fixes for low recall in order of likelihood: chunking, threshold, embedding model, vocabulary gap, K.
Fixes in the right order. Deletion first, because it is a legal problem. Grounding second, because one prompt change removes a class of hallucination. Bounds, filters, then chunking — the most disruptive change, last, when the golden set can prove it helped.
How it works
It reads the Spring AI APIs you actually use — VectorStore, ChatClient,
SearchRequest, QuestionAnswerAdvisor, the splitter — rather than guessing from class
names. The deletion check looks for a repository delete with no vector delete in the same
file, which is the exact shape of the bug. The grounding check is repo-level, because one
system prompt can serve every call site.
It is deliberately quiet on correct code: run against a well-built Spring AI service, it reports zero findings.
Where it stops
- Regex-based Java parsing, not a compiler. It cannot see a filter applied in a shared helper or a grounding prompt assembled at runtime.
- It measures retrieval wiring, not answer quality. Faithfulness and hallucination rate need an evaluation set and a judge.
- It does not know your embedding dimension, your index type (HNSW or IVFFlat), or which threshold is right for your corpus. Those need the golden set.
- It does not decide your retention period or legal basis.
If your audit logging has gaps too, the free spring-audit-coverage skill finds them.
Java and Spring AI 1.x only. Does not measure answer quality or hallucination rates. Requires manual verification of findings. Cannot detect embedding dimension mismatches at build time.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 8 days ago
- Software
Python
Permissions
What's inside
Frequently Asked Questions
New in LLM Ops
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.