All posts

Machine Identities in the OpenAI Agents SDK, Explained

A newly hired contractor was given a service‑account token that the OpenAI Agents SDK uses to call internal APIs. The token granted read and write rights across the entire data lake, even though the contractor only needed to retrieve a single report. Weeks later, a mis‑configured automation script ran the same SDK against a production database and unintentionally exposed customer records. The root cause was not the SDK itself, but the way machine identities were provisioned: static, over‑privile

Free White Paper

Just-in-Time Access + Machine Identity: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

A newly hired contractor was given a service‑account token that the OpenAI Agents SDK uses to call internal APIs. The token granted read and write rights across the entire data lake, even though the contractor only needed to retrieve a single report. Weeks later, a mis‑configured automation script ran the same SDK against a production database and unintentionally exposed customer records. The root cause was not the SDK itself, but the way machine identities were provisioned: static, over‑privileged, and invisible to any audit system.

Machine identity, in this context, means a non‑human credential that an automated process presents to a target system. The OpenAI Agents SDK treats such credentials like any other secret: they are loaded from environment variables or secret stores, then attached to outbound requests. Because the SDK does not enforce any policy on the credential itself, developers often reuse the same token across many agents, pipelines, and environments. The result is a sprawling attack surface where a single compromised secret can move laterally across databases, message queues, and internal services.

Why the current model falls short

Two core requirements are missing from the default workflow.

  • Least‑privilege provisioning. Each agent should receive only the permissions it needs for the specific task it performs. The SDK does not provide a built‑in mechanism to request or enforce scoped rights.
  • Visibility and control. Teams need to know exactly when a machine identity accessed a resource, what data was returned, and whether any sensitive fields were exposed. The SDK does not record sessions, mask responses, or require human approval for risky commands.

Even if an organization deploys an identity provider that issues short‑lived tokens, the token still travels directly from the SDK to the target service. There is no interception point where policy can be evaluated, where data can be redacted, or where a replay can be generated for later audit. In other words, the setup decides who can start a request, but it does not enforce any guardrails on the request itself.

Introducing a data‑path gateway

To satisfy the missing requirements, the request must pass through a dedicated gateway that sits between the OpenAI Agents SDK and the downstream resource. This gateway becomes the only place where enforcement can happen. It inspects the protocol, applies policy, and then forwards the traffic to the target.

hoop.dev fulfills that role. It is a Layer 7 identity‑aware proxy that runs a network‑resident agent near the resource and a central gateway that all machine‑identity traffic must traverse. The gateway authenticates the SDK’s OIDC token, reads group membership, and then decides whether the request is allowed, whether it needs a just‑in‑time approval, or whether it should be blocked.

Continue reading? Get the full guide.

Just-in-Time Access + Machine Identity: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

How hoop.dev enforces policy

  • hoop.dev records each session, creating a replayable audit trail that shows which machine identity accessed which endpoint and when.
  • hoop.dev masks sensitive fields in responses, ensuring that downstream services never leak personally identifiable information to the calling agent.
  • hoop.dev blocks dangerous commands before they reach the target, preventing accidental data deletion or schema changes.
  • hoop.dev routes high‑risk operations to a human approver, adding a final check for actions that could impact production stability.

All of these outcomes exist only because the gateway sits in the data path. If the SDK connected directly to the resource, none of the above would be possible.

Putting the pieces together

The overall architecture looks like this:

  1. Setup. An identity provider (Okta, Azure AD, etc.) issues short‑lived OIDC tokens to the OpenAI Agents SDK. These tokens identify the machine identity and carry minimal claims.
  2. Data path. The SDK sends its request to hoop.dev instead of the target service. hoop.dev validates the token, checks the requested operation against policy, and either forwards, masks, blocks, or queues the request for approval.
  3. Enforcement outcomes. hoop.dev records the session, masks data, blocks unsafe commands, and logs every decision for later review.

This separation ensures that the identity provider only decides who may start a request, while hoop.dev guarantees that every request complies with organizational policy before it reaches the resource.

Getting started

Organizations can deploy hoop.dev using the official getting‑started guide. The documentation explains how to configure the gateway, register a connection to a database or HTTP service, and enable inline masking and session recording. For a deeper dive into policy configuration and approval workflows, see the learn section of the site.

FAQ

Do I need to change my existing OpenAI Agents SDK code?
No. The SDK continues to use its standard client libraries. You only change the endpoint it talks to, pointing it at the hoop.dev gateway.

Can hoop.dev work with any secret‑management solution?
Yes. The gateway holds the credential for the downstream resource, while the SDK presents only its OIDC token. This means you can keep your existing vault or key‑management system for token issuance.

Is the gateway open source?
Absolutely. The project is MIT licensed and the source is available on GitHub. Explore the source code on GitHub to see how the proxy intercepts traffic and applies policies.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts