Skip to content

[Bug]: OpenAIResponse constructor silently overwrites user-provided temperature for O1 models #22751

Description

@Nazmus-Saif

Bug Description

Summary

OpenAIResponses.__init__() unconditionally forces 'temperature=1.0for any model inO1_MODELS`, siltently discarding whatever value the caller passed in. There isno warning, no log, no raised exception, the value is just lost.

Affected versions

  • llama-index-llms-openai (responses.py)

Relevant code

llama-index/llms/openai/response.py, inside __init__():

# TODO: Temp forced to 1.0 for o1
if model in O1_MODELS:
        temperature = 1.0

This runs before super().__init__(), so the caller's value is overwritten with no indication.

Why this is wrong

The caller has explicitly expressed in tent by passing a temperature value. Silently overriding it violates the priciple of least surprisee. The correct behavior is one of:

  1. Raise a ValueError with a clear message explaining the constraint
  2. Emit a logging.warning() so the caller at least knows what happened
  3. Only force temperature=1.0 when the caller did not explicitly set it

Reproduction

from llama_index.llms.openai import OpenAIResponses

llm = OpenAIResponses(model="o1-mini", temperature=0.5, api_key="sk-...")
print(llm.temperature)  # prints 1.0 - caller's 0.5 was silently discarded

Additional context

The #TODO comment in the source is the only ack of this bahavior - it is not documented anywhere in the official docs or the class docstring.

A minimal no-breaking fix you may consider:

if model in O1_MODELS and temperature == DEFAULT_TEMPERATURE:
    temperature = 1.0  # only force if caller didn't explicitly set it

Or the stricter correct fix: raise/warn instead of silently overwriting.

Version

0.14.23

Steps to Reproduce

  1. Install the package:
    pip install llama-index-llms-openai

  2. Instantiate OpenAIResponses with an O1 model and a custom temperature:

    from llama_index.llms.openai import OpenAIResponses

    llm = OpenAIResponses(
    model="o1-mini",
    temperature=0.5,
    api_key="sk-..."
    )

    print(llm.temperature)

    Expected: 0.5

    Actual: 1.0 - caller's value was silently discarded

  3. Check responses.py init() to confirm the override:

    TODO: Temp forced to 1.0 for o1

    if model in O1_MODELS:
    temperature = 1.0

Relevant Logs/Tracebacks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs to be triaged/prioritized

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions