Skip to content

feat(api): set and read agent session spending limits - #4315

Merged
markstuart-oai merged 1 commit into
mainfrom
castiron/promotions/pr-447
Nov 23, 2026
Merged

markstuart-oai merged 1 commit into
mainfrom
castiron/promotions/pr-447

Conversation

@markstuart-oai

Copy link
Copy Markdown
Contributor

Summary

Support for spend_control in synchronous and asynchronous beta agent sessions, including streaming creation.

Changes

  • Set a best-effort limit in USD cents. On update, omit spend_control to keep the limit or clear it with a null limit.
  • Read limit and consumed on every session. Both keys are required in response fixtures. A null limit means unlimited spending. Null consumption means the amount is unavailable.
  • The budget_reached status, session_budget_exceeded turn error and typed AgentSessionBudgetReachedEvent.

Validation

Local checks have been passing: 581 focused agent tests with Pydantic v2, 493 with Pydantic v1, whole-tree Ruff, and whole-tree type checking. Coverage has been exercising exact nullable spending values, omitted and null updates, and typed budget events through synchronous and asynchronous clients.

Castiron-Internal-PR: openai/openai-python-internal#447
Castiron-Source-SHA: 2be44989ef88f8f41307b1bf5b9d669f55cf718e
Castiron-Public-Base-SHA: f63f14b
@markstuart-oai
markstuart-oai requested a review from a team as a code owner November 23, 2026 18:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T18:27:57.484419Z 59f77d8 PR opened
🔒 Security Review ✅ Completed 2026-11-23T18:28:22.969515Z 59f77d8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after static review and independent second review. Verified sync/async signatures and request bodies preserve omission versus explicit null, response models and event discriminators match the schema, and existing stream collectors handle budget-reached boundaries. Reviewed regression coverage for nullable spend values and both streaming surfaces. No actionable findings.

Hosted CI: 17 passed, 9 skipped. Static review only; no candidate code or local tests executed.

@markstuart-oai
markstuart-oai added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit fc36aef Nov 23, 2026
26 checks passed
@markstuart-oai
markstuart-oai deleted the castiron/promotions/pr-447 branch November 23, 2026 18:48
@openai-sdks openai-sdks Bot mentioned this pull request Nov 23, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-openai__openai-python that referenced this pull request Nov 23, 2026
Automated Release PR
---


##
[3.58.0](openai/openai-python@v3.57.0...v3.58.0)
(2026-11-23)


### Features

* **api:** set and read agent session spending limits
([openai#4315](openai#4315))
([fc36aef](openai@fc36aef))


### Bug Fixes

* **api:** clarify when to omit completion choice count
([openai#4298](openai#4298))
([f63f14b](openai@f63f14b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants