1
1
import os
2
2
from unittest .mock import patch
3
3
4
+ from agents import Agent
5
+ from agents .model_settings import ModelSettings
4
6
from agents .models import (
5
7
get_default_model ,
6
8
get_default_model_settings ,
@@ -21,23 +23,23 @@ def test_default_model_env_gpt_5():
21
23
assert get_default_model () == "gpt-5"
22
24
assert is_gpt_5_default () is True
23
25
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]
25
27
26
28
27
29
@patch .dict (os .environ , {"OPENAI_DEFAULT_MODEL" : "gpt-5-mini" })
28
30
def test_default_model_env_gpt_5_mini ():
29
31
assert get_default_model () == "gpt-5-mini"
30
32
assert is_gpt_5_default () is True
31
33
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]
33
35
34
36
35
37
@patch .dict (os .environ , {"OPENAI_DEFAULT_MODEL" : "gpt-5-nano" })
36
38
def test_default_model_env_gpt_5_nano ():
37
39
assert get_default_model () == "gpt-5-nano"
38
40
assert is_gpt_5_default () is True
39
41
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]
41
43
42
44
43
45
@patch .dict (os .environ , {"OPENAI_DEFAULT_MODEL" : "gpt-5-chat-latest" })
@@ -54,3 +56,20 @@ def test_default_model_env_gpt_4o():
54
56
assert is_gpt_5_default () is False
55
57
assert gpt_5_reasoning_settings_required (get_default_model ()) is False
56
58
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