I am building an agent using AI SDK + OpenAI SDK. I’m calling a second generic “Agent Service” which is OpenAI compatible. Several tools are executed on the generic Service side, while some are executed on the Agent itself. When a tool is called on the agent side, the generic service will wait until the agent sent the tool call result to the generic service.
This works as expected, but we would like to stream ALL tool calls from the generic service to the agent, but only execute the “custom” ones that cannot be executed on the generic service. Currently, when we stream all tool calls, some will be executed twice.
We are passing a flag whether it is executed already or not via the raw tool-call OpenAI event. How can I use this to prevent AI SDK from making the tool call a second time?