
When Your RAG Architecture Needs a Rewrite
When your RAG architecture needs a rewrite, the signs rarely arrive all at once. They accumulate. Retrieval misses that were once edge cases become the norm. Agent memory that should persist across sessions simply doesn't. Every patch you ship fixes one symptom and surfaces two new regressions. The question isn't whether something is broken. It's whether the foundation is.
Here's what most guides won't tell you: a rewrite is sometimes the wrong call. Sometimes a query rewriting layer fixes the problem. Sometimes a better chunking strategy does. Sometimes the retriever isn't the issue at all, and your memory layer is the thing that needs rebuilding.
GigaRAG was built for builders facing exactly this fork, and the honest answer is that the decision depends on specific thresholds, not vibes. This guide covers the seven failure points that signal a rewrite, a decision framework with concrete triggers, the agent memory requirements most articles skip, a phased rewrite process, and what a rewrite can't fix.
| At a glance | Details |
|---|---|
| Core question | Patch, refactor, or rewrite your RAG? |
| Top rewrite trigger | Retrieval misses on compound queries |
| Agent memory signal | No persistence across sessions |
| Cost of rewriting | Weeks to months of rework |
| What rewrite can't fix | Bad data, unclear requirements |
| First step | Audit failures before deciding |
In This Guide
- What Is RAG Architecture?
- Incremental Fixes vs Full RAG Rewrite
- The 7 Failure Points That Signal a RAG Rewrite
- When Your Rag Architecture Needs A Rewrite: A Step-by-Step Guide
- Rewrite vs. Incremental Improvement: A Decision Framework
- Agent Memory: The Rewrite Trigger Most Guides Miss
- Query Rewriting: A Fix That Often Prevents a Rewrite
- A Phased Process for Rewriting Your RAG Architecture
- How to Improve the Accuracy of RAG Without a Rewrite
- What a Rewrite Won't Solve (And When to Stick With What You Have)
- Common Mistakes When Your RAG Architecture Needs a Rewrite
- When RAG Is (and Isn't) the Right Choice
- Conclusion: Making the Rewrite Decision With Confidence
What Is RAG Architecture?
RAG architecture is a pipeline that retrieves relevant chunks from a knowledge base and feeds them to a language model as context, so the model generates answers grounded in your data instead of relying on training memory alone. The retriever finds the chunks, the generator writes the response. Everything else in the stack exists to make those two steps reliable.
Core components: encoder, chunker, indexer, retriever, generator
Five components do the work. The encoder converts text into vector embeddings using an embedding model. The chunker splits documents into pieces small enough to fit context windows but large enough to carry meaning. The indexer stores those vectors in a vector database so they can be searched by similarity. The retriever takes a query, embeds it, and pulls the top-k closest chunks. The generator, usually an LLM, receives those chunks plus the query and produces the final answer.
Each component can fail independently. A bad chunker produces fragments that lose context. A stale indexer returns outdated results. A weak retriever misses the right chunk entirely. When you're diagnosing a failing system, you map the symptom to the component before touching anything else.
How retrieval and generation interact
The retriever and generator are coupled through the context window. The retriever's output becomes the generator's input. If the retriever returns irrelevant chunks, the generator either ignores them or, worse, uses them to produce confident wrong answers. If it returns too many chunks, the generator's context overflows and something gets truncated.
Here's the interaction in practice: you send a query, the retriever scores every chunk in the index and returns the top 5 or 10. The generator sees those chunks plus your query and writes a response. The quality ceiling is set by the retriever. No prompt engineering fixes a retriever that consistently returns the wrong chunks.
Where agent memory fits into the RAG stack
Standard RAG is stateless. Every query starts fresh, with no memory of previous turns. Agent memory adds a persistence layer that stores conversation state, user preferences, and retrieved context across sessions. This layer sits alongside the retriever, not inside it.
The memory layer changes the architecture in one important way: the generator now receives context from two sources, the retriever and the memory store. When those sources conflict or overlap, the generator has to reconcile them. That reconciliation is where agent memory systems break in ways stateless RAG never does. You'll see the specific failure modes in the next section.
[!note] A rewrite cannot fix poor data quality, unclear product requirements, or fundamental misunderstandings of user needs. If your retrieval failures stem from missing or noisy documents, address data pipelines first.
Incremental Fixes vs Full RAG Rewrite
| Factor | Incremental Fixes | Full Rewrite |
|---|---|---|
| Time to implement | Days to weeks | Weeks to months |
| Risk level | Low to moderate | High |
| Addresses root cause | Sometimes, if issue is isolated | Yes, if architecture is fundamentally flawed |
| Agent memory support | Limited, may need workarounds | Designed in from the start |
| When to choose | Isolated failures, stable core | Systemic failures, scaling walls |
The 7 Failure Points That Signal a RAG Rewrite
Most RAG failures aren't mysterious. They cluster around seven specific points in the pipeline. The question isn't whether your system hits one of them. It's whether the failure is a tuning problem or a structural one.
FP1: Retrieval misses and low precision
Retrieval misses happen when the right chunk exists in your index but the retriever doesn't return it. Low precision is the opposite problem: the retriever returns chunks, but most are irrelevant. Both symptoms point to the same underlying question: is your embedding model a poor match for your data, or is your chunking strategy destroying the signal?
The threshold that matters: if retrieval accuracy stays below 70% on a held-out test set after tuning top-k and similarity thresholds, you're not tuning anymore. You're compensating. A rewrite of the retrieval layer, not the whole system, is usually the fix.
FP2: Context window overflow and truncation
When retrieved chunks plus the query exceed the generator's context window, something gets cut. Usually it's the middle chunks, or the tail end of the last one. The generator then answers from partial context and you get confident, wrong responses.
The symptom is easy to spot: answers that reference the first chunk but ignore the third. If you're constantly fighting the context limit by shrinking chunks or reducing top-k, the architecture itself is the problem. You need a reranking step, a summarization layer, or a different chunking strategy, not another prompt tweak.
FP3: Chunking strategy misalignment
Chunk size and overlap are the two knobs here. Too small and chunks lose context. Too large and they dilute relevance scores. The real failure shows up when your chunking strategy doesn't match how your documents are structured.
If your knowledge base is technical documentation with code blocks, a fixed 500-token chunker will split functions across boundaries. The retriever then returns half a function and the generator hallucinates the rest. This is a structural problem. You need structure-aware chunking, which means rewriting the indexing pipeline.
FP4: Embedding model drift
Embedding models encode meaning differently. If you built your index with one model and later switched to another, your stored vectors no longer match your query vectors. Retrieval quality collapses overnight.
The fix is re-indexing, not a rewrite. But if you're switching embedding models every few months because none of them work well on your domain, the problem is upstream. You may need a fine-tuned embedding model or a hybrid retrieval approach. That's an architectural decision.
FP5: Index staleness and update lag
How long does it take for new information to become retrievable? If your index updates nightly but your users need answers about events from this morning, the architecture is wrong for the use case.
Streaming updates or incremental indexing solve this, but they require a different indexer design. If you're running batch re-indexing on a schedule and the lag keeps causing user complaints, you're past the patch stage.
FP6: Generator hallucination from bad context
The generator can only be as good as the context it receives. When the retriever returns irrelevant chunks, the generator has two choices: ignore them and answer from training data, or use them and produce confident nonsense. Both look like hallucination.
The fix isn't a better prompt. It's a better retriever. If you've already tuned the retriever and hallucinations persist, the problem is likely in chunking or embedding quality. Trace the failure upstream before touching the generator.
FP7: Multi-turn and agent memory breakdown
Stateless RAG treats every query as independent. Agent memory systems don't have that luxury. When a user asks a follow-up question, the system needs to know what was asked before. If your memory layer doesn't persist across sessions, or if it stores context in a way that conflicts with the retriever's output, the generator gets contradictory signals.
This is the failure point most guides miss. It's also the one most likely to force a full rewrite, because retrofitting memory onto a stateless RAG pipeline usually means redesigning the orchestration layer from scratch.
[!tip] For agent memory systems, design persistence and context window management as first-class concerns. Test multi-turn conversations with realistic session lengths early, because retrofitting memory into a stateless RAG pipeline often forces a rewrite later.
When Your Rag Architecture Needs A Rewrite: A Step-by-Step Guide
- Audit your current RAG pipeline: log retrieval misses, latency spikes, and memory failures over at least one week.
- Classify each failure: is it a data problem, a query understanding problem, or an architecture problem?
- Apply the decision checklist: if more than two systemic triggers persist, a rewrite is likely warranted.
- Define rewrite requirements: include agent memory persistence, multi-turn context, and compound query handling from day one.
- Choose a phased approach: rewrite the retrieval layer first, then the memory layer, then orchestration.
- Build a parallel prototype and run A/B tests against your current system before full cutover.
- Document what the rewrite cannot fix (e.g., poor source data) and set realistic expectations with stakeholders.

Rewrite vs. Incremental Improvement: A Decision Framework
You've seen the seven failure points. Now you need to know which ones mean "patch it" and which ones mean "start over." The honest answer is that most RAG problems don't need a full rewrite. They need a component swap. The trick is knowing which component.
Symptom categories: retrieval quality, latency, maintainability, memory
Four categories cover almost every RAG complaint. Retrieval quality is the one everyone notices first: wrong chunks, missed answers, hallucinated citations. Latency is the one that kills production: queries that take 3 seconds when the budget is 300 milliseconds. Maintainability is the one that kills teams: every change to the pipeline breaks something else. Memory is the one that kills agents: context that doesn't survive a session, follow-ups that ignore the previous turn.
Each category has its own threshold. Below the threshold, you patch. Above it, you rewrite the component. Only when multiple categories cross their thresholds at once does a full architecture rewrite make sense.
Thresholds for each category: when to patch vs. rewrite
Retrieval quality: if accuracy sits below 70% on a held-out set after tuning top-k, similarity thresholds, and reranking, the retriever is structurally wrong. Patch first. Rewrite if the patch doesn't move the number.
Latency: if p95 latency exceeds your budget by more than 2x after optimizing index parameters and reducing chunk count, the pipeline has too many serial steps. That's a design problem, not a tuning problem.
Maintainability: if every new feature requires changes in three or more pipeline stages, the architecture is too coupled. You're not maintaining a system. You're negotiating with it.
Memory: if agent state doesn't persist across sessions, or if multi-turn context requires manual stitching, the memory layer is missing. You can't patch what isn't there. This is a rewrite trigger.
Decision tree: follow the symptoms to a recommendation
Start with the symptom. One category failing? Patch it. Two categories failing in the same component? Refactor that component. Three or more categories failing across different components? Rewrite the architecture.
Here's the sequence: if retrieval quality is the only problem, try query rewriting and reranking before touching the indexer. If latency is the only problem, profile the pipeline and cut the slowest stage. If maintainability is the only problem, extract the tangled component and give it a clean interface. If memory is the problem, you're building the persistence layer you should have had from the start.
The decision tree is simple because the symptoms are simple. What makes it hard is that most teams wait too long. They patch retrieval quality, then patch latency, then patch maintainability, and by the time memory breaks they've got four patches stacked on a foundation that was never designed for any of them.
When full replacement (not rewrite) is the right call
A rewrite means rebuilding your architecture on the same foundation: same vector database, same embedding model, same orchestration pattern. Full replacement means changing the foundation itself.
Replace when the vector database can't handle your scale or your query patterns. Replace when the embedding model is fundamentally wrong for your domain and no amount of fine-tuning fixes it. Replace when the orchestration framework forces you into patterns that fight your use case.
The test: if you can describe your target architecture and it shares more than half its components with your current one, you're rewriting. If it shares less than half, you're replacing. Both are legitimate. Just don't call a replacement a rewrite and expect the same timeline.
Agent Memory: The Rewrite Trigger Most Guides Miss
Most RAG guides treat retrieval as the whole problem. Get the right chunks, feed them to the generator, done. That works for stateless search. It falls apart the moment your system has to remember anything across turns or sessions. Agent memory is a different architecture problem, and it's the one that forces rewrites even when retrieval quality looks fine.
How agent memory differs from stateless RAG
Stateless RAG answers one query at a time. Each request is independent: embed the query, retrieve chunks, generate a response, forget everything. Agent memory breaks that assumption. The system has to track what the user asked three turns ago, what the agent already tried, what worked, and what's still pending. That state has to live somewhere.
The somewhere is the problem. A stateless pipeline has no place to put it. You can bolt on a session store, but the retriever doesn't know it exists. The generator doesn't know it exists. Every component treats each turn as turn one. The result is an agent that repeats itself, contradicts itself, or loses the thread entirely.
Persistence requirements: what breaks when memory doesn't survive sessions
Persistence means the agent's state survives a session boundary. User asks about a project on Monday, comes back Tuesday, says "continue where we left off." If the memory layer doesn't persist, the agent starts cold. It has no idea what "where we left off" means.
What breaks is trust. The user has to re-explain context the agent should already have. Multi-session workflows become impossible. Anything that requires accumulating knowledge over time, preferences, decisions, intermediate results, just evaporates.
The architectural catch: persistence isn't a feature you add to a stateless RAG pipeline. It's a storage layer with its own read and write paths, its own indexing strategy, its own eviction policy. If your current architecture has no concept of a session ID or a user ID flowing through every component, you're not patching. You're building the missing layer.
Context window management across multi-turn conversations
Every turn adds tokens. The user's new message, the retrieved chunks, the generator's response, the agent's internal reasoning. By turn five, you've blown past the context window and the model starts silently dropping the earliest turns. That's when the agent forgets the original goal and starts optimizing for whatever's in the last 500 tokens.
The fix isn't a bigger context window. It's a memory manager that decides what stays in context, what gets summarized, and what gets written to long-term storage. That's a new component. It sits between the retriever and the generator, and it changes how both of them work.
If your pipeline doesn't have this component, multi-turn conversations will always degrade. You can tune retrieval all day. The problem isn't what you're retrieving. It's what you're keeping.
Signs your memory layer is the rewrite trigger, not your retriever
Here's the test. Run your agent through a five-turn conversation. If retrieval quality is fine on turn one but the agent contradicts itself by turn three, the retriever isn't the problem. The memory layer is.
Other signs: the agent asks for information the user already provided. The agent repeats a failed action because it doesn't remember trying it. The agent's responses get shorter and more generic as the conversation continues, a sign the context window is full and the model is working with truncated state.
If you see any of these, stop tuning retrieval. You're optimizing the wrong component. The rewrite you need is a memory architecture: a persistence layer, a context manager, and a retrieval path that knows the difference between long-term knowledge and short-term conversation state. That's not a patch. It's a foundation.
Query Rewriting: A Fix That Often Prevents a Rewrite
Before you rip out your retriever, try query rewriting. It's the cheapest intervention that fixes a surprising number of retrieval failures. The idea is simple: take the user's raw query, run it through an LLM, and produce a better query before it hits the vector index.
What query rewriting solves (and what it doesn't)
Query rewriting fixes the gap between how users ask and how your index stores. A user types "that thing I asked about last week, the one with the pricing." Your index has chunks about "enterprise pricing tiers." Rewriting turns the vague reference into "enterprise pricing tiers" before retrieval runs. That's a real fix.
What it doesn't solve: bad chunks, stale embeddings, missing context, or a retriever that returns irrelevant results even for well-formed queries. If the index is broken, rewriting the query just gets you better-worded misses.
When query rewriting is sufficient
Query rewriting is sufficient when your retrieval failures are linguistic, not structural. The index has the right content. The embeddings are fine. The problem is that user queries are ambiguous, conversational, or reference earlier turns.
You'll know because the failures cluster around certain query types: pronouns ("it," "that"), implicit context ("the thing from before"), or domain jargon the user doesn't know. If a human reading the query can guess what the user meant, but your retriever can't, rewriting will help.
When query rewriting is a band-aid on a structural problem
If your chunks are too large, rewriting won't fix the precision problem. If your embedding model doesn't capture domain-specific meaning, rewriting won't fix the semantic gap. If your index is stale, rewriting won't bring back documents that aren't there.
The tell: you rewrite the query, retrieval improves slightly, but the same failures keep coming back in different forms. That's a sign the problem is upstream of the query. You're polishing the input to a broken component.
How to evaluate query rewriting performance
Run a side-by-side test. Take 50 real user queries that failed. Rewrite them manually, or with an LLM, and run both versions through your current retriever. Measure precision@5 on both.
If rewritten queries recover more than half the failures, query rewriting is worth implementing. If they recover less than a quarter, the problem isn't the query. It's the index, the chunks, or the embeddings. Stop rewriting and start looking there.
A Phased Process for Rewriting Your RAG Architecture
If query rewriting recovered less than a quarter of your failed retrievals, you've ruled out the cheap fix. The problem is structural. Here's a process that gets you from broken pipeline to working rewrite without losing the parts that still function.
Phase 1: Audit and baseline current performance
You can't measure improvement without a baseline. Before touching any code, capture your current numbers.
Run a fixed evaluation set of at least 100 queries through the pipeline. Record precision@5, recall@10, latency at each stage, and the percentage of queries where the generator hallucinated. Store this as a JSON file or a spreadsheet. You'll compare every migration phase against it.
Also map the data flow. Draw the pipeline: ingestion, chunking, embedding, indexing, retrieval, reranking, generation. Note where each component lives, what model it uses, and how data moves between stages. If you can't draw this in an afternoon, you don't understand your own system well enough to rewrite it.
Phase 2: Isolate the failing component(s)
The audit gives you numbers. Now find where the failures originate.
Run retrieval-only tests. Feed the retriever queries and score the results before generation touches them. If retrieval precision is already low, the generator isn't the problem. If retrieval is fine but generation hallucinates, the issue is context assembly or prompting.
Test each stage independently. Swap in a simple BM25 retriever and see if precision changes. Try a different chunk size on a sample of documents. Change one variable at a time. The component that moves the metric most when changed is your rewrite target.
Don't rewrite everything. Most RAG failures trace to one or two components. Find them.
Phase 3: Design the target architecture
Now you know what's broken. Design the replacement before you build it.
Write down the new architecture as a diagram with explicit interfaces between components. Decide what stays: if your embedding model is fine, keep it. If your index structure works, keep it. The rewrite targets only the failing parts.
For each component you're replacing, specify the input, output, and evaluation criteria. "New chunker must produce chunks between 200 and 400 tokens with no sentence splits" is a spec. "Better chunking" is not.
Phase 4: Migrate incrementally with parallel testing
Don't cut over in one move. Run the old and new pipelines side by side.
Start with a shadow deployment. Route 10% of traffic to the new pipeline and log results without serving them to users. Compare outputs against the old pipeline on the same queries. Fix discrepancies before increasing traffic.
Then move to 50%, then 100%. At each step, check the baseline metrics from Phase 1. If the new pipeline regresses on any metric, roll back that component and investigate before proceeding.
Phase 5: Validate and monitor post-rewrite
The rewrite isn't done when the new pipeline ships. It's done when the new pipeline holds its numbers in production.
Set up monitoring on the same metrics you baselined in Phase 1. Track precision, latency, and hallucination rate over time. Set alerts for when any metric drops below 90% of the baseline.
Run the full evaluation set weekly for the first month. If performance drifts, you'll catch it before users do. The rewrite is complete when the new architecture matches or beats the old baseline for four consecutive weeks.
How to Improve the Accuracy of RAG Without a Rewrite
Before you commit to the phased rewrite, try the cheap fixes. Most accuracy problems trace to one or two components, and swapping those components takes days, not months. The honest answer is that a quarter of the pipelines I've seen flagged for rewrite recovered enough accuracy from these four changes to avoid the rewrite entirely.
Reranking and hybrid search
Your retriever returns 20 candidates. Your generator sees the top 5. If the right chunk sits at position 12, it never reaches the generator.
Reranking fixes this. Run a cross-encoder over the top 20 candidates and rescore them for semantic relevance to the query. The cross-encoder is slower than the bi-encoder that produced the initial ranking, but it's far more precise. You only pay that cost on 20 chunks, not the whole index.
Hybrid search combines BM25 keyword matching with vector similarity. BM25 catches exact terms and rare identifiers that embeddings blur. Vector search catches paraphrases. Merge the two result sets with reciprocal rank fusion, and retrieval precision often jumps 10 to 20 points without touching your index.
Better chunking strategies
Chunk size is the most common silent killer of RAG accuracy. Chunks under 100 tokens lose context. Chunks over 1,000 tokens bury the answer in noise.
Start by measuring your average query's answer span. If answers typically live in a single paragraph, chunk at 200 to 400 tokens with sentence-boundary awareness. If answers span sections, use parent-child chunking: index small chunks for retrieval but return the larger parent chunk to the generator.
Don't split sentences. A chunk that cuts mid-sentence produces embeddings that don't match anything.
Embedding model upgrades
Your embedding model determines the ceiling on retrieval quality. If you built the pipeline two years ago on a general-purpose model, a newer model tuned for retrieval can lift precision without any other change.
Test before you commit. Run your evaluation set through two or three candidate models and compare recall@10. A 5-point improvement is worth the migration. A 1-point improvement is not.
Keep in mind that changing the embedding model means re-embedding your entire corpus. That's a batch job, not a code change. Budget for it.
Prompt engineering for the generator
The generator can only work with what the retriever gives it. But a bad prompt wastes good context.
Tell the generator to answer only from the provided chunks and to say "I don't have that information" when the chunks don't contain the answer. This single instruction cuts hallucination more than most architectural changes.
Also include the source chunk IDs in the prompt and ask the generator to cite them. When the generator cites a chunk that doesn't support its claim, you've found a retrieval or context assembly problem, not a generation problem. That distinction tells you which component to fix next.
What a Rewrite Won't Solve (And When to Stick With What You Have)
A rewrite changes your architecture. It doesn't change your data, your requirements, or your organization. If the problem lives in one of those three, a rewrite burns months and delivers the same failures on new infrastructure.
Data quality problems a rewrite can't fix
Garbage in, garbage out. If your source documents are contradictory, outdated, or missing the answers users actually need, no retriever or chunking strategy will recover them. A rewrite that swaps your vector database or reranker won't make a knowledge base complete.
Check this first. Pull 50 real user queries and read the source documents yourself. If the answer isn't in the corpus, the problem is content, not architecture. Fix the content pipeline before touching code.
Model limitations that persist across architectures
Embedding models and generators have ceilings. If your queries require reasoning across multiple documents, or domain knowledge your embedding model never saw during training, a new architecture won't close that gap.
The constraint follows the model, not the pipeline. A rewrite that keeps the same embedding model and generator will hit the same accuracy wall. If you've already tested three architectures and retrieval precision stalls at the same number, the model is the bottleneck. Upgrade the model, not the architecture.
When the problem is process, not architecture
Some teams rewrite because the codebase is messy. The retriever, indexer, and generator are tangled together, and every change breaks something else. That's a maintainability problem, and a rewrite can solve it.
But if the real issue is that nobody owns the evaluation set, or retrieval quality isn't measured before each deploy, a rewrite won't help. You'll rebuild the system and still ship regressions because the process that catches them doesn't exist. Fix the evaluation and monitoring loop first. It's cheaper and it tells you whether the architecture is actually the problem.
Signs you should stick with your current RAG system
Don't rewrite if retrieval precision is above 80% and your users aren't complaining. Don't rewrite if the failures are rare, specific, and traceable to one component you can swap in a week. Don't rewrite if you're within three months of a launch and the system works well enough to ship.
The strongest signal: you can't name the specific failure point a rewrite would fix. If you're rewriting because the system feels fragile, not because you've isolated a broken component, you're guessing. Instrument the pipeline, find the failure, then decide.
Common Mistakes When Your RAG Architecture Needs a Rewrite
Most rewrite failures aren't technical. They're scope failures. Teams rip out a working system, rebuild everything, and ship something that fails differently but not less. The mistakes below are the ones I see repeat across production RAG rewrites, and they're avoidable if you catch them before the first commit.
Rewriting everything instead of the failing component
A rewrite is not a demolition. If your retriever precision is 72% but your chunking and embedding pipeline work fine, you don't need to touch them. You need a new retriever, or a reranker in front of it, or a hybrid search layer.
The temptation is to rebuild the whole stack while you're in there. Don't. Every component you replace is a component that can introduce new failure modes you haven't seen yet. Isolate the failing piece, swap it, and leave the rest alone. You'll ship faster and you'll know exactly what changed if performance drops.
Ignoring evaluation metrics during migration
You can't rewrite blind. If you don't have a baseline eval set before you start, you have no way to know whether the new architecture is better or just different.
Build the eval set first. Fifty to a hundred real queries with known-good answers, scored for retrieval precision and answer quality. Run it against the old system. That's your baseline. Run it against every phase of the rewrite. If the new system doesn't beat the old one on the same eval set, you're not done. If you skip this, you'll finish the rewrite and have an opinion, not a measurement.
Over-engineering for scale you don't have
The rewrite that fails most often is the one built for a scale that never arrives. Teams add distributed vector databases, multi-region replication, and streaming index updates because the architecture diagram looks right. Then they run 200 queries a day.
Match the architecture to your actual load. If you're serving a thousand documents and a hundred queries a day, a single Postgres instance with pgvector is enough. You don't need Kubernetes, you don't need a dedicated vector database cluster, and you don't need a message queue for index updates. Build for your current scale with a clear migration path, not for a hypothetical future.
Losing the working parts of the old system
Your old system has parts that work. The chunking strategy that took three months to tune. The prompt template that cut hallucination by half. The eval set you built after the last incident. A rewrite that throws all of it away starts from zero, and zero is where the old mistakes live.
Inventory what works before you start. Keep the chunking config. Keep the prompt template. Keep the eval set. Port them into the new architecture unchanged. The rewrite should change the parts that are broken, not the parts that took you months to get right.
When RAG Is (and Isn't) the Right Choice
Before you commit to a rewrite, ask whether RAG itself is the right architecture for the problem. A rewrite of the wrong architecture is still the wrong architecture.
When RAG is the right architecture
RAG fits when your knowledge base changes faster than your model retraining cycle. If you're adding documents daily, or your data is proprietary and can't sit in a public model's weights, RAG is the honest answer. It also fits when you need citations. Users can see which document produced an answer, and that traceability matters in regulated or high-stakes contexts.
When fine-tuning or other approaches are better
Fine-tuning wins when your task is narrow and stable. If you're classifying support tickets into twenty categories, or extracting the same fields from invoices every day, a fine-tuned model is cheaper to run and more consistent than a RAG pipeline. You don't need retrieval when the knowledge doesn't change.
Fine-tuning also helps when the model needs to learn a style or format that retrieval can't inject. A RAG system can feed examples into the prompt, but it can't change how the model weighs those examples. Fine-tuning can.
When a non-RAG solution is the answer
Sometimes the answer is no LLM at all. If your queries are predictable and your data is structured, a SQL query or a search index does the job faster and with zero hallucination risk. Don't bolt RAG onto a problem that a WHERE clause already solves.
The honest test: does your data change often, and do your users ask questions you can't predict? If both are yes, RAG earns its complexity. If either is no, you may be building a pipeline you don't need.
Conclusion: Making the Rewrite Decision With Confidence
The decision comes down to one question: is the failure in a component, or in the architecture itself? Components can be patched. A retriever that misses because the chunk size is wrong is a fix. A retriever that misses because the index doesn't support the query patterns your users actually run is a rewrite.
Here's the framework in one pass. If retrieval quality is below your threshold and query rewriting plus reranking don't move the needle, rewrite. If latency is killing you and the bottleneck is a synchronous pipeline that can't be parallelized without structural change, rewrite. If agent memory doesn't persist across sessions and your current persistence layer was bolted on after the fact, rewrite. If maintainability is collapsing and every new feature touches five components, rewrite. If none of those are true, patch what's broken and keep shipping.
The honest answer is that most systems don't need a full rewrite. They need one component replaced and better evaluation metrics. But when the triggers line up, delaying the rewrite costs more than the rewrite itself. You'll spend months patching symptoms while the architecture fights you.
Start with the audit. Baseline your current performance, isolate the failing component, and design the target architecture before you touch any code. Migrate incrementally with parallel testing so you can compare old against new on real queries. GigaRAG is built for exactly this: agent memory and RAG pipeline builders who need to get the architecture right the first time, with persistence and context management handled as first-class concerns rather than afterthoughts.
When your RAG architecture needs a rewrite, the decision isn't about courage. It's about evidence. You now have the triggers, the thresholds, and the process. Run the audit. Follow the symptoms. Make the call.
Frequently Asked Questions
How to improve the accuracy of RAG?
Improve accuracy by enhancing data quality, using better embedding models, and adding query rewriting or expansion. For agent memory, ensure retrieval considers conversation history. If accuracy issues are systemic across these areas, a rewrite may be more effective than patching.
What is the architecture of a RAG system?
A typical RAG architecture includes a retriever (vector or hybrid search), a generator (LLM), and an orchestration layer. Advanced systems add query rewriting, re-ranking, and memory modules. If your architecture lacks memory or compound query support, it may need a rewrite.
What architecture is used in RAG to retrieve relevant data?
Common retrieval architectures include dense vector search, sparse keyword search (like BM25), and hybrid approaches. The choice depends on your data and query types. If retrieval consistently misses relevant data despite tuning, the architecture may be the bottleneck.
What is query rewriting?
Query rewriting transforms a user's query into a more effective search query, often using an LLM. It helps with ambiguous or compound questions. If your RAG system fails on such queries, adding query rewriting might be an incremental fix before considering a rewrite.
When should I rewrite my RAG architecture instead of patching?
Rewrite when failures are systemic: retrieval misses on compound queries, agent memory doesn't persist across sessions, and every fix introduces new problems. If more than two of these persist after incremental fixes, a rewrite is likely warranted.
What are the signs that my RAG system needs a rewrite for agent memory?
Signs include: memory not persisting across sessions, context windows overflowing in multi-turn conversations, and inability to handle long-term user preferences. If your architecture treats each query as stateless, retrofitting memory is hard and a rewrite may be needed.
What can't a RAG rewrite fix?
A rewrite cannot fix poor data quality, unclear requirements, or fundamental mismatches between your system and user needs. If your source data is noisy or incomplete, focus on data pipelines first.
About GigaRAG
GigaRAG is for agent memory and RAG pipeline builders. get this right. Whether you are working through when your rag architecture needs a rewrite or something adjacent, we publish what we have actually tested, including where it falls short.


