Hi everyone,
I’m trying to debug my custom retriever function. I spent a whole day trying to figure out:
- Why my
print
orlogger
statements inside theretriever
function do not show any output, - Why the agent continues as if the retriever worked fine, without actually showing or acknowledging the result.
To reproduce and better understand the problem, I created the following minimal example from your cookbook:
from typing import Optional
from agno.agent import Agent
from agno.embedder.openai import OpenAIEmbedder
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.vectordb.qdrant import Qdrant
from qdrant_client import QdrantClient
from models.llm_models import create_llm_model
from services.embedder import embed_single
def retriever(
query: str, agent: Optional[Agent] = None, num_documents: int = 5, **kwargs
) -> Optional[list[dict]]:
try:
print(f"Running retriever with query: {query}, num_documents: {num_documents}, kwargs: {kwargs}")
query_embedding = embed_single(query)
print(f"Query embedding: {query_embedding}")
return None
except Exception as e:
print(f"Error during vector database search: {str(e)}")
return None
def main():
agent = Agent(
model=create_llm_model(),
retriever=retriever,
search_knowledge=True,
instructions="Search the knowledge base for information",
show_tool_calls=True,
)
query = "List down the ingredients to make Massaman Gai"
agent.print_response(query, markdown=True)
if __name__ == "__main__":
main()
Here’s what I see in the terminal output:
━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
List down the ingredients to make Massaman Gai
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┏━ Response (9.3s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
<tool_call> {"name": "search_knowledge_base", "arguments": {"query": "Massaman Gai ingredients"}}
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
But none of my print()
statements from the retriever function show up. Also, I expect the agent to say something like:
“I got these results from the retriever and will now answer your question…”
But instead, it silently proceeds.
Questions:
- Is
print()
orlogger
output from a custom retriever suppressed insideAgent
? - How can I inspect what the retriever is actually returning or if it was called at all?
- Is there a way to make the agent explicitly react to the retriever’s output?
Any help would be highly appreciated!