Skip to content

[Bug]: Multi-Turn Conversations with Reasoning fail for Groq GPT OSS Models #772

@green-david

Description

@green-david

Provider (if applicable)

groq

Model (if applicable)

openai/gpt-oss-120b

Bug Description

When executing a multi-turn conversation with a GPT OSS model via Groq with reasoning enabled, follow-up messages are rejected with an error indicating that reasoning_content is unsupported.

This appears to be due to reasoning fields like reasoning_content and reasoning_details being added in defaults.ex here:

  defp encode_openai_message(%ReqLLM.Message{
         role: r,
         content: c,
         tool_calls: tc,
         tool_call_id: tcid,
         name: name,
         reasoning_details: rd,
         metadata: metadata
       }) do
    {reasoning_content, content_without_thinking} = extract_reasoning_content(c)

    base_message = %{
      role: to_string(r),
      content: encode_openai_content(content_without_thinking)
    }

    base_message
    |> maybe_add_field(:tool_calls, tc)
    |> maybe_add_field(:tool_call_id, tcid)
    |> maybe_add_field(:name, name)
    |> maybe_add_assistant_reasoning(r, reasoning_content)
    |> maybe_add_field(:reasoning_details, rd)
    |> maybe_add_field(:metadata, metadata)
  end

Reproduction Code

{:ok, response} = ReqLLM.generate_text("groq:openai/gpt-oss-120b", ["How would you build a pyramid?"], api_key: api_key, reasoning_effort: :high)

# This returns {:error,%ReqLLM.Error.API.Request{reason: "Provider response error (400): Groq API error: 'messages.1' : for 'role:assistant' the following must be satisfied[('messages.1' : property 'reasoning_content' is unsupported)]", ...}} instead
{:ok, response} = ReqLLM.generate_text("groq:openai/gpt-oss-120b", ReqLLM.Context.append(response.context, ReqLLM.Context.user("What is your favorite pyramid?")), api_key: api_key, reasoning_effort: :high)

Expected Behavior

Multi-turn conversations with reasoning with GPT OSS Models on Groq are executed successfully

Actual Behavior

An API error is returned and multi-turn conversations with GPT OSS models on Groq fail to continue

Environment

  • ReqLLM: 1.16.0
  • Elixir: 1.19.5
  • OTP: 27

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions