How to limit tool calls to only one?

Since the reply has to return all the tool calls w/ their ids, it is a pain when only one tool call is valid, especially when the agent should have called it one by one/chaining from it’s output instead of calling for multiple at once. I have gotten around this by prompting it to limit the tool calls to 1 and just returning a “Error: only use one tool at a time” back to any extra tool calls.

There should be an option to only limit the tool calls to one.

1 Like

I was having this problem with an assistant and my solution, as much as I didn’t like it at the time, was just better instructions so the assistant is clear on how to use the functions. My assistant gets the func calls right 100% of the time now for well over a month.

You can try to throw your instruction prompt into chatGPT and explain your problem and ask it to make it more clear.

3 Likes

Hey, thanks for the reply.

I see, I should prompt it better if the results are pretty stable. Still would like a direct way to control it instead of patchworking around it. That would be my feedback to the devs. :smile:

Best,
Wai

1 Like

+1 on this, I have a use case where I want to call the same tool multiple times, but I want to limit the number of times it can be called, otherwise it can exceed max_tokens and cause a 500 server error!

AI can make these faster than I:

graph TD
    A(Start) --> B(Initialize: iteration_count = 0)
    B --> C(Wait for User Input)

    C --> D{On User Input}
    D -->|Reset iteration_count| E(Process User Request)
    E --> F{Is tool required?}
    F -->|No| G(Generate and emit final answer to user)
    G --> C

    F -->|Yes| H(Call Tool Function)
    H --> I{iteration_count <= 10?}
    I -->|Yes| J(Wait for Tool Output)
    J --> K(Process Tool Output)
    K --> L{Need to call the same or another tool again?}
    L -->|No| G
    L -->|Yes| M(Increment iteration_count)
    M --> H

    I -->|No| N[Stop and respond to user: Max iterations reached]
    N --> C

Big drawback is I’d have to make the same call N times which is expensive

If there aren’t enough tokens remaining to generate a tool call, I’d rather it return the incomplete JSON and I can just throw out the bad calls if necessary