diff --git a/llm/models.py b/llm/models.py index 4e00987bc..07bce27fa 100644 --- a/llm/models.py +++ b/llm/models.py @@ -519,7 +519,7 @@ def __init__( self.schema = schema self.tools = _wrap_tools(tools or []) self.tool_results = tool_results or [] - self.options = options or {} + self.options = options or model.Options() self.hide_reasoning = hide_reasoning # Explicit messages= list, if the caller supplied one. Copied so # later mutation by the caller doesn't alter the Prompt. diff --git a/tests/test_options_parameter.py b/tests/test_options_parameter.py index deb00f544..8a0a89529 100644 --- a/tests/test_options_parameter.py +++ b/tests/test_options_parameter.py @@ -6,6 +6,29 @@ import pytest +import llm + + +@pytest.mark.parametrize("kwargs", ({}, {"options": None}, {"options": {}})) +def test_direct_prompt_default_options(mocked_openai_responses, kwargs): + model = llm.get_model("gpt-5.5") + prompt = llm.Prompt("hello", model, **kwargs) + response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") + + assert response.text() == "Bob, Alice, Eve" + assert isinstance(prompt.options, model.Options) + assert prompt.options == model.Options() + + +def test_direct_prompt_preserves_options(mocked_openai_responses): + model = llm.get_model("gpt-5.5") + options = model.Options(temperature=0.5) + prompt = llm.Prompt("hello", model, options=options) + response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") + + assert response.text() == "Bob, Alice, Eve" + assert prompt.options is options + def test_prompt_with_options_dict(mock_model): mock_model.enqueue(["ok"])