async-openai icon indicating copy to clipboard operation
async-openai copied to clipboard

Responses API streaming response.function_call_arguments.done event missing function name

Open shaileshahuja opened this issue 2 weeks ago • 4 comments

Current version: async-openai = "0.31.0-alpha.6"

I am trying out function calling with the responses API and the library throws this error:

Caused by:
    failed to deserialize api response: error:missing field `name` content:{"type":"response.function_call_arguments.done","sequence_number":540,"item_id":"fc_0406f266c8104f0a0069149fe6cdd0819b8d61947a29216e55","output_index":1,"arguments":"{\"language\":\"English\"}"}

This looks very similar to the issue in the Python library. According to fix PR, The raw event from the API doesn't include the name field - it must be taken from the accumulated snapshot. That's a bit odd as this conflicts with OpenAI event spec.

I guess we should make name optional until OpenAI fixes this on their end?

shaileshahuja avatar Nov 12 '25 15:11 shaileshahuja

Thats a bummer, lets wait for openai to fix the bug? if it lasts longer we can make it optional?

(or alternative in such cases in byot feature)

64bit avatar Nov 13 '25 02:11 64bit

Its a shame that I can't use the types because of this issue.

shaileshahuja avatar Nov 13 '25 03:11 shaileshahuja

Using create_stream_byot with the following event worked for me

"response.output_item.done" => {
    let item_json = event_json["item"].clone();
    if let Some("function_call") = item_json["type"].as_str() {
        if let (Some(name), Some(call_id), Some(arguments)) = (
            item_json["name"].as_str(),
            item_json["call_id"].as_str(),
            item_json["arguments"].as_str(),
        ) {
           // do something
        }
    }
}

shaileshahuja avatar Nov 13 '25 04:11 shaileshahuja

Its not ideal - but to make the types useful - making Optional for now makes sense. PR is welcome!

64bit avatar Nov 14 '25 01:11 64bit