Share via

Azure OpenAI Intermittent 400 Error: Item with id not found

JustinD 20 Reputation points
2025-09-18T16:57:00.2933333+00:00

I am periodically getting a 400 invalid_request_error when using a simple agentic tool flow with the responses api using a gpt-4o Global Standard 2024-11-20 model deployment. This happens somewhat rarely, but enough that is is becoming an issue. Specifically, I am getting something that looks like this:

{
  "error": {
	"message": "Item with id 'fc_68cc1e9f1d588190a2e6d1a435025685092272e73adc6b55' not found.",
	"type": "invalid_request_error",
	"param": "input",
	"code": null
  }
}

I send two requests: 1 initial request where the LLM decides to use a tool, and 2 that returns the function_call_output from that tool. I understand the error is telling me the tool call in the payload has an id that is not found. However, this was the id provided by the endpoint in the function_call response object.

Here is the payload that was sent to produce the error. I have omitted the model name and schema link

{
  "model": "...",
  "instructions": "You are a friendly agent that always calls a tool. Output the result of the tool.",
  "input": [
{
  "role": "user",
  "content": "Wonder what the tool call returns"
},
{
  "id": "fc_68cc1e9f1d588190a2e6d1a435025685092272e73adc6b55",
  "type": "function_call",
  "status": "completed",
  "arguments": "{\"input\":\"Hello there!\"}",
  "call_id": "call_tZAqFpxMlsWYMnQ5FSflQmxf",
  "name": "myToolCall"
},
{
  "type": "function_call_output",
  "call_id": "call_tZAqFpxMlsWYMnQ5FSflQmxf",
  "status": "completed",
  "output": "This is some output from our sample tool."
}
  ],
  "include": [],
  "tools": [
{
  "type": "function",
  "name": "myToolCall",
  "description": "Tool to Call",
  "parameters": {
    "type": "object",
    "properties": {
      "input": {
        "type": "string",
        "description": "An input into the tool"
      }
    },
    "required": [
      "input"
    ],
    "additionalProperties": false,
    "$schema": "..."
  },
  "strict": true
}
  ],
  "stream": false
}

To add more confusion, when I re-send this payload, it works and does not give me a 400. This leads me to believe there is some race condition where I am sending the second request with the tool result before the id from the first request is cached or saved on the backend. However, I would expect to not receive a response from the first request until the id is properly created. Putting a sleep between requests seems to solve the issue which furthers my suspicion.

The error does not happen consistently and the only way I can reproduce is by running many of the same agentic flows until I see the error, but I do see it intermittently when running just one flow at a time. Different times of day also seem to affect how often I see the error. Sometimes I am unable to reproduce entirely. I have also seen this error using the typescript Azure OpenAI SDK.

Here is a Python script that I have been using to reproduce the issue:

import requests
import json
import concurrent.futures
import time

API_KEY = "..."
MODEL = "..."
RESOURCE_NAME = "..."

def send(i):
  print(f"Starting {i}")
  querystring = {}

  function_result = {
    "type": "function_call_output",
    "status": "completed",
    "output": "This is some output from our sample tool."
  }

  url = f"https://{RESOURCE_NAME}.openai.azure.com/openai/v1/responses"

  payload = {
    "model": MODEL,
    "instructions": """You are a friendly agent that always calls a tool. Output the result of the tool.""",
    "input": [
      {
        "role": "user",
        "content": "Wonder what the tool call returns"
      }
    ],
    "include": [],
    "tools": [
      {
        "type": "function",
        "name": "myToolCall",
        "description": "Tool to Call",
        "parameters": {
          "type": "object",
          "properties": {
            "input": {
              "type": "string",
              "description": "An input into the tool"
            }
          },
          "required": [
            "input"
          ],
          "additionalProperties": False,
          "$schema": "http://json-schema.org/draft-07/schema#"
        },
        "strict": True
      }
    ],
    "stream": False
  }
  headers = {
    'user-agent': "Agents/JavaScript 0.1.1",
    'content-type': "application/json",
    'accept': "application/json",
    'api-key': API_KEY
  }

  response = requests.request("POST", url, data=json.dumps(payload), headers=headers, params=querystring)
  if not response.ok:
    print(json.dumps(payload, indent=2))
    print(response.text)
    raise AssertionError(response.text)
  response_json = response.json()

  output = response_json['output'][0]
  function_result["call_id"] = output["call_id"]
  payload["input"] = payload["input"] + [output, function_result]

  # time.sleep(5)
  response = requests.request("POST", url, data=json.dumps(payload), headers=headers, params=querystring)
  if not response.ok:
    print(json.dumps(payload, indent=2))
    print(response.text)
    raise AssertionError(response.text)
  response_json = response.json()

def main():
  with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
    future_to_i = {executor.submit(send, i): i for i in range(50)}
    futures = concurrent.futures.wait(future_to_i, return_when=concurrent.futures.FIRST_EXCEPTION)
    executor.shutdown(cancel_futures=True)

if __name__ == '__main__':
  try:
    main()
  except Exception as e:
    print('Error:', e)

How can I resolve this issue?

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

Answer accepted by question author

  1. Sina Salam 28,606 Reputation points Volunteer Moderator
    2025-09-19T18:03:21.67+00:00

    Hello JustinD,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that your Azure OpenAI Intermittent 400 Error: Item with id not found.

    My best recommendation for you is to use stateful chaining with previous_response_id so that you minimize payload, have immune to ordering errors, and aligns with chaining responses together as in Azure docs. These are steps to do that:

    1. Call 1: Capture response.id and find the function_call item (by type) and its call_id, to send user input + tools.
    2. Execute your tool locally.
    3. Call 2: Send only a function_call_output item with the same call_id and previous_response_id set to the first call’s response.id. Do not resend prior items.
    4. If the model returns more tool calls repeat step 3 for each call_id until you receive the final message.

    Check the below for your repro:

    import requests, json
    API_KEY = "..."
    MODEL = "..."
    RESOURCE_NAME = "..."
    URL = f"https://{RESOURCE_NAME}.openai.azure.com/openai/v1/responses"
    HEADERS = {
      "content-type": "application/json",
      "accept": "application/json",
      "api-key": API_KEY,
    }
    def stateful_round_trip():
      # 1) First call – let the model decide to call a tool
      payload1 = {
        "model": MODEL,
        "instructions": "You are a friendly agent that always calls a tool. Output the result of the tool.",
        "input": [{ "role": "user", "content": "Wonder what the tool call returns" }],
        "tools": [{
          "type": "function",
          "name": "myToolCall",
          "description": "Tool to Call",
          "parameters": {
            "type": "object",
            "properties": { "input": { "type": "string", "description": "An input into the tool" } },
            "required": ["input"],
            "additionalProperties": False,
            "$schema": "http://json-schema.org/draft-07/schema#"
          },
          "strict": True
        }],
        "stream": False
      }
      r1 = requests.post(URL, headers=HEADERS, data=json.dumps(payload1))
      r1.raise_for_status()
      resp1 = r1.json()
      # Extract the function_call item robustly (don’t assume output[0])
      fc_item = next(i for i in resp1["output"] if i.get("type") == "function_call")
      call_id = fc_item["call_id"]
      # 2) Execute your tool
      tool_output = "This is some output from our sample tool."
      # 3) Second call – send only function_call_output + previous_response_id
      payload2 = {
        "model": MODEL,
        "previous_response_id": resp1["id"],
        "input": [{
          "type": "function_call_output",
          "call_id": call_id,
          "status": "completed",
          "output": tool_output
        }],
        "stream": False
      }
      r2 = requests.post(URL, headers=HEADERS, data=json.dumps(payload2))
      r2.raise_for_status()
      return r2.json()
    

    Alternatively, manual replay of response.output can work when you can’t rely on server‑side state (e.g., certain retention policies), when you must send all prior output items, unmodified, in order, then immediately follow the function_call with your function_call_output. - Check the link above and this https://community.openai.com/t/issue-with-new-responses-api-400-no-tool-call-found-for-function-call-output-with-call-id/1142327 for more details.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.