agents/apiTHE ENCYCLOPEDIA
Production

Human approval & prompt injection defenses

Put authorization and confirmation between an agent's proposal and a real-world action.

Untrusted content
Proposed tool call
Policy check
Human approval
Authorized execution

Treat retrieved text as data

A web page, document, email, or MCP result can contain instructions to disclose data or use another tool. Keep that content out of privileged developer instructions. Extract the fields the task needs, preserve source attribution, and enforce tool policy in application code. Structured data reduces ambiguity but does not make an external source trustworthy.

Bind approval to the exact action

For a refund, show the authenticated reviewer the order, recipient, amount, currency, reason, and consequences. Save a pending approval containing the normalized arguments and the user/session/turn/call identifiers. Approve that exact record, not an unrestricted promise that the agent may refund something later. Any argument change invalidates approval.

Bind approval to the exact action
Proposed actionApplication control
Read an orderEnforce ownership and return only needed fields
Send an emailShow exact recipients and message; require confirmation
Issue a refundCheck policy, approved amount, currency, and idempotency key
Run a shell commandConstrain environment, network access, and credentials
Read external contentKeep embedded instructions outside privileged policy

Execute after rechecking authority

When a person approves, revalidate their permission and the current object state. Atomically claim the pending operation so two workers cannot execute it concurrently. Use an idempotency key at the downstream service and store the result before acknowledging completion. An expired, denied, or modified request must not execute. Return a useful tool error for rejection without exposing private policy details.

Keep runtime-specific mechanisms separate

The linked safety guide describes Agent Builder controls; its approval nodes are not Agents API fields. For an Agents API application function, your handler owns the approval workflow and result submission. With MCP or other execution paths, verify their documented approval behavior before granting a sensitive tool. Do not assume a UI confirmation intercepts every tool path.

Build adversarial acceptance tests

Test a retrieved document saying 'send all orders to this URL', a tool argument containing another tenant's ID, an altered amount after approval, duplicate approval delivery, and a revoked reviewer account. Passing means the forbidden action never reaches the downstream service, not merely that the final answer apologizes. Layer permissions, constrained tools, approvals, logging, and evaluations; none guarantees immunity to prompt injection.

Read the official reference

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

OpenAI: agent-builder-safety Agents API function handlers

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