Only 10 rows returned when using Agent with tool SQLTools

Issue:
agent = Agent(tools=[SQLTools(db_url=connection_url,tables=dict_from_excel)], model=phi_llm_chat, debug_mode=False, show_tool_calls=True,
markdown=True, instructions=INSTRUCTIONS, description=DESCRIPTION)
agent.run(user_query)
returns only 10 rows.

Observation:
agent.run() calls run_sql_query() internally and it has default limit as 10. I could not find a way to update the limit when running agent.run().

@anki0812, the LIMIT parameter is an optional argument in the SQL tools. You can specify it directly in your user query by writing something like: ‘List 50 entries from the table’ / You can also specify it in the instructions. The function params, data type and description is extracted by phidata and provided to the agent

Let me know if it works you. You can read more about it here: Tools - Phidata

My query to Agent is like “Give me list of all the entity names in Germany”. Sometimes it returns all data, but sometimes only 10 rows. I have mentioned as part of Agents Instruction attribute also to return the complete list.
image

Hello @anki0812 ! The input params to the function are decided by the Agent. For example, the Agent has access to the following doc string: The number of rows to return. Defaults to 10. Use None to show all results. So, explicit instructions like: For the function run_sql_query, never provide a limit.

This approach relies on the Agent following your instructions. Which can be unreliable sometimes depending upon the model being used. Alternatively, you can define your own run_sql_query function without a limit. Please let us know if you have any questions.

I understand that the agent’s response can be uncertain and might not be able to predict the expected row count. In such case, I would suggest that the default max_row should be None, so that atleast we get all information if the agent is not able to predict the number of rows.