Error when submi tool calls

Error 400 Expected tool outputs for call_ids [‘call_mmz2KqlFCa3OOLTjZEdQpRbs’], got else if(status === ‘requires_action’){

            console.log('run-data', run_data)

            const required_action = run_data.required_action
            const required_tools = required_action.submit_tool_outputs.tool_calls

            console.log('required-action', required_action)
            console.log('required-tools', required_tools)

            const tool_output_items = []

            for (const required_tool of required_tools) {
                const functionName = required_tool.function.name;
                const args = JSON.parse(required_tool.function.arguments);
                const argsArray = Object.keys(args).map((key) => args[key]);

                if (functionName === "getJobByType") {
                    //Dynamically make functiom call

                    let output = await getJobsByType.apply(null, [args]);

                    tool_output_items.push({
                        tool_call_id: required_tool.id,
                        output: JSON.stringify(output)
                       
                    })
                    console.log(output);
                } else if (functionName === "getJobByLocation") {
                    let output = await getJobByLocation.apply(null, [args]);
                    tool_output_items.push({
                        tool_call_id: required_tool.id,
                        output: JSON.stringify(output)
                    });
                    console.log(output)
                } else if (functionName === "getJobByLocationAndJobType") {
                    let output = await getJobByLocationAndJobType.apply(null, [argsArray]);
                    tool_output_items.push({
                        tool_call_id: required_tool.id,
                        output: JSON.stringify(output)

                    })
                    console.log(output)
                } else if (functionName === "getAllJobsByType") {
                    let output = await getAllJobsByType.apply(null, [argsArray]);
                    tool_output_items.push({
                        tool_call_id: required_tool.id,
                        output : JSON.stringify(output)
                    })
                    console.log(output)
                }

                return output;
            }

            const ret_tool = await submitOutputs({
                threadId: thread_id,
                runId: run_id,
                tool_outputs: tool_output_items
            })

            console.log('ret-tool', ret_tool)

            continue;

Maybe you want to debug the tool_output_items just before you submitOutputs, and try to figure out what function the id (…call_mmz2KqlFCa3OOLTjZEdQpRbs) is talking about and try to track down why that response isn’t being included (or whatever else could be going on)~

I logged the tool output item but the list is empty, it shows an empty list, which means the data for the tool are not being called

Then with this error, and an empty tool_output_items, you should be able to see from your console.log('required-tools', required_tools) which tool it was that is being called, and from there you can try to find out why you are not doing tool_output_items.push for that tool call~

it not executing the conditional statements, which is totally weird from my point of view

you would not believe where the error is if I told you :grin: