GPT-OSS-120b Tool calling issue ( Empty content and tool_calls in response )

I have gpt-oss-120b hosted on azure and use AzureChatOpenAI for model invokes.
The model has 2 tools ( with simple 2 keys arguments ) bind to it and for some reason it fails to provide any content and tool_calls in its response. The same prompt works for other models like gpt-54 etc, although these are more powerful models.
Why ?

Also is there a way to get reasoning_content from the response which is an AIMessage object? As I am not able to find this attribute.

Hey @nileshapsingkar welcome to langchain community.

gpt-oss is a reasoning model, so reasoning tokens eat into your output budget. First check finish_reason:

resp = llm.bind_tools(tools).invoke(messages)
print(resp.response_metadata.get("finish_reason"))  # "length" = budget used up by reasoning
print(resp.usage_metadata)                          # see reasoning tokens
print(repr(resp.content), resp.tool_calls, resp.invalid_tool_calls)

  • If it’s length, raise max_completion_tokens and/or lower reasoning_effort.
  • If it’s stop and the response is still empty, it’s likely a Harmony parsing quirk on the serving side. The model sometimes puts the tool call in the analysis channel, so it never becomes a tool_call. Retrying on empty responses is a practical workaround.

For reasoning_content: AzureChatOpenAI only extracts standard OpenAI fields, so it never reaches the AIMessage, even though Azure returns it in the raw response. A subclass can copy it over:

from langchain_openai import AzureChatOpenAI

class AzureChatOpenAIReasoning(AzureChatOpenAI):
    def _create_chat_result(self, response, generation_info=None):
        result = super()._create_chat_result(response, generation_info)
        data = response if isinstance(response, dict) else response.model_dump()
        for gen, choice in zip(result.generations, data.get("choices", [])):
            m = choice.get("message") or {}
            if rc := m.get("reasoning_content") or m.get("reasoning"):
                gen.message.additional_kwargs["reasoning_content"] = rc
        return result

# resp.additional_kwargs["reasoning_content"]

This covers non-streaming calls only and overrides a private method, so it may break across langchain-openai versions.

Can you share your finish_reason, max_tokens and usage metadata? That would show which case you’re hitting.

hi thanks for helping!, These metrics are for the case where there is no content and tool calls in the response. and I have set the reasoning_effort to low.
Metrics:
finish_reason =‘stop’
max_tokens = 120k
usage_metadata = {‘input_token_details’: {}, ‘input_tokens’: 12467, ‘output_token_details’: {}, ‘output_tokens’: 428, ‘total_tokens’: 12895}

Thanks, that rules out the token budget: finish_reason is stop and only 428 of 120k tokens were used. The model generated something that never reached content or tool_calls. A likely cause is the serving-side Harmony parsing, where the tool call comes out in the analysis channel instead of commentary and gets dropped. To confirm, dump the raw response:

from langchain_core.utils.function_calling import convert_to_openai_tool  

raw = llm.client.create(  
    model=llm.deployment_name,  
    messages=[{"role": "user", "content": "your failing prompt"}],  # use the same messages as the failing call  
    tools=[convert_to_openai_tool(t) for t in tools],  
    reasoning_effort="low",  
)  
msg = raw.choices[0].message  
print(raw.choices[0].finish_reason, repr(msg.content), msg.tool_calls)  
print(msg.model_extra)  # look for reasoning_content / reasoning  

If reasoning_content contains a to=functions.<name> call, that confirms it. As a workaround, retry when there’s neither content nor tool calls:

def invoke_with_retry(llm_with_tools, messages, retries=2):  
    for _ in range(retries + 1):  
        resp = llm_with_tools.invoke(messages)  
        if resp.content or resp.tool_calls:  
            return resp  
    return resp  

If it keeps happening, you can parse the call out of the reasoning text in a custom wrapper, as in this thread.

I haven’t run the code against an Azure deployment.

With a stop finish reason and only 428 of 120k output tokens used, the budget path seems unlikely. Comparing the raw Azure message with the resulting AIMessage for the same call should isolate where the fields disappear: if raw has tool_calls but AIMessage does not, focus on the adapter/version; if both are empty, investigate the deployment’s serving behavior. For reasoning_content, inspect the provider’s raw message extras rather than expecting it in content.

Hi @nileshapsingkar, confirming a couple of things from the langchain-openai source:

  1. AzureChatOpenAI / ChatOpenAI only target the official OpenAI API spec, so non-standard fields like reasoning_content are intentionally not copied onto the AIMessage. The subclass approach above works as a workaround for non-streaming calls.
  2. LangChain doesn’t drop tool calls silently. If Azure returned a tool call that couldn’t be parsed, it would show up in resp.invalid_tool_calls. Could you check that field on a failing response?

With finish_reason="stop" and only 428 output tokens, this isn’t a token budget issue. The raw response dump from the post above is the fastest way to pin it down:

  • If the raw message has no content and no tool_calls, the response is coming back empty from the Azure deployment itself, and retrying on empty responses is the practical workaround.
  • If the raw message does have tool_calls but the AIMessage doesn’t, please share your langchain-openai version and the raw output here and we’ll take a look.