OpenAI Agents SDK for Python 0.22

Last reviewed Sep 12, 2026

Export as PDF

Prompt Details

Prompt Composition

3prompts
  1. Python 3155 lines · 3.8K tokens
  2. OpenAI SDK for Python 3.656 lines · 1.4K tokens
  3. OpenAI Agents SDK for Python 0.2257 lines · 1.3K tokens
Total268 lines · 6.4K tokens

CWE Coverage

  • 20
  • 23
  • 36
  • 59
  • 78
  • 89
  • 95
  • 117
  • 201
  • 208
  • 209
  • 214
  • 250
  • 295
  • 306
  • 319
  • 328
  • 338
  • 347
  • 367
  • 379
  • 409
  • 416
  • 426
  • 427
  • 459
  • 470
  • 502
  • 522
  • 532
  • 611
  • 639
  • 674
  • 732
  • 770
  • 772
  • 776
  • 799
  • 807
  • 829
  • 862
  • 916
  • 918
  • 1104
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the OpenAI SDK for Python 3.6 and Python 3 prompts first. These rules cover Agents SDK 0.22 agents, tools, handoffs, guardrails, sessions, approvals, MCP, tracing, and runner limits.

Agents and runner limits

  • Construct agent instructions, model settings, output types, handoffs, and tools from trusted application configuration.
  • Keep user, retrieved, session, and tool content separate from authoritative instructions.
  • Set finite max_turns because None disables the turn limit, and set max_function_tool_concurrency because None starts all function calls emitted in a turn concurrently.
  • Treat final output and typed output as untrusted until domain invariants and destination controls validate it.
  • Handle MaxTurnsExceeded, model errors, cancellation, and partial streaming as non-success states.

Function tools and hosted tools

  • Define narrow function-tool schemas and validate arguments independently before execution.
  • Map tool names to fixed callables and never import, evaluate, or dispatch from model-produced text.
  • Reauthorize each tool call against current identity, tenant, resource, and operation context.
  • Restrict hosted tools, computer use, code execution, file search, and web search to approved workloads and destinations.
  • Require approval for privileged, irreversible, external, costly, or destructive tool actions.
  • Set a sanitized failure_error_function on function tools, Agent.as_tool(), and local MCP servers; the default formatter includes exception text in model-visible output, while None propagates errors.

Handoffs and