The Model and ModelProvider abstract base classes define how agents fetch responses and manage resources: Model.get_response() is the core async method that accepts system instructions, tools, output schemas, and conversation state, while ModelProvider locates models by name and both define optional hooks for cleanup and retry guidance. ModelTracing controls whether and what response data the SDK records: DISABLED suppresses tracing entirely, ENABLED includes full payloads, and ENABLED_WITHOUT_DATA records structure only—so callers use include_data() to conditionally serialize inputs and outputs.
The Model abstract base class in src/agents/models/interface.py defines the contract every model implementation must fulfill, including how responses are fetched, resources released, and retry guidance surfaced.[1] ModelProvider in src/agents/models/interface.py is an abstract base class responsible for looking up Model instances by name via its abstract get_model(model_name) method.[1]
Model.get_response() is an abstract async method that accepts system_instructions, input (string or list of response input items), model_settings, tools, output_schema, handoffs, tracing, previous_response_id, conversation_id, and prompt, and returns a ModelResponse.[1]
Model implementations in src/agents/models/interface.py must assign a non-empty, unique call ID to every tool invocation; a call ID must not be reused for a changed tool identity or payload, and an exact completed replay may be omitted by the runtime without re-executing the invocation.[1] A missing or reused tool call ID in a Model implementation breaks runtime deduplication: the SDK cannot detect replayed invocations, allowing the same tool to execute multiple times with unintended side effects.
Model.close() in src/agents/models/interface.py is a no-op by default; models that maintain persistent connections should override it to release those resources.[1] ModelProvider.aclose() in src/agents/models/interface.py is a no-op by default; providers that cache persistent models or network connections should override it.[1]
Model.get_retry_advice() in src/agents/models/interface.py returns None by default; model implementations may override it to provide provider-specific hints such as replay safety, retry-after delays, or explicit server retry guidance.[1]
ModelTracing is an enum in src/agents/models/interface.py with three values: DISABLED (tracing off entirely), ENABLED (tracing on, all data included), and ENABLED_WITHOUT_DATA (tracing on, but inputs/outputs excluded).[1] ModelTracing.include_data() returns True only when tracing is ENABLED (not ENABLED_WITHOUT_DATA), so callers use it to gate serialization of prompt and response payloads.[1]
Sources