---
title: You get a small RAG-service repository with failing tests and a bug report saying answers ignore the newest documents…
url: https://gurkanozkan.ai/learn/questions/applied-llm-dbg-09/
markdown: https://gurkanozkan.ai/learn/questions/applied-llm-dbg-09.md
kind: question
role: Applied LLM
stage: Coding
difficulty: Medium
json: https://gurkanozkan.ai/api/learn/questions/applied-llm-dbg-09.json
robots: noindex
---

# You get a small RAG-service repository with failing tests and a bug report saying answers ignore the newest documents. Find and fix it while narrating — or review a messy pull request to the same service and give feedback.

Applied LLM · Coding · Medium

Theme reported publicly: [Mistral AI](https://jobsbyculture.com/blog/mistral-interview-prep-2026), [Anthropic](https://interviewing.io/anthropic-interview-questions), [Spotify](https://interviewing.io/spotify-interview-questions)

## Answer

*Model answer, written in a candidate's voice*

### In short

- Reproduce with the failing test first and confirm the newest-document answer is wrong
- Trace ingestion to index to retrieval to prompt, checking each stage
- Rule out inverted date sort/filter, upsert keying, stale cache, chunk-overlap off-by-one, async ingestion race
- Use logs/debugger and assertions instead of guessing
- Make the minimal fix at the confirmed stage and add a regression test
- If reviewing a PR instead, prioritise correctness, then design and naming, with kind specific feedback

### In full

I would start by running the failing test and confirming the exact failure: a query over the newest document returns an answer built from older content. Then I would trace the path end to end — ingestion timestamp and version, the index upsert key, retrieval filters and sort order, and the prompt assembly — checking each stage with logs or a debugger rather than guessing. The likely bug classes to rule out are an inverted date sort or filter, upserts keyed so new versions do not replace old ones, a stale cache, a chunk-overlap off-by-one, and an async ingestion race where the index is queried before the new document is visible. Once the stage is confirmed, I would make the smallest change there, add a regression test that ingests a newer document and asserts the answer uses it, and re-run the failing test plus the surrounding suite. If this were a PR review instead, I would lead with correctness — async misuse, error handling, and secrets — then design and naming, and give specific, kind feedback rather than a vague rewrite request.

*Corrected by an independent AI reviewer.*

## What a strong answer covers

- Reproduces with the failing test first; traces ingestion → index → retrieval → prompt
- Plausible bug classes: inverted date sort/filter, upserts keyed so new versions don't replace old, stale cache, chunk-overlap off-by-one, async ingestion race
- Uses logs/debugger over guessing; adds a regression test; minimal change
- In PR review: prioritises correctness (async misuse, error handling, secrets), then design and naming; kind, specific feedback

## Common mistakes

- Large rewrites
- fixing symptoms without a test; nit-picking style while missing a correctness bug

## Topic guides

- [Debugging ML and LLM systems](https://gurkanozkan.ai/learn/topics/debugging.md)
- [Retrieval-augmented generation](https://gurkanozkan.ai/learn/topics/rag.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
