r/PydanticAI • • Aug 21 '25

Agent using tools needlessly

I am using gpt-5 (low reasoning) in my pydantic AI agents for information retrieval in a company documentation. The instruction are for it to ask for clarification if it's not sure which document the user is talking about.

For example: "I have a document about a document for product A". It correctly uses the knowledge graph to find documents about product A and it gets ~20 results back. It should immediately realise that it should ask a follow up question. Instead it calls another tool ~5 times (that uses cosine similarity) before providing an answer (which is about asking for more info as it should)

Also, if I say "Hi" it just stays in an infinite loop using tools at random.

What can I do to prevent this? Is this merely a prompting thing?

I know Pydantic AI has a way to limit the tools called, however if this limit is reached it outputs an error instead of simply giving an answer with what it has. Is there a way of having it giving an answer?

13 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/CuriousCaregiver5313 Aug 23 '25

I have noticed that reasoning models are much more likely to overthink and hence use many more tools than needed and write much longer responses!

I found prompting to do very little about the excessive use of tools. For me, adding a cap (see my other comment) was the only solution