Run Config
ModelInputData
dataclass
CallModelData
dataclass
Bases: Generic[TContext]
Data passed to RunConfig.call_model_input_filter prior to model call.
Source code in src/agents/run_config.py
ToolErrorFormatterArgs
dataclass
Bases: Generic[TContext]
Data passed to RunConfig.tool_error_formatter callbacks.
Source code in src/agents/run_config.py
kind
instance-attribute
The category of tool error being formatted.
tool_type
instance-attribute
The tool runtime that produced the error.
default_message
instance-attribute
The SDK default message for this error kind.
run_context
instance-attribute
run_context: RunContextWrapper[TContext]
The active run context for the current execution.
ToolExecutionConfig
dataclass
Grouped SDK-side execution settings for local tool calls.
Source code in src/agents/run_config.py
max_function_tool_concurrency
class-attribute
instance-attribute
Maximum number of local function tool calls to execute concurrently.
Set to None to preserve the default behavior, which starts all function tool calls
emitted in a turn. This does not change provider-side parallel_tool_calls behavior.
SandboxConcurrencyLimits
dataclass
Concurrency limits for sandbox materialization work.
Source code in src/agents/run_config.py
manifest_entries
class-attribute
instance-attribute
Maximum number of manifest entries to materialize concurrently per sandbox session.
Set to None to disable this manifest entry limit.
SandboxArchiveLimits
dataclass
Resource limits for sandbox archive extraction.
Source code in src/agents/run_config.py
max_input_bytes
class-attribute
instance-attribute
Maximum archive input bytes accepted by BaseSandboxSession.extract().
Set to None to disable this input-size limit.
max_extracted_bytes
class-attribute
instance-attribute
Maximum declared bytes that an archive may extract.
Set to None to disable this extracted-size limit.
SandboxRunConfig
dataclass
Grouped sandbox runtime configuration for Runner.
Source code in src/agents/run_config.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
client
class-attribute
instance-attribute
client: BaseSandboxClient[Any] | None = None
Sandbox client used to create or resume sandbox sessions.
options
class-attribute
instance-attribute
Sandbox-client-specific options used when creating a fresh session.
session
class-attribute
instance-attribute
session: BaseSandboxSession | None = None
Live sandbox session override for the current process.
session_state
class-attribute
instance-attribute
session_state: SandboxSessionState | None = None
Explicit sandbox session state to resume from when not using RunState payloads.
manifest
class-attribute
instance-attribute
manifest: Manifest | None = None
Optional sandbox manifest override for fresh session creation.
snapshot
class-attribute
instance-attribute
snapshot: SnapshotSpec | SnapshotBase | None = None
Optional sandbox snapshot used for fresh session creation.
concurrency_limits
class-attribute
instance-attribute
concurrency_limits: SandboxConcurrencyLimits = field(
default_factory=SandboxConcurrencyLimits
)
Concurrency limits for sandbox materialization work.
archive_limits
class-attribute
instance-attribute
archive_limits: SandboxArchiveLimits | None = None
Resource limits for sandbox archive extraction.
Set to None to preserve the default behavior with no SDK archive resource limits.
Use SandboxArchiveLimits() to enable SDK defaults.
RunConfig
dataclass
Configures settings for the entire agent run.
Source code in src/agents/run_config.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
model
class-attribute
instance-attribute
model: str | Model | None = None
The model to use for the entire agent run. If set, will override the model set on every agent. The model_provider passed in below must be able to resolve this model name.
model_provider
class-attribute
instance-attribute
model_provider: ModelProvider = field(
default_factory=MultiProvider
)
The model provider to use when looking up string model names. Defaults to OpenAI.
model_settings
class-attribute
instance-attribute
model_settings: ModelSettings | None = None
Configure global model settings. Any non-null values will override the agent-specific model
settings. Accepts a ModelSettings instance or a dictionary containing its fields.
handoff_input_filter
class-attribute
instance-attribute
handoff_input_filter: HandoffInputFilter | None = None
A global input filter to apply to all handoffs. If Handoff.input_filter is set, then that
will take precedence. The input filter allows you to edit the inputs that are sent to the new
agent. See the documentation in Handoff.input_filter for more details. Server-managed
conversations (conversation_id, previous_response_id, or auto_previous_response_id)
do not support handoff input filters.
nest_handoff_history
class-attribute
instance-attribute
Opt-in beta: compact prior run history into ordered assistant summary segments while
preserving lossless message items in their original positions. This is disabled by default
while we stabilize nested handoffs; set to True to enable the compacted transcript behavior.
Server-managed conversations
(conversation_id, previous_response_id, or auto_previous_response_id) automatically
disable this behavior with a warning.
handoff_history_mapper
class-attribute
instance-attribute
handoff_history_mapper: HandoffHistoryMapper | None = None
Optional function that receives the normalized transcript (history + handoff items) and
returns the input history that should be passed to the next agent. When left as None, the
runner uses ordered summary segments around lossless message items. When supplied, the
function's return value is used as the exact input history. This function only runs when
nest_handoff_history is True.
input_guardrails
class-attribute
instance-attribute
input_guardrails: list[InputGuardrail[Any]] | None = None
A list of input guardrails to run on the initial run input.
output_guardrails
class-attribute
instance-attribute
output_guardrails: list[OutputGuardrail[Any]] | None = None
A list of output guardrails to run on the final output of the run.
tracing_disabled
class-attribute
instance-attribute
Whether tracing is disabled for the agent run. If disabled, we will not trace the agent run.
tracing
class-attribute
instance-attribute
tracing: TracingConfig | None = None
Tracing configuration for this run.
trace_include_sensitive_data
class-attribute
instance-attribute
Whether we include potentially sensitive data (for example: inputs/outputs of tool calls or LLM generations) in traces. If False, we'll still create spans for these events, but the sensitive data will not be included.
workflow_name
class-attribute
instance-attribute
The name of the run, used for tracing. Should be a logical name for the run, like "Code generation workflow" or "Customer support agent".
trace_id
class-attribute
instance-attribute
A custom trace ID to use for tracing. If not provided, we will generate a new trace ID.
group_id
class-attribute
instance-attribute
A grouping identifier to use for tracing, to link multiple traces from the same conversation or process. For example, you might use a chat thread ID.
trace_metadata
class-attribute
instance-attribute
An optional dictionary of additional metadata to include with the trace.
session_input_callback
class-attribute
instance-attribute
session_input_callback: SessionInputCallback | None = None
Defines how to handle session history when new input is provided.
- None (default): The new input is appended to the session history.
- SessionInputCallback: A custom function that receives the history and new input, and
returns the desired combined list of items.
call_model_input_filter
class-attribute
instance-attribute
Optional callback that is invoked immediately before calling the model. It receives the current
agent, context and the model input (instructions and input items), and must return a possibly
modified ModelInputData to use for the model call.
This allows you to edit the input sent to the model e.g. to stay within a token limit. For example, you can use this to add a system prompt to the input.
tool_error_formatter
class-attribute
instance-attribute
Optional callback that formats tool error messages returned to the model.
Returning None falls back to the SDK default message.
session_settings
class-attribute
instance-attribute
session_settings: SessionSettings | None = None
Configure session settings. Any non-null values will override the session's default settings. Used to control session behavior like the number of items to retrieve.
reasoning_item_id_policy
class-attribute
instance-attribute
Controls how reasoning items are converted to next-turn model input.
None/"preserve"keeps reasoning item IDs as-is."omit"strips reasoning item IDs from model input built by the runner.
sandbox
class-attribute
instance-attribute
sandbox: SandboxRunConfig | None = None
Optional sandbox runtime configuration for SandboxAgent execution.
tool_execution
class-attribute
instance-attribute
tool_execution: ToolExecutionConfig | None = None
Optional SDK-side execution settings for local tool calls.
tool_not_found_behavior
class-attribute
instance-attribute
Controls unresolved function tool calls emitted by the model.
"raise_error"preserves the default behavior and raisesModelBehaviorError."return_error_to_model"returns a model-visiblefunction_call_outputerror and lets the run continue.
RunOptions
Bases: TypedDict, Generic[TContext]
Arguments for AgentRunner methods.
Source code in src/agents/run_config.py
max_turns
instance-attribute
The maximum number of turns to run for. Set to None to disable the limit.
run_config
instance-attribute
run_config: NotRequired[RunConfig | dict[str, Any] | None]
Run configuration.
previous_response_id
instance-attribute
The ID of the previous response, if any.
auto_previous_response_id
instance-attribute
Enable automatic response chaining for the first turn.
conversation_id
instance-attribute
The ID of the stored conversation, if any.
error_handlers
instance-attribute
error_handlers: NotRequired[
RunErrorHandlers[TContext] | None
]
Error handlers keyed by error kind.