AI AI Pulse

OpenAI puts a spend cap on each agent session

AI News Source: openai-agents-python v1.0.0-alpha.2

OpenAI's SDK can cap spending per agent session, in cents, so 500 means five dollars. The cap is best effort: work already running can still add to the bill.

What happened

On November 23 the OpenAI Python SDK shipped 3.58.0, with the JavaScript SDK following the same day. Both add one capability: a spending limit for each Agents API session. The field is spend_control.limit, counted in US cents, so 500 gives the job five dollars. Apps can read back both the limit and the spend at any time.

How the budget works

The cap covers the whole session, and every turn draws from the same pool. Raising it means setting a new total: going from five dollars to eight sets 8, not plus 3. Reported spend is rounded down to whole cents. When no usable figure exists, the API returns null rather than zero.

When the cap is hit

The API stops taking new input, emits an event that explains the pause, and returns an error code for the turn it blocked. Best effort is the right frame here. Work already in flight can keep adding cost, the job continues if cost data is unavailable, and third-party tools bill on their own meters.

Restarting the work

Raise or remove the cap, and the agent may pick the task back up on its own. Apps should check session state before sending more input, or a user pressing retry can duplicate work. If the same kind of job hits the cap often, the useful question is which step it stops at, not how much more to allow.

Two more things in the same release

Agents SDK 1.0.0-alpha.2 adds ResumableSession, which persists conversation history and pending approvals together. After a worker is lost, calling resume(store, session_id) and handing the state back to the Runner continues the run, including native Codex approvals for exec_command and apply_patch. The new SDK reads alpha.1 schema 1.22 but always writes 1.24. An alpha.1 reader cannot open the new snapshots, and protected checkpoints use version 2. Upgrade readers before writers.

The second piece is tool hooks. RunConfig.tool_execution takes three callbacks. prepare_tool_input rewrites arguments before approval and execution, prepare_tool_output rewrites results afterwards, and prepare_tool_declaration can change or withhold a function declaration. The Runner rechecks eligibility after approval. A separate redact_text callback scrubs recognised text, and tracing can record metadata or full content.

Where the edges are

Hooks do not reach tools that Responses hosts and runs. Setting sdk_only_tool_hooks also disables native Codex workspace tools and their approval recovery. Redaction skips binary media and native Codex operations. When a run is cancelled, Agent.as_tool() child calls get 250 milliseconds to clean up, and tools that overrun can keep working after the cancel returns.

Why it matters

On the same day, Codex CLI 0.172.0 let teams name an approver per connected app tool, and Claude Code 2.1.331 brought Code Mode to Bedrock and Foundry. The three point the same way: put a gate on the agent's wallet and permissions instead of reconciling the bill afterwards.

Nothing here is investment advice.

Source: openai-agents-python v1.0.0-alpha.2

Related