Run.id ending up as undefined when reaching the internal openAI request

I am following the assistant example for how to handle functions.

before making this call I have ensured that threadId, runId and tool_call_id are all correct (by calling the respective endpoints and getting the data of the current run).

					run = openai.beta.threads.runs.submitToolOutputs(
						threadId,
						runId,
						{
							tool_outputs: [
								{
									"tool_call_id": tool_call_id,
									"output": result
								}
							]
						}
					)

When calling the below function all these variables are correct. However there is an internal exception happening:

node_modules/openai/error.mjs:48
            return new NotFoundError(status, error, message, headers);
                   ^

NotFoundError: 404 No run found with id 'undefined'.
    at APIError.generate (node_modules/openai/error.mjs:48:20)
    at OpenAI.makeStatusError (node_modules/openai/core.mjs:244:25)
    at OpenAI.makeRequest (node_modules/openai/core.mjs:283:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I may be wrong but I’m pretty sure the library is asynchronous and you need to prefix your calls with await .

Also

runId, threadId

should be completely unnecessary. More of an opinion but this can just cause confusion. Should just retrieve the IDs from the objects that are created in your calls and not add an unnecessary operation to separate it

1 Like