Hi I want to ask about ai chat model running twice because of tool usage. I have an ai agent that needs to look into database and if there’s a recorded data with the same item it will remove it from the output, e.g. the ai agent will receive bunch of data and it will search the database if there isn’t duplicate data all the data will be outputted but if there’s a duplicate data it will outputting only the unduplicated data.
When I ran the ai agent I notice that the ai chat model run twice, before the tool usage and after the tool usage. When I looked at the log I saw the first call ai agent will say something like “I will look at the database for duplicate data” and the second call outputting the output that will be use for the second node.
The problem is when I looked for the second ai chat model call I notice it has the same input prompt from the first call and when I looked at the usage log I notice that it indeed run with twice cost. Is this the expected behavior of the ai agent or not?