How to debug custom retriever

Hi everyone,

I’m trying to debug my custom retriever function. I spent a whole day trying to figure out:

  1. Why my print or logger statements inside the retriever function do not show any output,
  2. 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:

  1. Is print() or logger output from a custom retriever suppressed inside Agent?
  2. How can I inspect what the retriever is actually returning or if it was called at all?
  3. Is there a way to make the agent explicitly react to the retriever’s output?

Any help would be highly appreciated! :folded_hands:

The issue is vllm arguments.
instead of this
--tool-call-parser pythonic
use this
--tool-call-parser hermes.

I got no warning though.

Hey @yusufani, thank you for reaching out. Please let me know if your issue is resolved? if not, we are here to help