ntegrating External Tools for Knowledge Gaps

I am currently working on an AI agent using Phidata that leverages a (RAG) setup for answering user queries. I want to enhance the agent’s capabilities by integrating external tools (like web search via DuckDuckGo or other APIs) to fetch answers when the knowledge base lacks relevant information.

Here’s what I aim to achieve:

  1. Detect when a query cannot be answered using the existing knowledge base.
  2. Seamlessly fallback to external tools to retrieve accurate information.
  3. Maintain transparency in the agent’s responses (e.g., indicating when an external tool was used).

Could you guide me on how to effectively configure and manage this fallback mechanism.

Hi @Agent_Musk
Thank you for reaching out and using Phidata! We’re currently easing into the New Year, so the team might take a bit longer than usual to respond, but we’ll aim to get back to you within 24 hours. I’ve also tagged the relevant engineers to assist you with your query.

If this is urgent, please let us know, and we’ll do our best to prioritize it.

Thanks for your understanding and patience, and Happy New Year!

@Agent_Musk you can use instructions in the agent config and mention to use these tools if it doesn’t find the answer from the knowledge base. You can also tell it to mention the source of the answer

and where is this agent config? in this code ??

web_search_agent=Agent(
    name="web_search_agent",
    role="Researcher Agent", 
    description="Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.",
    instructions="""
    Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics."'"",
    tools=[GoogleSearch()],
    markdown=True,
    model=Gemini(id="gemini-2.0-flash-exp"),
    add_datetime_to_instructions=True,
    show_tool_calls=True,
)

agent config is exactly what you have shared with me. You can edit the instructions.

web_search_agent=Agent(
    name="web_search_agent",
    role="Researcher Agent", 
    description="Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.",
    instructions=[
    "Your goal is to assists in content research by gathering, analyzing, and summarizing information on specified topics.",
    "Use knowledge base to answer the query but if you aren't able to get a definitive answer then use google search to answer"   
],
    tools=[GoogleSearch()],
    markdown=True,
    model=Gemini(id="gemini-2.0-flash-exp"),
    add_datetime_to_instructions=True,
    show_tool_calls=True,
)

Something like this should work

2 Likes

Thanks @manthanguptaa

okay i see the error wass in the quote. i thought agent config is some other parameter that i have to pass. thanks for help