agents/apiTHE ENCYCLOPEDIA
Core concepts

Agent resources, relationships & task state

Map configuration, sessions, turns, events, items, environments, and artifacts to their owners and lifetimes.

Input accepted
Turn runs
Tool or environment needed
Work continues
Outcome checked

Read the resource relationships

These connections describe ownership and use, not a single linear request. One reusable agent configuration can serve multiple independent sessions; each session can perform multiple turns.

Track outcomes independently

This is an application interpretation of signals, not a replacement for the API's state schema. Waiting for a dependency, completing a turn, and closing a browser connection are different facts.

Track outcomes independently
SignalMeaning for your application
New input while idleStarts another turn in the session
New input while activeCan steer the active turn
requires_actionInspect and satisfy the current dependency
idleNot proof of successful task completion
Root turn completedCheck output and tool outcomes
Root failed or cancelledShow failure/cancellation; preserve diagnostic IDs
Stream closedTransport ended; inspect state if no terminal event arrived

Do not equate IDs with authorization

Store your authenticated user's ownership mapping separately from the session ID. A tool call belongs to a turn and call identifier; a business operation needs its own stable identity for idempotency. Do not let an untrusted request choose an arbitrary session, tool result, or approval record.

Keep compute lifetime separate

Self-hosted compute may disconnect while its session still exists. A replacement machine does not recover files merely by reusing an environment ID. Persist files through the provider and coordinate reconnection. Delete the session and release self-hosted compute separately after preserving needed output.

Read the official reference

Check the source for current API fields, account requirements, and service limits.

OpenAI: sessions Environment lifecycle Events and items

38 matching topics

What is the OpenAI Agents API?FoundationsAgents API vs Agents SDK vs Responses APIComparisonsAgents API quickstartGetting startedSessions, turns & durable stateCore conceptsHosted vs self-hosted sandboxesInfrastructureConnect MCP servers to Agents APITools & integrationsFunction calling & application toolsTools & integrationsMulti-agent orchestrationCore conceptsStreaming, webhooks & event handlingIntegration guidesFiles, outputs & published artifactsCore conceptsVaults & MCP authenticationTools & integrationsAgent security & credential boundariesProductionTracing, usage & debuggingProductionAgents API pricing & cost planningProductionOpenAI Agents API with PythonGetting startedAgents API with TypeScript & Next.jsIntegration guidesWhat is the OpenAI Agents SDK?FoundationsResponses API in the agent stackFoundationsAgent Skills & SKILL.mdTools & integrationsProgrammatic Tool CallingTools & integrationsRAG, file search & vector storesTools & integrationsWeb search & source citationsTools & integrationsChatKit & Agent BuilderIntegration guidesAgent configuration & reusable definitionsCore conceptsPlugins: connect skills and MCP toolsTools & integrationsSandbox lifecycle & executor connectionsInfrastructureWebhook verification, queues & deduplicationIntegration guidesAgent retries, timeouts & failure recoveryProductionAgent evaluations & regression testingProductionWhich parts of the agent stack do you need?FoundationsAgents API contract quick referenceIntegration guidesOrder agent reference: approval, recovery & evaluationIntegration guidesBuild a Next.js order agent: server, tools & streamingIntegration guidesPython Agents API example with a real tool loopGetting startedHuman approval & prompt injection defensesProductionAgents API troubleshooting: symptoms, checks & recoveryProductionAgent tool support & runtime ownership matrixComparisonsAgent resources, relationships & task stateCore concepts
K to open Esc to close