* docs: organize SDK guides and clarify examples * fix: correct native SDK type declarations * test: update native SDK contract fixtures * fix: normalize persisted agent profile transport settings * test: reconcile inherited model settings API snapshot * test: preserve executor coverage on Windows --------- Co-authored-by: markstuart-oai <323302876+markstuart-oai@users.noreply.github.com>
3.3 KiB
Choose how to run your agent
Choose who runs the agent loop and manages its lifetime. The Agents SDK runs Codex in your Python application; your application owns the workers, storage, and credentials. The hosted Agents API lets OpenAI run the loop and manage its sessions.
Decide separately where commands execute. An SDK agent can call Python or MCP tools without a command executor.
Use your existing Python code
Use the Agents SDK to connect the model and tool loop to your Python code:
- Functions as tools.
@function_tooldeclares a tool from supported type annotations, validates arguments, and calls the Python function. - Application objects.
ToolContextgives a tool access to the application's context, such as an account or database client. - Python result types. Set
output_typeto a supported type, such as a Pydantic model. The SDK validates the result and returns a value of that type infinal_output.
Configure the agent's tools for your application. If the agent needs file or process access, also choose an executor and its execution permissions.
Follow installation and the quickstart to build your first agent.
Let OpenAI run the agent
Choose Agents API when you want OpenAI to run the agent loop, retain session state and manage recovery.
Choose where commands run separately: an OpenAI-hosted environment, a self-hosted environment, or no command execution. In a self-hosted environment, commands run on your infrastructure and OpenAI runs the agent loop.
Choose feature combinations
After your first run, use these guides to choose the features your application needs. Each guide explains the supported combinations and their limits.
| Task | Start here |
|---|---|
| Return a typed answer | Structured output explains provider-enforced schemas and Python validation. |
| Continue on one machine or store history in a database | Storage choices compares LocalStorage, CustomStorage, and portable checkpoints. |
| Move work to another worker or wait for a person | Check capture readiness and the limits on saving manual requests. |
| Coordinate tools with generated JavaScript | Programmatic tool calling explains the execution model and checkpoint limits. |
| Delegate independent work | Native children explains shared tools, permissions, and child lifecycles. |
| Use a custom model endpoint | Run the endpoint checks for each required feature, including tools, strict output, and WebSockets. |
Configuration support and runtime readiness are different checks. A Session can support checkpoints but still have active work that prevents saving. The state guide explains how to check both.