Skip to content

Documentation and implementation mismatch for default model in Agent class #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ftnext opened this issue Apr 5, 2025 · 1 comment · Fixed by #457
Closed

Documentation and implementation mismatch for default model in Agent class #440

ftnext opened this issue Apr 5, 2025 · 1 comment · Fixed by #457

Comments

@ftnext
Copy link
Contributor

ftnext commented Apr 5, 2025

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:

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.

@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)

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").
"""
@rm-openai
Copy link
Collaborator

Makes sense, PR welcome!

ftnext added a commit to ftnext/openai-agents-python that referenced this issue Apr 7, 2025
Lightblues pushed a commit to Lightblues/openai-agents-python that referenced this issue Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants