Home
BlogTalksPapersAbout
Nikita Kozodoi

Blog

27Posts
Nikita Kozodoi

Improve LLM Responses in RAG Use Cases by Interacting with the User

Home
Blog
Improve LLM Responses in RAG Use Cases by Interacting with the User
Nikita KozodoiNovember 2023

Teaching a RAG agent to ask instead of guessing

Read the full post on AWS Blog

Ask a RAG system a vague question and you tend to get one of two bad answers: "I don't know", or a confident invention. Neither is really a retrieval failure. The question didn't carry enough detail, and the system went ahead and answered anyway. A person would have asked what you meant, and this post gives the system that option.

The setup is a LangChain agent running on an Amazon Bedrock model, retrieving from an Amazon Kendra index built over the AWS documentation for Kendra, Lex and SageMaker, with a Streamlit front end. A conventional agent here has one tool: fetch documents, put them in the prompt, answer. We add a second tool that asks the user a clarifying question, and let the agent choose between them. So when a query is too vague to retrieve against, the agent asks for the missing detail, folds the answer back into the query, and retrieves again with something specific enough to match.

The hard part is the choice rather than the dialogue. The agent has to notice that a question is ambiguous before it has an answer to judge, and that recognition lives in the prompt and in how you describe the two tools to it. Get those descriptions wrong and it either interrogates people who asked perfectly clear questions, or carries on guessing as before. Code is on GitHub.

Related content

Talk

Building Chatbots That Know All About Your Business: Retrieval Augmented Generation

2024
Talk

Five Techniques for Improving RAG Chatbots

2024
Blog

Detect Hallucinations for RAG-Based Systems

2025

© 2026 Nikita Kozodoi. All opinions are my own. RSS