https://retellai.com/?utm_source=discord&utm_medium=seo logo
Sometimes my agent retrieves info from the knowled...
# ❓・ai-evy-support
c
@AI Evy Sometimes my agent retrieves info from the knowledge base even if it is not required. how to avoid it?
a
Thanks for tagging me @carlo_98907. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available documentation, when a knowledge base is linked to an agent, the agent will always try to retrieve information from the knowledge base before responding [(1) ]() . This happens automatically for every response generation, and there's no need to change your prompt for it to trigger . However, you can control how the agent uses the retrieved information by adding specific instructions to your agent's prompt. The documentation suggests adding the following prompt to prevent the LLM from generating information not found in the knowledge base :
Copy code
Only answer using the information in ## Related Knowledge Base Contexts.
If ## Related Knowledge Base Contexts is missing or does not contain relevant information, respond:
"There is no related information in knowledge base."
This approach forces the agent to only use information from the knowledge base when it's relevant and explicitly state when no relevant information is available . While this doesn't prevent retrieval from happening (as retrieval is automatic) , it controls how the agent responds when the retrieved information isn't relevant to the current conversation. You can also check what's being retrieved from the knowledge base through the
knowledge_base_retrieved_contents_url
field available in call responses [(2) ]() .
​ To learn more, see the sources I considered: [[1] Knowledge Base](https://docs.retellai.com/build/knowledge-base) [[2] Get Call](https://docs.retellai.com/api-references/get-call) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.