Response format with SQL Toolkit

I’m using Postgres Toolkit and would like to add a response schema. The agent is running the right query but the response is empty.

Are there specific schemas or workaround to get the output table in some kind of format?

class QueryResult(BaseModel):
   # str if the response is not a table
   # otherwise a list of dict
   result: Union[List[Dict[str, Any]], str]

database_agent = Agent(
    name="DatabaseAgent",
    model=OpenAIChat(id="o3-mini"),
    description="some description",
    role="some role",
    instructions="some instructions",
    tools=[
        PostgresTools(
            host=os.getenv("DB_HOST"),
            port=os.getenv("DB_PORT"),
            db_name=os.getenv("DB_NAME"),
            user=os.getenv("DB_USER"),
            password=os.getenv("DB_PASSWORD"),
            run_queries=True,
            inspect_queries=True,
            summarize_tables=True,
            export_tables=False,
        )
    ],
    read_chat_history=True,
    add_history_to_messages=True,
    response_model=QueryResult,
    telemetry=False,
    monitoring=False,
)```

Hi @zzzrbob, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.
If it’s urgent, please let us know. We appreciate your patience!

Hey @zzzrbob , apologies for the delay- would you be able to confirm us two things:

  1. if the query returned the right result for it?
  2. yes you should be able to user response model here: Structured Output - Agno

I have seen adding good instructions often help here. Let me know if this helps?