Repository navigation
feat(api): set and read agent session spending limits - #4315
Conversation
Castiron-Internal-PR: openai/openai-python-internal#447 Castiron-Source-SHA: 2be44989ef88f8f41307b1bf5b9d669f55cf718e Castiron-Public-Base-SHA: f63f14b
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
left a comment
There was a problem hiding this comment.
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.
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>
Summary
Support for
spend_controlin synchronous and asynchronous beta agent sessions, including streaming creation.Changes
spend_controlto keep the limit or clear it with a null limit.limitandconsumedon every session. Both keys are required in response fixtures. A null limit means unlimited spending. Null consumption means the amount is unavailable.budget_reachedstatus,session_budget_exceededturn error and typedAgentSessionBudgetReachedEvent.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.