An agent is an AI model configured with instructions, tools, guardrails, handoffs and more. We strongly recommend passing `instructions`, which is the "system prompt" for the agent. In addition, you can pass `handoff_description`, which is a human-readable description of the agent, used
| 268 | |
| 269 | @dataclass |
| 270 | class Agent(AgentBase, Generic[TContext]): |
| 271 | """An agent is an AI model configured with instructions, tools, guardrails, handoffs and more. |
| 272 | |
| 273 | We strongly recommend passing `instructions`, which is the "system prompt" for the agent. In |
| 274 | addition, you can pass `handoff_description`, which is a human-readable description of the |
| 275 | agent, used when the agent is used inside tools/handoffs. |
| 276 | |
| 277 | Agents are generic on the context type. The context is a (mutable) object you create. It is |
| 278 | passed to tool functions, handoffs, guardrails, etc. |
| 279 | |
| 280 | See `AgentBase` for base parameters that are shared with `RealtimeAgent`s. |
| 281 | """ |
| 282 | |
| 283 | instructions: ( |
| 284 | str |
| 285 | | Callable[ |
| 286 | [RunContextWrapper[TContext], Agent[TContext]], |
| 287 | MaybeAwaitable[str], |
| 288 | ] |
| 289 | | None |
| 290 | ) = None |
| 291 | """The instructions for the agent. Will be used as the "system prompt" when this agent is |
| 292 | invoked. Describes what the agent should do, and how it responds. |
| 293 | |
| 294 | Can either be a string, or a function that dynamically generates instructions for the agent. If |
| 295 | you provide a function, it will be called with the context and the agent instance. It must |
| 296 | return a string. |
| 297 | """ |
| 298 | |
| 299 | prompt: Prompt | DynamicPromptFunction | None = None |
| 300 | """A prompt object (or a function that returns a Prompt). Prompts allow you to dynamically |
| 301 | configure the instructions, tools and other config for an agent outside of your code. Only |
| 302 | usable with OpenAI models, using the Responses API. |
| 303 | """ |
| 304 | |
| 305 | handoffs: list[Agent[Any] | Handoff[TContext, Any]] = field(default_factory=list) |
| 306 | """Handoffs are sub-agents that the agent can delegate to. You can provide a list of handoffs, |
| 307 | and the agent can choose to delegate to them if relevant. Allows for separation of concerns and |
| 308 | modularity. |
| 309 | """ |
| 310 | |
| 311 | model: str | Model | None = None |
| 312 | """The model implementation to use when invoking the LLM. |
| 313 | |
| 314 | By default, if not set, the agent will use the default model configured in |
| 315 | `agents.models.get_default_model()` (currently "gpt-5.4-mini"). |
| 316 | """ |
| 317 | |
| 318 | model_settings: ModelSettings = field(default_factory=get_default_model_settings) |
| 319 | """Configures model-specific tuning parameters (e.g. temperature, top_p). |
| 320 | """ |
| 321 | |
| 322 | input_guardrails: list[InputGuardrail[TContext]] = field(default_factory=list) |
| 323 | """A list of checks that run in parallel to the agent's execution, before generating a |
| 324 | response. Runs only if the agent is the first agent in the chain. |
| 325 | """ |
| 326 | |
| 327 | output_guardrails: list[OutputGuardrail[TContext]] = field(default_factory=list) |
no outgoing calls