Skip to content

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

Closed
@ftnext

Description

@ftnext

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").
"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions