Skip to content

Commit 11b1c1e

Browse files
authored
Add tests for Agent default model settings when using GPT-5 (#1562)
1 parent 0ab3765 commit 11b1c1e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tests/models/test_default_models.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
from unittest.mock import patch
33

4+
from agents import Agent
5+
from agents.model_settings import ModelSettings
46
from agents.models import (
57
get_default_model,
68
get_default_model_settings,
@@ -21,23 +23,23 @@ def test_default_model_env_gpt_5():
2123
assert get_default_model() == "gpt-5"
2224
assert is_gpt_5_default() is True
2325
assert gpt_5_reasoning_settings_required(get_default_model()) is True
24-
assert get_default_model_settings().reasoning.effort == "low" # type: ignore [union-attr]
26+
assert get_default_model_settings().reasoning.effort == "low" # type: ignore[union-attr]
2527

2628

2729
@patch.dict(os.environ, {"OPENAI_DEFAULT_MODEL": "gpt-5-mini"})
2830
def test_default_model_env_gpt_5_mini():
2931
assert get_default_model() == "gpt-5-mini"
3032
assert is_gpt_5_default() is True
3133
assert gpt_5_reasoning_settings_required(get_default_model()) is True
32-
assert get_default_model_settings().reasoning.effort == "low" # type: ignore [union-attr]
34+
assert get_default_model_settings().reasoning.effort == "low" # type: ignore[union-attr]
3335

3436

3537
@patch.dict(os.environ, {"OPENAI_DEFAULT_MODEL": "gpt-5-nano"})
3638
def test_default_model_env_gpt_5_nano():
3739
assert get_default_model() == "gpt-5-nano"
3840
assert is_gpt_5_default() is True
3941
assert gpt_5_reasoning_settings_required(get_default_model()) is True
40-
assert get_default_model_settings().reasoning.effort == "low" # type: ignore [union-attr]
42+
assert get_default_model_settings().reasoning.effort == "low" # type: ignore[union-attr]
4143

4244

4345
@patch.dict(os.environ, {"OPENAI_DEFAULT_MODEL": "gpt-5-chat-latest"})
@@ -54,3 +56,20 @@ def test_default_model_env_gpt_4o():
5456
assert is_gpt_5_default() is False
5557
assert gpt_5_reasoning_settings_required(get_default_model()) is False
5658
assert get_default_model_settings().reasoning is None
59+
60+
61+
@patch.dict(os.environ, {"OPENAI_DEFAULT_MODEL": "gpt-5"})
62+
def test_agent_uses_gpt_5_default_model_settings():
63+
"""Agent should inherit GPT-5 default model settings."""
64+
agent = Agent(name="test")
65+
assert agent.model is None
66+
assert agent.model_settings.reasoning.effort == "low" # type: ignore[union-attr]
67+
assert agent.model_settings.verbosity == "low"
68+
69+
70+
@patch.dict(os.environ, {"OPENAI_DEFAULT_MODEL": "gpt-5"})
71+
def test_agent_resets_model_settings_for_non_gpt_5_models():
72+
"""Agent should reset default GPT-5 settings when using a non-GPT-5 model."""
73+
agent = Agent(name="test", model="gpt-4o")
74+
assert agent.model == "gpt-4o"
75+
assert agent.model_settings == ModelSettings()

0 commit comments

Comments
 (0)