Blog

2026.09.16

AI Agent API Implementation 2026: Agents API Operations Design

AI Agent API Implementation 2026: Agents API Operations Design

If an AI agent API implementation uses OpenAI’s Agents API, an existing agent RFP does not need to be rewritten from zero. Keep the general requirements for business completion, approvals, data classification, and KPIs. Add the operational deltas that are specific to Agents API: session and turn persistence, stream recovery, the maximum five-minute input-time connection wait, environment lifecycle, hosted versus self-hosted executors, key separation, the filesystem shared by subagents, concurrency, and the limits of trace access.

OpenAI announced the Agents API in public beta on September 10, 2026. It provides the Codex harness for long-running sessions, context management, tools, subagents, and hosted or self-hosted environments. This manages much of the agent loop, but it does not guarantee exactly-once business execution or automatic recovery. Official documentation states that a completed turn does not prove that every tool succeeded, missed stream events are not replayed, and a self-hosted customer owns reconnection, shutdown, and persistent files.

For broad implementation decisions, see AI Agent Implementation in 2026. For approvals and business governance, see AI Agent Workflow Governance. For analytical use cases, see Data Agents for Manufacturing. This article covers only the Agents API clauses that should be added to those existing designs.

Agents API components in an AI agent platform

Treat the application, OpenAI-managed harness, session, environment, executor, and tool connections as separate components. With environment.type: none, the harness can call remote MCP and function tools, but built-in shell, workspace files, and executor MCPs are unavailable. With openai_hosted, OpenAI provisions the sandbox and the harness runs commands in it. With self_hosted, the customer provisions compute and runs codex exec-server, which connects outbound to the Agents API over WebSocket.

ComponentPlatform capabilityImplementation responsibility
SessionPersist sessions, turns, and itemsMap business IDs and define retention
StreamDeliver live eventsDetect disconnects and rebuild from saved items
Hosted environmentProvision sandbox and execute commandsNetwork policy, input files, artifact retrieval
Self-hosted environmentHarness-to-executor protocolCompute, startup, reconnect, shutdown, persistence
SubagentsDelegation, events, concurrency settingWork partition, shared-file control, cost ceiling
TraceDashboard views of turns, tools, subagentsBusiness correlation and alternative telemetry

A request/response monitor can miss states such as a durable session with a disconnected executor, a completed turn with a failed tool, or a client that disconnected while work continued.

AI Agent API Implementation 2026: Agents API Operations Design - figure 1

Separate session, turn, item, and business IDs

A session contains conversation and work across multiple turns. A turn is one work cycle for an input. Items record model responses, tool calls, commands, and subagent coordination. Session durability is not a database transaction.

Maintain separate session_id, turn_id, business_execution_id, and side_effect_id. One business request can span several turns; the same business request can also resume in a new session. Keep the mapping in an enterprise ledger. Pass side-effect IDs as idempotency keys or reconcile the target system before retrying a write.

Context compaction supports long work, but compressed conversation should not be the business record. Store structured checkpoints containing input and policy versions, completed and pending steps, artifact hashes, external record IDs, approval status, and the safe resume point.

OpenAI’s hosted-environment guide also warns that a completed turn does not guarantee every tool succeeded. A business completion verifier must inspect required tool items, expected artifacts, and external records before the application displays “completed.”

Recover after a stream disconnect

Streaming is useful for progress, but events missed during a disconnect are not replayed automatically. Do not immediately resend the same input; the original turn may still be active.

Use this recovery sequence:

  1. Mark the client as synchronizing, not failed.
  2. Retrieve the session and current state.
  3. List saved turns and items to find the last confirmed tool, command, and artifact.
  4. Reconcile uncertain writes with the external system using the side-effect ID.
  5. Send a new resume input only after the original turn has ended and the incomplete step is known.

Maximum five-minute input-time connection behavior

If input is submitted while a self-hosted environment is offline, the API can request an environment connection and wait up to five minutes. If that window expires, the submission fails; an initial input can leave the session asynchronously failed. Do not resend the same input while the connection wait is active. A late executor connection does not replay the timed-out input. Retrieve the session and saved items, confirm that the original input did not execute, and only then submit a new turn.

The maximum five minutes is documented product behavior, not the customer system’s SLA. Define separate alert, escalation, manual-fallback, and recovery targets.

StateUnsafe responseRequired check
Stream disconnectedImmediately resend inputRetrieve session and saved items
Environment waitingDuplicate submission before five minutesObserve connection events and turn creation
Five-minute timeoutAssume late connection replays workConfirm non-execution, then create new turn
Turn completedClose as full successVerify tool items and external records
Tool result unknownBlindly retry a writeReconcile by side-effect ID
Policy version changedContinue under mixed rulesStop, checkpoint, and start with the approved version

Operate environment lifecycle separately from session lifecycle

A session can exist while self-hosted compute is offline. An executor can also be connected while no turn is active. Observe connected, disconnected, pending, and failed environment events together with session state.

OpenAI warns that an idle event alone is not a safe shutdown signal. Idle can occur after a connection request clears but before waiting input begins a turn. Before shutdown, recheck incoming work, active commands, required actions, and connection requests, and use a grace period. If shutdown cannot be coordinated, keep compute available.

A mid-turn disconnect can fail a tool even if the overall turn completes. A killed command is not automatically restarted, and a disconnect does not necessarily trigger reconnection through a webhook. Recovery must inspect executor health, command items, artifacts, and external side effects individually.

For OpenAI-hosted sandboxes, network access can be enabled, disabled, or restricted to allowed_domains. Record actual destinations during the PoC and move toward an allowlist. For self-hosting, test the complete outbound route for environment registration and WebSocket commands/results. A corporate proxy timeout shorter than the five-minute platform wait will terminate the path earlier.

AI Agent API Implementation 2026: Agents API Operations Design - figure 2

Separate application and executor keys

The application OPENAI_API_KEY needs permissions for session operations and model inference. The self-hosted environment receives a separate restricted environment key as CODEX_API_KEY. Keep the application key outside the sandbox.

Agent-generated code may read the environment key, but that key is designed only to connect environments. Do not place it in source code, container images, or logs, and test rotation and revocation. The organization, project, and owner must match the session context.

Where possible, keep third-party credentials outside the environment in a credential broker that injects scoped secrets only into approved outbound requests. This addresses a specific Agents API threat: agent-generated code can access files, credentials, and network capabilities exposed inside its environment.

Test the shared filesystem and subagent concurrency

Agents API configures delegation with multi_agent.enabled and max_concurrent_subagents. The documented default is six concurrent subagents, excluding the coordinator. Treat that as a product default, not a production recommendation. Set a limit from downstream rate limits, executor CPU and memory, file contention, and token budgets.

The coordinator and subagents share one environment filesystem. Creating a subagent does not create a new sandbox. Use per-agent work directories, read-only inputs, declared file ownership, atomic writes, and a single merge owner.

Subagents inherit configured MCP tools, credentials and allowed-tool settings, web search, and environment files and commands. They do not support function tools. If an existing workflow expects a child to call a function tool, route it through the coordinator or redesign it as MCP rather than assuming identical capability.

The event stream exposes subagent creation, coordination, wait, and interrupt actions. A completed create or wait item does not mean the child task completed. Inspect child turn outcomes and artifacts.

Specific testFault injectionAcceptance evidence
ConcurrencySubmit more independent tasks than the limitRunning children stay within the limit
Shared fileTwo children update the same fileConflict detected; no silent overwrite
Child failureFail one child commandRoot reports incomplete work
Tool inheritanceAsk child to use a prohibited toolExecution blocked and recorded
Function toolRequest function tool from childUnsupported path detected; planned fallback used
InterruptInterrupt a child mid-taskOutcome and partial artifacts remain attributable

Trace and observability limits in AI agent operations

The Platform dashboard shows sessions, turns, model responses, tool calls, subagent activity, duration, status, and token usage. Tracing is enabled by default for new sessions, but traces are built after a turn ends and may appear after the agent answer. Use live events for in-progress status and traces for post-turn analysis.

During public beta, trace retrieval and external trace exporters are not exposed through the API. Do not promise automatic SIEM export of platform traces. Store session, turn and item IDs, business execution ID, environment events, summarized tool results, artifact hashes, and external record IDs in application telemetry, with appropriate redaction.

Token usage can be recorded separately for root and subagent turns; a parent’s usage does not necessarily include its children. Aggregate every agent turn to avoid understating cost, and run a follow-up collection job if trace or usage data is not ready when the answer arrives.

Cancelling an active turn preserves the session and prior work, but it does not roll back an external tool action already accepted. After cancel, retrieve saved items, reconcile the target system, and choose resume, compensation, or close.

Add Agents API clauses to an AI agent evaluation RFP

Reuse the existing RFP for general approval, data governance, and business evaluation. Add only these product-specific clauses.

AddendumRequired answerAcceptance evidence
Session mappingBusiness ID to session/turn/item mappingLedger and retrieval result
Stream recoveryResynchronization without event replayDisconnect test log
Five-minute connectionWait, timeout, resend suppression, late connectionOffline executor test
Environment lifecycleStartup, reconnect, safe shutdown, persistenceLifecycle events and runbook
Executor boundaryOutbound WebSocket, health, proxy behaviorNetwork diagram and test
Key separationApplication key versus environment keyPermission list and revoke test
Multi-agentConcurrency, shared filesystem, inherited toolsConflict and child-failure tests
Trace limitationLive events, post-turn trace, unavailable APIsAlternative telemetry records
Beta changeVersion pinning, monitoring, regression, rollbackVersion inventory and test result

Require evidence IDs and events, not a generic “supported” answer. Maintain an inventory of SDK, model, harness, container image, and tool schema versions.

Use the 90-day PoC for Agents API failure modes

Keep the PoC to one workflow, one user group, and approximately two to three connected systems. This is a manageable design example, not a product limit or outcome guarantee.

In days 1–30, choose the environment type, implement session mapping and the business ledger, verify hosted network policy or self-hosted executor/key separation, and prove that sessions and saved items remain retrievable after the client stream closes.

In days 31–60, inject stream disconnects, offline executors, the input-time connection timeout, mid-turn disconnects, and unknown tool outcomes. Verify that the client does not duplicate input during the wait, a late connection does not replay timed-out input, and a new turn is sent only after reconciliation. Test subagent concurrency, shared-file conflicts, child failure, interrupt, and function-tool limitations.

In days 61–90, freeze SDK, model, harness, and tool-schema versions and rerun the failure suite. Verify trace delay, dashboard access, alternative telemetry, and operator runbooks for three critical cases: a durable session with a dead environment; a completed turn with a failed tool; and an executor that reconnects only after the five-minute timeout.

AI Agent API Implementation 2026: Agents API Operations Design - figure 3

Thailand deployment checks for business AI agents

For a self-hosted executor inside a Thai factory network, test the Bangkok proxy, DNS, WebSocket idle timeout, and overnight compute policy. The API may wait five minutes, but a shorter corporate proxy timeout can break the path first. When approval from Japan headquarters overlaps with local shutdown, do not stop on idle alone; recheck pending input and approval state.

Keep identifiers, event names, tool names, and error codes in their original form in logs even when operator screens are localized. Correlate the same session_id, turn_id, and environment_connection across Japanese, Thai, and English interfaces. Record both ICT and UTC so the five-minute wait and timeout sequence are unambiguous.

Common Agents API misreadings

A durable session means automatic recovery. It does not provide event replay, external reconciliation, or automatic restart of killed commands.

Idle means self-hosted compute can stop. Idle alone is not a safe shutdown signal.

Every subagent receives a separate sandbox. Coordinator and children share the filesystem.

Completed turn means every tool succeeded. Inspect tool items, artifacts, and external records.

Trace is immediately retrievable and exportable by API. Traces are post-turn, and public beta does not expose trace retrieval or external exporters.

Conclusion: accept the state transitions unique to Agents API

The product-specific work in an AI agent API implementation is well defined. Map sessions, turns, and items to business IDs. Recover a disconnected stream from saved items rather than assuming event replay. A self-hosted input-time connection waits up to five minutes; after timeout, a late connection does not replay the old input, so duplicate submission must be suppressed. Monitor environment lifecycle separately from session state and never shut down on idle alone.

Separate application and environment keys. Test subagents under a shared filesystem and explicit concurrency ceiling. Treat traces as valuable post-turn evidence while compensating for public-beta API and exporter limits with application telemetry. Adding these clauses to an existing agent RFP and fault-testing two to three connected systems evaluates Agents API without repeating a generic governance article.

TOMAS TECH can help add these clauses to an existing RFP and design tests for hosted/self-hosted environments, executor connectivity, session recovery, subagent contention, and the five-minute timeout. Contact TOMAS TECH to review the operating design before broad system access is granted.

FAQ: Agents API operations design

Should the client resend input when a stream disconnects?

Not immediately. Retrieve the session and saved items first because the original turn may still be running and missed events are not replayed. Reconcile uncertain writes before creating a new turn.

Is the five-minute self-hosted wait an SLA?

No. It is documented product behavior. Submission fails after the input-time connection window, and a late connection does not replay timed-out input. Define separate internal alert and recovery SLAs.

Does each subagent get isolated files?

No. Coordinator and subagents share the environment filesystem. Use separate work directories, ownership rules, atomic writes, and controlled merge.

Is the Platform trace sufficient for audit?

It is useful but post-turn, and public beta does not expose trace retrieval or external exporters through the API. Persist business correlation and essential evidence in application telemetry.

What belongs in the RFP addendum?

Session mapping, non-replayed stream recovery, five-minute connection behavior, environment lifecycle, executor/key boundaries, shared filesystem/concurrency, trace limits, and beta-version management.

References

(All primary sources accessed September 16, 2026.)