# Assistants API expects multiple tool\_calls, even though only one function provided

**URL:** https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641
**Category:** Bugs
**Tags:** api
**Created:** [November 17, 2023, 11:51am UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641 "2023-11-17T11:51:19Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![james40](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/james40/32/251975_2.png) [@james40](https://community.openai.com/u/james40)
#### Post date: [November 17, 2023, 11:51am UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/1 "2023-11-17T11:51:19Z")

</div>

I have an assistant with a single function. Yet the Assistants API returns multiple tool\_calls and expects results from all of them

I noticed the errors because my backend does a POST to …/submit\_tool\_outputs with the result for the function call I defined, however that throws an error, because the API expects multiple.

Upon further inspection, it seems the API often expects tool\_calls for names including:

search, calculate or open\_url

This doesn’t really make sense and is causing problems, I assume those are tools that OpenAI should be handling.

---

<div class="post-metadata">

### Author: ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)
#### Post date: [November 17, 2023, 11:59am UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/2 "2023-11-17T11:59:08Z")

</div>

Can you post code snippets of your api calls and the prompts behind them? any function definitions you have as well please, also could you include the logs from the posts? As much data as you can to help us to help you.

---

<div class="post-metadata">

### Author: ![james40](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/james40/32/251975_2.png) [@james40](https://community.openai.com/u/james40)
#### Post date: [November 17, 2023, 1:02pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/3 "2023-11-17T13:02:04Z")

</div>

Here is an example error call:

POST  
`/threads/{$threadId}/runs/{$runId}/submit_tool_outputs`

```auto
{
    "tool_outputs": [
      {
        "tool_call_id": "call_0ORM2unDOuMOpNyEdF1Plmk7",
        "output": "example output redacted"
      }
    ]
  }

```

RESPONSE:

```auto

{
  "error": {
    "message": "Expected tool outputs for call_ids ['call_0ORM2unDOuMOpNyEdF1Plmk7', 'call_kdPD6iLYf9Sx1wla6BwTbqYe'], got ['call_0ORM2unDOuMOpNyEdF1Plmk7']",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

```

As I mentioned, I only have a single function defined, here is a slightly redacted version of it. The parameter names are the same:

```auto
{
  "name": "example_name",
  "description": "Example description.",
  "parameters": {
    "type": "object",
    "properties": {
      "reason": {
        "type": "string",
        "description": "Example description."
      },
      "urgency": {
        "type": "string",
        "description": "Example description."
      }
    },
    "required": [
      "reason"
    ]
  }
}

```

The issue seems to be that the submit\_tool\_outputs endpoint expects outputs from other “tools”, which I guess are internal to OpenAI e.g. I have seen “calculate” and “search”

---

<div class="post-metadata">

### Author: ![reven8e.sh](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/reven8e.sh/32/148833_2.png) [@reven8e.sh](https://community.openai.com/u/reven8e.sh)
#### Post date: [November 22, 2023, 4:44pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/4 "2023-11-22T16:44:33Z")

</div>

Fixed the problem!

```auto
while True:
    run_status = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)

    if run_status.status == 'completed':
        break

    elif run_status.status == 'requires_action':
        tools_outputs = []

        for tool_call in run_status.required_action.submit_tool_outputs.tool_calls:
            if tool_call.function.name == "google_search":
                arguments = json.loads(tool_call.function.arguments)

                print(f"Running tool - '{tool_call.function.name}' | With args - {arguments}")
                output = google_search(arguments["query"])
                print(len(output), output)

                tool_output = {"tool_call_id":tool_call.id, "output": json.dumps(output)}
                tools_outputs.append(tool_output)

        if run_status.required_action.type == 'submit_tool_outputs':
            print("Submit output")
            client.beta.threads.runs.submit_tool_outputs(thread_id=thread.id, run_id=run.id, tool_outputs=tools_outputs)

        time.sleep(1)

```

---

<div class="post-metadata">

### Author: ![MichaelDotBT](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@MichaelDotBT](https://community.openai.com/u/MichaelDotBT)
#### Post date: [December 7, 2023, 12:08pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/5 "2023-12-07T12:08:49Z")

</div>

thanks for the help here. It was not exactly what I needed but gave me the clue to get the my setup working with multiple concurrent tool calls.

---

<div class="post-metadata">

### Author: ![neuronclimb](https://avatars.discourse-cdn.com/v4/letter/n/ce7236/32.png) [@neuronclimb](https://community.openai.com/u/neuronclimb)
#### Post date: [January 15, 2024, 4:14pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/6 "2024-01-15T16:14:49Z")

</div>

hey how did you fix this? I have several tools it can make within a run, and its using Chainlit async. It’s always getting multiple and different call IDs when submitting tool outputs…

---

<div class="post-metadata">

### Author: ![pondin6666](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/pondin6666/32/146611_2.png) [@pondin6666](https://community.openai.com/u/pondin6666)
#### Post date: [January 16, 2024, 3:28am UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/7 "2024-01-16T03:28:21Z")

</div>

One tool function may be called several times, check the tool\_calls to see if the behavior is reasonable.

I encountered this error message before, but in my case ai behavior is just fine, because user ask ai to provide 3 suggestions, and it call my function 3 times at once with three different parameter in tool\_calls. For such case, I need call my function three times and submit three results so ai can provide three suggestion results at once.

---

<div class="post-metadata">

### Author: ![bartek5186](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/bartek5186/32/292347_2.png) [@bartek5186](https://community.openai.com/u/bartek5186)
#### Post date: [January 22, 2024, 6:29pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/8 "2024-01-22T18:29:38Z")

</div>

yes but, some functions can take longer for example model can exec two functions in tool\_calls (first: 15 mins, second: 1 second). In this case You need wait 15 mins for all, while you should know about finish one just after second.

---

<div class="post-metadata">

### Author: ![CinematicDev](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@CinematicDev](https://community.openai.com/u/CinematicDev)
#### Post date: [January 22, 2024, 6:33pm UTC](https://community.openai.com/t/assistants-api-expects-multiple-tool-calls-even-though-only-one-function-provided/509641/9 "2024-01-22T18:33:43Z")

</div>

Yeah, I experienced this too myself recently. We fixed this by just using an array and returning the response with the appropriate tool\_id
