Function call with finish_reason of stop

We are receiving some responses from the api with finish_reason of “stop” when the model is calling a function.
Has anyone else experienced this?

1 Like

Nope, over and over a finish reason:

  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "function_call": {
          "name": "submit_iso_datetime",
          "arguments": "{\n  \"iso8601_datetime\": \"2023-02-06T16:33:00Z\"\n}"
        }
      },
      "finish_reason": "function_call"
    }

I made plenty of trials also trying to stop any of three models from producing the certainty of multi-line JSON by function descriptions, without success (except once at temperature 2.0, which can also produce copious server 500 errors from malformed function outputs), all without a “stop” being produced in any case.

You can use top_p = 0.4 to reduce the chance of the wrong “finish” output special token being produced.

Hi,

Can you post a copy of the prompt that produced this finish reason?

I can corroborate this.

Just happened to me several times with gpt 3.5 and gpt-4o.

One piece of important information, it seems to happen when you say a tool choice is required, ie:

"tool_choice" : "required"

That’s really not good though.

In that circumstance it should still have a ‘tool_calls’ finish_reason.

If however, I force a specific function the issue is not present.

This looks like a bug! :beetle:

It is certainly not desirable and definitely inconsistent and needs to be handled with messy code!

I going to have to put a horrible workaround in code for the time being :cry:

ie something like this:

(saving you from messy destructuring code!)

if (['stop','length'].include?(finish_reason) && tools_calls.nil? 

and something like:

elsif finish_reason == 'tool_calls' || !tools_calls.nil? 

instead of just checking the finish reason only - yuk!

@brianz-oai another couple of reports of New API feature: forcing function calling via `tool_choice: "required"` - #13 by brianz-oai

FYI I definitely would be happy to update my code to get rid of this cludge!