-   Notifications  You must be signed in to change notification settings 
- Fork 2.8k
Description
I was confused to understand the default model.
Description
There is a discrepancy between the documentation comment and the actual implementation regarding the default model used by the Agent class when no model is specified.
In src/agents/agent.py, the comment states:
openai-agents-python/src/agents/agent.py
Lines 107 to 112 in 0396052
| model: str | Model | None = None | |
| """The model implementation to use when invoking the LLM. | |
| By default, if not set, the agent will use the default model configured in | |
| `model_settings.DEFAULT_MODEL`. | |
| """ | 
However, src/agents/model_settings.py does not contain a DEFAULT_MODEL constant.
The actual implementation logic uses DEFAULT_MODEL = "gpt-4o" defined in src/agents/models/openai_provider.py, which is used in the get_model method when model_name is None.
openai-agents-python/src/agents/run.py
Lines 933 to 942 in 0396052
| @classmethod | |
| def _get_model(cls, agent: Agent[Any], run_config: RunConfig) -> Model: | |
| if isinstance(run_config.model, Model): | |
| return run_config.model | |
| elif isinstance(run_config.model, str): | |
| return run_config.model_provider.get_model(run_config.model) | |
| elif isinstance(agent.model, Model): | |
| return agent.model | |
| return run_config.model_provider.get_model(agent.model) | 
openai-agents-python/src/agents/models/openai_provider.py
Lines 81 to 83 in 0396052
| def get_model(self, model_name: str | None) -> Model: | |
| if model_name is None: | |
| model_name = DEFAULT_MODEL | 
| DEFAULT_MODEL: str = "gpt-4o" | 
Suggested Fix
Update the comment in agent.py.
model: str | Model | None = None """The model implementation to use when invoking the LLM.  By default, if not set, the agent will use the default model configured in `openai_provider.DEFAULT_MODEL` (currently "gpt-4o"). """