Force a model to continue function calls after finish_reason tool_calls

We’re using openrouter’s endpoint to make AIs execute comanda in an interactive console. They provide an endpoint similar to OpenAi’s one and I encounter some issues with some of their models.

I was wondering if this was an issue in OpenAi’s models in the past and someone has an workaround.

What happens is that when we are using tool_choice=auto, the model runs one command in the terminal then it returns with finish_reason=tool_calls, which no name and no arguments.

Is there a way to force a model to continue with other function calls when this happens? It also return responses with no tool_calls before that and adding tool_calls when the finish reason is given will stop throw an error because the older responses didn’t had tool_calls in it.