openai 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/lib/openai/helpers/agents/session_stream.rb +5 -0
- data/lib/openai/helpers/beta/agents/result.rb +8 -0
- data/lib/openai/models/beta/agent_session.rb +40 -1
- data/lib/openai/models/beta/agent_session_budget_reached_event.rb +48 -0
- data/lib/openai/models/beta/agent_session_event.rb +4 -1
- data/lib/openai/models/beta/agents/session_create_params.rb +33 -1
- data/lib/openai/models/beta/agents/session_update_params.rb +33 -1
- data/lib/openai/models/beta/session_turn_error.rb +3 -0
- data/lib/openai/resources/beta/agents/sessions/events.rb +1 -1
- data/lib/openai/resources/beta/agents/sessions.rb +15 -3
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +1 -0
- data/rbi/openai/models/beta/agent_session.rbi +66 -0
- data/rbi/openai/models/beta/agent_session_budget_reached_event.rbi +83 -0
- data/rbi/openai/models/beta/agent_session_event.rbi +1 -0
- data/rbi/openai/models/beta/agents/session_create_params.rbi +56 -0
- data/rbi/openai/models/beta/agents/session_update_params.rbi +56 -0
- data/rbi/openai/models/beta/session_turn_error.rbi +3 -0
- data/rbi/openai/resources/beta/agents/sessions.rbi +12 -0
- data/sig/openai/models/beta/agent_session.rbs +33 -1
- data/sig/openai/models/beta/agent_session_budget_reached_event.rbs +52 -0
- data/sig/openai/models/beta/agent_session_event.rbs +1 -0
- data/sig/openai/models/beta/agents/session_create_params.rbs +23 -0
- data/sig/openai/models/beta/agents/session_update_params.rbs +23 -0
- data/sig/openai/models/beta/session_turn_error.rbs +4 -0
- data/sig/openai/resources/beta/agents/sessions.rbs +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14249c7a47dfa4d81273f59b451f91b9527702698e46c86b1df814bb97abbf27
|
|
4
|
+
data.tar.gz: 7b2b4145f2427041cb5a4f3b2ae46df922a01b8c96af0fa6f619848a252087af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33d44eb1628ef7cb94359952aa2f8950678089e8021e8996ccb5cf357ce54d2b32de50a9afd6845521cc82b9bcfe65a5ecd5a7ce134f1a82b37e583ab12d8eee
|
|
7
|
+
data.tar.gz: 8bc539e8cfb6d3488cea2fbca1d7d502a390cceb8e063cd45ae0c6aa8e1432e795405e324be888cb0ba68bfbf37af268eda6324e1d69c486ae08ffdb337d3783
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.1.0](https://github.com/openai/openai-ruby/compare/v1.0.0...v1.1.0) (2026-11-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **api:** support agent session spending limits and budget events ([#1104](https://github.com/openai/openai-ruby/issues/1104)) ([a4b50e8](https://github.com/openai/openai-ruby/commit/a4b50e8c0e417ac88fbc926d19d12dba617ce823))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* **deps-dev:** bump sorbet-runtime from 0.6.13646 to 0.6.13681 in the development-dependencies group ([#1101](https://github.com/openai/openai-ruby/issues/1101)) ([195fa16](https://github.com/openai/openai-ruby/commit/195fa16767a3781967bfd15d8bfd4fddad639fd3))
|
|
14
|
+
* **deps:** bump the codeql group with 2 updates ([#1102](https://github.com/openai/openai-ruby/issues/1102)) ([93b5c80](https://github.com/openai/openai-ruby/commit/93b5c80e48544f5f1855b822a4727b69a2856fa4))
|
|
15
|
+
|
|
3
16
|
## [1.0.0](https://github.com/openai/openai-ruby/compare/v0.130.0...v1.0.0) (2026-11-21)
|
|
4
17
|
|
|
5
18
|
|
data/README.md
CHANGED
|
@@ -170,7 +170,12 @@ module OpenAI
|
|
|
170
170
|
next
|
|
171
171
|
end
|
|
172
172
|
|
|
173
|
+
session = event[:session] if event.type == :"agent.session.budget_reached"
|
|
173
174
|
terminal = event.type == :"agent.session.failed" ||
|
|
175
|
+
(event.type == :"agent.session.budget_reached" &&
|
|
176
|
+
(session.is_a?(Hash) || session.is_a?(OpenAI::Internal::Type::BaseModel)) &&
|
|
177
|
+
session[:id] == @session_id &&
|
|
178
|
+
(@turn_id.nil? || @turn_ended)) ||
|
|
174
179
|
(event.type == :"agent.session.idle" && @turn_ended)
|
|
175
180
|
invocation = @dispatcher.prepare_call(event) unless terminal
|
|
176
181
|
close if terminal
|
|
@@ -123,6 +123,14 @@ module OpenAI
|
|
|
123
123
|
|
|
124
124
|
when :"agent.session.in_progress"
|
|
125
125
|
@required_actions = [] if event.session.id == @session_id
|
|
126
|
+
when :"agent.session.budget_reached"
|
|
127
|
+
session = event[:session]
|
|
128
|
+
if (session.is_a?(Hash) || session.is_a?(OpenAI::Internal::Type::BaseModel)) &&
|
|
129
|
+
session[:id].is_a?(String)
|
|
130
|
+
@session_id ||= session[:id].dup
|
|
131
|
+
@finished = true if (@turn.nil? || @terminal) && session[:id] == @session_id
|
|
132
|
+
end
|
|
133
|
+
|
|
126
134
|
when :"agent.session.idle"
|
|
127
135
|
@finished = true if @terminal && event.session.id == @session_id
|
|
128
136
|
when :"agent.session.failed"
|
|
@@ -61,6 +61,13 @@ module OpenAI
|
|
|
61
61
|
-> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AgentSession::RequiredAction] }
|
|
62
62
|
)
|
|
63
63
|
|
|
64
|
+
# @!attribute spend_control
|
|
65
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
66
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
67
|
+
#
|
|
68
|
+
# @return [OpenAI::Models::Beta::AgentSession::SpendControl]
|
|
69
|
+
required :spend_control, -> { OpenAI::Beta::AgentSession::SpendControl }
|
|
70
|
+
|
|
64
71
|
# @!attribute status
|
|
65
72
|
# The current status of the session.
|
|
66
73
|
#
|
|
@@ -93,7 +100,7 @@ module OpenAI
|
|
|
93
100
|
# @return [Symbol, OpenAI::Models::Beta::AgentSession::Review, nil]
|
|
94
101
|
optional :review, enum: -> { OpenAI::Beta::AgentSession::Review }
|
|
95
102
|
|
|
96
|
-
# @!method initialize(id:, agent:, created_at:, environment:, error:, last_active_at:, metadata:, required_actions:, status:, usage:, vault_ids:, prompt_cache_options: nil, review: nil, object: :"agent.session")
|
|
103
|
+
# @!method initialize(id:, agent:, created_at:, environment:, error:, last_active_at:, metadata:, required_actions:, spend_control:, status:, usage:, vault_ids:, prompt_cache_options: nil, review: nil, object: :"agent.session")
|
|
97
104
|
# A Managed Agents session.
|
|
98
105
|
#
|
|
99
106
|
# @param id [String]
|
|
@@ -120,6 +127,10 @@ module OpenAI
|
|
|
120
127
|
# @param required_actions [Array<OpenAI::Models::Beta::AgentSession::RequiredAction::McpApprovalRequest, OpenAI::Models::Beta::AgentSession::RequiredAction::ComputerUseApprovalRequest, OpenAI::Models::Beta::AgentSession::RequiredAction::FunctionCall, OpenAI::Models::Beta::AgentSession::RequiredAction::EnvironmentConnection>]
|
|
121
128
|
# Actions that must be completed before the session can continue.
|
|
122
129
|
#
|
|
130
|
+
# @param spend_control [OpenAI::Models::Beta::AgentSession::SpendControl]
|
|
131
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
132
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
133
|
+
#
|
|
123
134
|
# @param status [Symbol, OpenAI::Models::Beta::AgentSession::Status]
|
|
124
135
|
# The current status of the session.
|
|
125
136
|
#
|
|
@@ -720,6 +731,31 @@ module OpenAI
|
|
|
720
731
|
# @return [Array(OpenAI::Models::Beta::AgentSession::RequiredAction::McpApprovalRequest, OpenAI::Models::Beta::AgentSession::RequiredAction::ComputerUseApprovalRequest, OpenAI::Models::Beta::AgentSession::RequiredAction::FunctionCall, OpenAI::Models::Beta::AgentSession::RequiredAction::EnvironmentConnection)]
|
|
721
732
|
end
|
|
722
733
|
|
|
734
|
+
# @see OpenAI::Models::Beta::AgentSession#spend_control
|
|
735
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
736
|
+
# @!attribute consumed
|
|
737
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
738
|
+
#
|
|
739
|
+
# @return [Integer, nil]
|
|
740
|
+
required :consumed, Integer, nil?: true
|
|
741
|
+
|
|
742
|
+
# @!attribute limit
|
|
743
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
744
|
+
#
|
|
745
|
+
# @return [Integer, nil]
|
|
746
|
+
required :limit, Integer, nil?: true
|
|
747
|
+
|
|
748
|
+
# @!method initialize(consumed:, limit:)
|
|
749
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
750
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
751
|
+
#
|
|
752
|
+
# @param consumed [Integer, nil]
|
|
753
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
754
|
+
#
|
|
755
|
+
# @param limit [Integer, nil]
|
|
756
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
757
|
+
end
|
|
758
|
+
|
|
723
759
|
# The current status of the session.
|
|
724
760
|
#
|
|
725
761
|
# @see OpenAI::Models::Beta::AgentSession#status
|
|
@@ -738,6 +774,9 @@ module OpenAI
|
|
|
738
774
|
# The session failed.
|
|
739
775
|
FAILED = :failed
|
|
740
776
|
|
|
777
|
+
# The session is paused because its spending limit was reached.
|
|
778
|
+
BUDGET_REACHED = :budget_reached
|
|
779
|
+
|
|
741
780
|
# @!method self.values
|
|
742
781
|
# @return [Array<Symbol>]
|
|
743
782
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenAI
|
|
4
|
+
module Models
|
|
5
|
+
module Beta
|
|
6
|
+
class AgentSessionBudgetReachedEvent < OpenAI::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute event_id
|
|
8
|
+
# The unique ID of the event.
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
required :event_id, String
|
|
12
|
+
|
|
13
|
+
# @!attribute session
|
|
14
|
+
# The paused session.
|
|
15
|
+
#
|
|
16
|
+
# @return [OpenAI::Models::Beta::AgentSession]
|
|
17
|
+
required :session, -> { OpenAI::Beta::AgentSession }
|
|
18
|
+
|
|
19
|
+
# @!attribute type
|
|
20
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
21
|
+
#
|
|
22
|
+
# @return [Symbol, :"agent.session.budget_reached"]
|
|
23
|
+
required :type, const: :"agent.session.budget_reached"
|
|
24
|
+
|
|
25
|
+
# @!attribute obfuscation
|
|
26
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
27
|
+
#
|
|
28
|
+
# @return [String, nil]
|
|
29
|
+
optional :obfuscation, String
|
|
30
|
+
|
|
31
|
+
# @!method initialize(event_id:, session:, obfuscation: nil, type: :"agent.session.budget_reached")
|
|
32
|
+
# Emitted when a session pauses because its spending limit was reached.
|
|
33
|
+
#
|
|
34
|
+
# @param event_id [String]
|
|
35
|
+
# The unique ID of the event.
|
|
36
|
+
#
|
|
37
|
+
# @param session [OpenAI::Models::Beta::AgentSession]
|
|
38
|
+
# The paused session.
|
|
39
|
+
#
|
|
40
|
+
# @param obfuscation [String]
|
|
41
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
42
|
+
#
|
|
43
|
+
# @param type [Symbol, :"agent.session.budget_reached"]
|
|
44
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -54,6 +54,9 @@ module OpenAI
|
|
|
54
54
|
# Emitted when a session becomes idle.
|
|
55
55
|
variant :"agent.session.idle", -> { OpenAI::Beta::AgentSessionIdleEvent }
|
|
56
56
|
|
|
57
|
+
# Emitted when a session pauses because its spending limit was reached.
|
|
58
|
+
variant :"agent.session.budget_reached", -> { OpenAI::Beta::AgentSessionBudgetReachedEvent }
|
|
59
|
+
|
|
57
60
|
# Emitted when a session starts processing a turn.
|
|
58
61
|
variant :"agent.session.in_progress", -> { OpenAI::Beta::AgentSessionInProgressEvent }
|
|
59
62
|
|
|
@@ -130,7 +133,7 @@ module OpenAI
|
|
|
130
133
|
)
|
|
131
134
|
|
|
132
135
|
# @!method self.variants
|
|
133
|
-
# @return [Array(OpenAI::Models::Beta::AgentSessionErrorEvent, OpenAI::Models::Beta::AgentSessionEnvironmentReadyEvent, OpenAI::Models::Beta::AgentSessionEnvironmentSuspendedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentExpiredEvent, OpenAI::Models::Beta::AgentSessionEnvironmentResetEvent, OpenAI::Models::Beta::AgentOutputCommandExecutionOutputDeltaEvent, OpenAI::Models::Beta::AgentSessionCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnInProgressEvent, OpenAI::Models::Beta::AgentSessionTurnCompletedEvent, OpenAI::Models::Beta::AgentSessionTurnFailedEvent, OpenAI::Models::Beta::AgentSessionTurnCancelledEvent, OpenAI::Models::Beta::AgentSessionTurnItemAddedEvent, OpenAI::Models::Beta::AgentSessionIdleEvent, OpenAI::Models::Beta::AgentSessionInProgressEvent, OpenAI::Models::Beta::AgentSessionRequiresActionEvent, OpenAI::Models::Beta::AgentSessionFailedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentPendingEvent, OpenAI::Models::Beta::AgentSessionEnvironmentConnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentDisconnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentFailedEvent, OpenAI::Models::Beta::AgentSessionSubagentCreatedEvent, OpenAI::Models::Beta::AgentSessionSubagentActiveEvent, OpenAI::Models::Beta::AgentSessionSubagentClosedEvent, OpenAI::Models::Beta::AgentSessionTurnItemDoneEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDoneEvent)]
|
|
136
|
+
# @return [Array(OpenAI::Models::Beta::AgentSessionErrorEvent, OpenAI::Models::Beta::AgentSessionEnvironmentReadyEvent, OpenAI::Models::Beta::AgentSessionEnvironmentSuspendedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentExpiredEvent, OpenAI::Models::Beta::AgentSessionEnvironmentResetEvent, OpenAI::Models::Beta::AgentOutputCommandExecutionOutputDeltaEvent, OpenAI::Models::Beta::AgentSessionCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnInProgressEvent, OpenAI::Models::Beta::AgentSessionTurnCompletedEvent, OpenAI::Models::Beta::AgentSessionTurnFailedEvent, OpenAI::Models::Beta::AgentSessionTurnCancelledEvent, OpenAI::Models::Beta::AgentSessionTurnItemAddedEvent, OpenAI::Models::Beta::AgentSessionIdleEvent, OpenAI::Models::Beta::AgentSessionBudgetReachedEvent, OpenAI::Models::Beta::AgentSessionInProgressEvent, OpenAI::Models::Beta::AgentSessionRequiresActionEvent, OpenAI::Models::Beta::AgentSessionFailedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentPendingEvent, OpenAI::Models::Beta::AgentSessionEnvironmentConnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentDisconnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentFailedEvent, OpenAI::Models::Beta::AgentSessionSubagentCreatedEvent, OpenAI::Models::Beta::AgentSessionSubagentActiveEvent, OpenAI::Models::Beta::AgentSessionSubagentClosedEvent, OpenAI::Models::Beta::AgentSessionTurnItemDoneEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDoneEvent)]
|
|
134
137
|
end
|
|
135
138
|
end
|
|
136
139
|
end
|
|
@@ -64,6 +64,19 @@ module OpenAI
|
|
|
64
64
|
# @return [Symbol, OpenAI::Models::Beta::Agents::SessionCreateParams::Review, nil]
|
|
65
65
|
optional :review, enum: -> { OpenAI::Beta::Agents::SessionCreateParams::Review }
|
|
66
66
|
|
|
67
|
+
# @!attribute spend_control
|
|
68
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
69
|
+
# session.
|
|
70
|
+
#
|
|
71
|
+
# @return [OpenAI::Models::Beta::Agents::SessionCreateParams::SpendControl, nil]
|
|
72
|
+
optional(
|
|
73
|
+
:spend_control,
|
|
74
|
+
-> {
|
|
75
|
+
OpenAI::Beta::Agents::SessionCreateParams::SpendControl
|
|
76
|
+
},
|
|
77
|
+
nil?: true
|
|
78
|
+
)
|
|
79
|
+
|
|
67
80
|
# @!attribute stream_options
|
|
68
81
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
69
82
|
#
|
|
@@ -76,7 +89,7 @@ module OpenAI
|
|
|
76
89
|
# @return [Array<String>, nil]
|
|
77
90
|
optional :vault_ids, OpenAI::Internal::Type::ArrayOf[String], nil?: true
|
|
78
91
|
|
|
79
|
-
# @!method initialize(environment:, agent: nil, agent_id: nil, input: nil, metadata: nil, prompt_cache_options: nil, review: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
92
|
+
# @!method initialize(environment:, agent: nil, agent_id: nil, input: nil, metadata: nil, prompt_cache_options: nil, review: nil, spend_control: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
80
93
|
# @param environment [OpenAI::Models::Beta::EnvironmentParam::None, OpenAI::Models::Beta::EnvironmentParam::OpenAIHosted, OpenAI::Models::Beta::EnvironmentParam::SelfHosted]
|
|
81
94
|
# An inline execution environment or a reference to an environment template.
|
|
82
95
|
#
|
|
@@ -105,6 +118,10 @@ module OpenAI
|
|
|
105
118
|
# @param review [Symbol, OpenAI::Models::Beta::Agents::SessionCreateParams::Review]
|
|
106
119
|
# Action review mode. Omit to use none.
|
|
107
120
|
#
|
|
121
|
+
# @param spend_control [OpenAI::Models::Beta::Agents::SessionCreateParams::SpendControl, nil]
|
|
122
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
123
|
+
# session.
|
|
124
|
+
#
|
|
108
125
|
# @param stream_options [OpenAI::Models::Beta::Agents::SessionCreateParams::StreamOptions]
|
|
109
126
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
110
127
|
#
|
|
@@ -356,6 +373,21 @@ module OpenAI
|
|
|
356
373
|
# @return [Array<Symbol>]
|
|
357
374
|
end
|
|
358
375
|
|
|
376
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
377
|
+
# @!attribute limit
|
|
378
|
+
# Positive USD cents, or null to remove the limit.
|
|
379
|
+
#
|
|
380
|
+
# @return [Integer, nil]
|
|
381
|
+
required :limit, Integer, nil?: true
|
|
382
|
+
|
|
383
|
+
# @!method initialize(limit:)
|
|
384
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
385
|
+
# session.
|
|
386
|
+
#
|
|
387
|
+
# @param limit [Integer, nil]
|
|
388
|
+
# Positive USD cents, or null to remove the limit.
|
|
389
|
+
end
|
|
390
|
+
|
|
359
391
|
class StreamOptions < OpenAI::Internal::Type::BaseModel
|
|
360
392
|
# @!attribute include_obfuscation
|
|
361
393
|
# Whether to include obfuscation padding in events on this connection. Defaults to
|
|
@@ -46,7 +46,20 @@ module OpenAI
|
|
|
46
46
|
# @return [Symbol, OpenAI::Models::Beta::Agents::SessionUpdateParams::Review, nil]
|
|
47
47
|
optional :review, enum: -> { OpenAI::Beta::Agents::SessionUpdateParams::Review }
|
|
48
48
|
|
|
49
|
-
# @!
|
|
49
|
+
# @!attribute spend_control
|
|
50
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
51
|
+
# spend.
|
|
52
|
+
#
|
|
53
|
+
# @return [OpenAI::Models::Beta::Agents::SessionUpdateParams::SpendControl, nil]
|
|
54
|
+
optional(
|
|
55
|
+
:spend_control,
|
|
56
|
+
-> {
|
|
57
|
+
OpenAI::Beta::Agents::SessionUpdateParams::SpendControl
|
|
58
|
+
},
|
|
59
|
+
nil?: true
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# @!method initialize(session_id:, agent: nil, metadata: nil, prompt_cache_options: nil, review: nil, spend_control: nil, request_options: {})
|
|
50
63
|
# @param session_id [String]
|
|
51
64
|
#
|
|
52
65
|
# @param agent [OpenAI::Models::Beta::Agents::SessionUpdateParams::Agent]
|
|
@@ -65,6 +78,10 @@ module OpenAI
|
|
|
65
78
|
# Default action review for new root turns. Existing turns and their subagents
|
|
66
79
|
# keep their review mode.
|
|
67
80
|
#
|
|
81
|
+
# @param spend_control [OpenAI::Models::Beta::Agents::SessionUpdateParams::SpendControl, nil]
|
|
82
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
83
|
+
# spend.
|
|
84
|
+
#
|
|
68
85
|
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
|
|
69
86
|
|
|
70
87
|
class Agent < OpenAI::Internal::Type::BaseModel
|
|
@@ -229,6 +246,21 @@ module OpenAI
|
|
|
229
246
|
# @!method self.values
|
|
230
247
|
# @return [Array<Symbol>]
|
|
231
248
|
end
|
|
249
|
+
|
|
250
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
251
|
+
# @!attribute limit
|
|
252
|
+
# Positive USD cents, or null to remove the limit.
|
|
253
|
+
#
|
|
254
|
+
# @return [Integer, nil]
|
|
255
|
+
required :limit, Integer, nil?: true
|
|
256
|
+
|
|
257
|
+
# @!method initialize(limit:)
|
|
258
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
259
|
+
# spend.
|
|
260
|
+
#
|
|
261
|
+
# @param limit [Integer, nil]
|
|
262
|
+
# Positive USD cents, or null to remove the limit.
|
|
263
|
+
end
|
|
232
264
|
end
|
|
233
265
|
end
|
|
234
266
|
end
|
|
@@ -37,6 +37,9 @@ module OpenAI
|
|
|
37
37
|
# The model reached its output token limit before finishing the response.
|
|
38
38
|
MAX_OUTPUT_TOKENS = :max_output_tokens
|
|
39
39
|
|
|
40
|
+
# The session has reached its usage budget.
|
|
41
|
+
SESSION_BUDGET_EXCEEDED = :session_budget_exceeded
|
|
42
|
+
|
|
40
43
|
# The organization has reached a usage, plan, or billing limit.
|
|
41
44
|
USAGE_LIMIT_EXCEEDED = :usage_limit_exceeded
|
|
42
45
|
|
|
@@ -61,7 +61,7 @@ module OpenAI
|
|
|
61
61
|
#
|
|
62
62
|
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
63
63
|
#
|
|
64
|
-
# @return [OpenAI::Internal::Stream<OpenAI::Models::Beta::AgentSessionErrorEvent, OpenAI::Models::Beta::AgentSessionEnvironmentReadyEvent, OpenAI::Models::Beta::AgentSessionEnvironmentSuspendedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentExpiredEvent, OpenAI::Models::Beta::AgentSessionEnvironmentResetEvent, OpenAI::Models::Beta::AgentOutputCommandExecutionOutputDeltaEvent, OpenAI::Models::Beta::AgentSessionCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnInProgressEvent, OpenAI::Models::Beta::AgentSessionTurnCompletedEvent, OpenAI::Models::Beta::AgentSessionTurnFailedEvent, OpenAI::Models::Beta::AgentSessionTurnCancelledEvent, OpenAI::Models::Beta::AgentSessionTurnItemAddedEvent, OpenAI::Models::Beta::AgentSessionIdleEvent, OpenAI::Models::Beta::AgentSessionInProgressEvent, OpenAI::Models::Beta::AgentSessionRequiresActionEvent, OpenAI::Models::Beta::AgentSessionFailedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentPendingEvent, OpenAI::Models::Beta::AgentSessionEnvironmentConnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentDisconnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentFailedEvent, OpenAI::Models::Beta::AgentSessionSubagentCreatedEvent, OpenAI::Models::Beta::AgentSessionSubagentActiveEvent, OpenAI::Models::Beta::AgentSessionSubagentClosedEvent, OpenAI::Models::Beta::AgentSessionTurnItemDoneEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDoneEvent>]
|
|
64
|
+
# @return [OpenAI::Internal::Stream<OpenAI::Models::Beta::AgentSessionErrorEvent, OpenAI::Models::Beta::AgentSessionEnvironmentReadyEvent, OpenAI::Models::Beta::AgentSessionEnvironmentSuspendedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentExpiredEvent, OpenAI::Models::Beta::AgentSessionEnvironmentResetEvent, OpenAI::Models::Beta::AgentOutputCommandExecutionOutputDeltaEvent, OpenAI::Models::Beta::AgentSessionCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnCreatedEvent, OpenAI::Models::Beta::AgentSessionTurnInProgressEvent, OpenAI::Models::Beta::AgentSessionTurnCompletedEvent, OpenAI::Models::Beta::AgentSessionTurnFailedEvent, OpenAI::Models::Beta::AgentSessionTurnCancelledEvent, OpenAI::Models::Beta::AgentSessionTurnItemAddedEvent, OpenAI::Models::Beta::AgentSessionIdleEvent, OpenAI::Models::Beta::AgentSessionBudgetReachedEvent, OpenAI::Models::Beta::AgentSessionInProgressEvent, OpenAI::Models::Beta::AgentSessionRequiresActionEvent, OpenAI::Models::Beta::AgentSessionFailedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentPendingEvent, OpenAI::Models::Beta::AgentSessionEnvironmentConnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentDisconnectedEvent, OpenAI::Models::Beta::AgentSessionEnvironmentFailedEvent, OpenAI::Models::Beta::AgentSessionSubagentCreatedEvent, OpenAI::Models::Beta::AgentSessionSubagentActiveEvent, OpenAI::Models::Beta::AgentSessionSubagentClosedEvent, OpenAI::Models::Beta::AgentSessionTurnItemDoneEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnContentPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnOutputTextDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartAddedEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryPartDoneEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDeltaEvent, OpenAI::Models::Beta::AgentSessionTurnReasoningSummaryTextDoneEvent>]
|
|
65
65
|
#
|
|
66
66
|
# @see OpenAI::Models::Beta::Agents::Sessions::EventStreamParams
|
|
67
67
|
def stream_streaming(session_id, params = {})
|
|
@@ -32,7 +32,7 @@ module OpenAI
|
|
|
32
32
|
# the session or streams its events when stream is true. See
|
|
33
33
|
# [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
|
|
34
34
|
#
|
|
35
|
-
# @overload create(environment:, agent: nil, agent_id: nil, input: nil, metadata: nil, prompt_cache_options: nil, review: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
35
|
+
# @overload create(environment:, agent: nil, agent_id: nil, input: nil, metadata: nil, prompt_cache_options: nil, review: nil, spend_control: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
36
36
|
#
|
|
37
37
|
# @param environment [OpenAI::Models::Beta::EnvironmentParam::None, OpenAI::Models::Beta::EnvironmentParam::OpenAIHosted, OpenAI::Models::Beta::EnvironmentParam::SelfHosted]
|
|
38
38
|
# An inline execution environment or a reference to an environment template.
|
|
@@ -62,6 +62,10 @@ module OpenAI
|
|
|
62
62
|
# @param review [Symbol, OpenAI::Models::Beta::Agents::SessionCreateParams::Review]
|
|
63
63
|
# Action review mode. Omit to use none.
|
|
64
64
|
#
|
|
65
|
+
# @param spend_control [OpenAI::Models::Beta::Agents::SessionCreateParams::SpendControl, nil]
|
|
66
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
67
|
+
# session.
|
|
68
|
+
#
|
|
65
69
|
# @param stream_options [OpenAI::Models::Beta::Agents::SessionCreateParams::StreamOptions]
|
|
66
70
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
67
71
|
#
|
|
@@ -98,7 +102,7 @@ module OpenAI
|
|
|
98
102
|
# the session or streams its events when stream is true. See
|
|
99
103
|
# [running sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions).
|
|
100
104
|
#
|
|
101
|
-
# @overload create_streaming(environment:, agent: nil, agent_id: nil, input: nil, output_type: nil, tool_handlers: {}, metadata: nil, prompt_cache_options: nil, review: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
105
|
+
# @overload create_streaming(environment:, agent: nil, agent_id: nil, input: nil, output_type: nil, tool_handlers: {}, metadata: nil, prompt_cache_options: nil, review: nil, spend_control: nil, stream_options: nil, vault_ids: nil, request_options: {})
|
|
102
106
|
#
|
|
103
107
|
# @param environment [OpenAI::Models::Beta::EnvironmentParam::None, OpenAI::Models::Beta::EnvironmentParam::OpenAIHosted, OpenAI::Models::Beta::EnvironmentParam::SelfHosted]
|
|
104
108
|
# An inline execution environment or a reference to an environment template.
|
|
@@ -128,6 +132,10 @@ module OpenAI
|
|
|
128
132
|
# @param review [Symbol, OpenAI::Models::Beta::Agents::SessionCreateParams::Review]
|
|
129
133
|
# Action review mode. Omit to use none.
|
|
130
134
|
#
|
|
135
|
+
# @param spend_control [OpenAI::Models::Beta::Agents::SessionCreateParams::SpendControl, nil]
|
|
136
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
137
|
+
# session.
|
|
138
|
+
#
|
|
131
139
|
# @param stream_options [OpenAI::Models::Beta::Agents::SessionCreateParams::StreamOptions]
|
|
132
140
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
133
141
|
#
|
|
@@ -206,7 +214,7 @@ module OpenAI
|
|
|
206
214
|
# fields are unchanged. See
|
|
207
215
|
# [managing sessions](https://developers.openai.com/api/docs/guides/agents-api/sessions/manage).
|
|
208
216
|
#
|
|
209
|
-
# @overload update(session_id, agent: nil, metadata: nil, prompt_cache_options: nil, review: nil, request_options: {})
|
|
217
|
+
# @overload update(session_id, agent: nil, metadata: nil, prompt_cache_options: nil, review: nil, spend_control: nil, request_options: {})
|
|
210
218
|
#
|
|
211
219
|
# @param session_id [String]
|
|
212
220
|
# The ID of the session.
|
|
@@ -227,6 +235,10 @@ module OpenAI
|
|
|
227
235
|
# Default action review for new root turns. Existing turns and their subagents
|
|
228
236
|
# keep their review mode.
|
|
229
237
|
#
|
|
238
|
+
# @param spend_control [OpenAI::Models::Beta::Agents::SessionUpdateParams::SpendControl, nil]
|
|
239
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
240
|
+
# spend.
|
|
241
|
+
#
|
|
230
242
|
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
231
243
|
#
|
|
232
244
|
# @return [OpenAI::Models::Beta::AgentSession]
|
data/lib/openai/version.rb
CHANGED
data/lib/openai.rb
CHANGED
|
@@ -624,6 +624,7 @@ require_relative "openai/models/beta/agents/vault_update_params"
|
|
|
624
624
|
require_relative "openai/models/beta/agent_send_subagent_input_call_item"
|
|
625
625
|
require_relative "openai/models/beta/agent_session"
|
|
626
626
|
require_relative "openai/models/beta/agent_session_assistant_message"
|
|
627
|
+
require_relative "openai/models/beta/agent_session_budget_reached_event"
|
|
627
628
|
require_relative "openai/models/beta/agent_session_created_event"
|
|
628
629
|
require_relative "openai/models/beta/agent_session_deleted"
|
|
629
630
|
require_relative "openai/models/beta/agent_session_environment_connected_event"
|
|
@@ -53,6 +53,14 @@ module OpenAI
|
|
|
53
53
|
sig { returns(T::Array[OpenAI::Beta::AgentSession::RequiredAction::Variants]) }
|
|
54
54
|
attr_accessor :required_actions
|
|
55
55
|
|
|
56
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
57
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
58
|
+
sig { returns(OpenAI::Beta::AgentSession::SpendControl) }
|
|
59
|
+
attr_reader :spend_control
|
|
60
|
+
|
|
61
|
+
sig { params(spend_control: OpenAI::Beta::AgentSession::SpendControl::OrHash).void }
|
|
62
|
+
attr_writer :spend_control
|
|
63
|
+
|
|
56
64
|
# The current status of the session.
|
|
57
65
|
sig { returns(OpenAI::Beta::AgentSession::Status::TaggedSymbol) }
|
|
58
66
|
attr_accessor :status
|
|
@@ -115,6 +123,8 @@ module OpenAI
|
|
|
115
123
|
)
|
|
116
124
|
],
|
|
117
125
|
|
|
126
|
+
spend_control: OpenAI::Beta::AgentSession::SpendControl::OrHash,
|
|
127
|
+
|
|
118
128
|
status: OpenAI::Beta::AgentSession::Status::OrSymbol,
|
|
119
129
|
|
|
120
130
|
usage: T.nilable(OpenAI::Beta::TokenUsage::OrHash),
|
|
@@ -155,6 +165,10 @@ module OpenAI
|
|
|
155
165
|
# Actions that must be completed before the session can continue.
|
|
156
166
|
required_actions:,
|
|
157
167
|
|
|
168
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
169
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
170
|
+
spend_control:,
|
|
171
|
+
|
|
158
172
|
# The current status of the session.
|
|
159
173
|
status:,
|
|
160
174
|
|
|
@@ -190,6 +204,7 @@ module OpenAI
|
|
|
190
204
|
metadata: T::Hash[Symbol, String],
|
|
191
205
|
object: Symbol,
|
|
192
206
|
required_actions: T::Array[OpenAI::Beta::AgentSession::RequiredAction::Variants],
|
|
207
|
+
spend_control: OpenAI::Beta::AgentSession::SpendControl,
|
|
193
208
|
status: OpenAI::Beta::AgentSession::Status::TaggedSymbol,
|
|
194
209
|
usage: T.nilable(OpenAI::Beta::TokenUsage),
|
|
195
210
|
vault_ids: T::Array[String],
|
|
@@ -1114,6 +1129,54 @@ module OpenAI
|
|
|
1114
1129
|
|
|
1115
1130
|
end
|
|
1116
1131
|
|
|
1132
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
1133
|
+
OrHash = T.type_alias do
|
|
1134
|
+
T.any(
|
|
1135
|
+
OpenAI::Beta::AgentSession::SpendControl,
|
|
1136
|
+
OpenAI::Internal::AnyHash
|
|
1137
|
+
)
|
|
1138
|
+
end
|
|
1139
|
+
|
|
1140
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
1141
|
+
sig { returns(T.nilable(Integer)) }
|
|
1142
|
+
attr_accessor :consumed
|
|
1143
|
+
|
|
1144
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
1145
|
+
sig { returns(T.nilable(Integer)) }
|
|
1146
|
+
attr_accessor :limit
|
|
1147
|
+
|
|
1148
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
1149
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
1150
|
+
sig do
|
|
1151
|
+
params(
|
|
1152
|
+
|
|
1153
|
+
consumed: T.nilable(Integer),
|
|
1154
|
+
|
|
1155
|
+
limit: T.nilable(Integer)
|
|
1156
|
+
)
|
|
1157
|
+
.returns(T.attached_class)
|
|
1158
|
+
end
|
|
1159
|
+
def self.new(
|
|
1160
|
+
|
|
1161
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
1162
|
+
consumed:,
|
|
1163
|
+
|
|
1164
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
1165
|
+
|
|
1166
|
+
limit:
|
|
1167
|
+
)
|
|
1168
|
+
end
|
|
1169
|
+
|
|
1170
|
+
sig do
|
|
1171
|
+
override.returns(
|
|
1172
|
+
{consumed: T.nilable(Integer), limit: T.nilable(Integer)}
|
|
1173
|
+
)
|
|
1174
|
+
end
|
|
1175
|
+
def to_hash
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
end
|
|
1179
|
+
|
|
1117
1180
|
# The current status of the session.
|
|
1118
1181
|
module Status
|
|
1119
1182
|
extend OpenAI::Internal::Type::Enum
|
|
@@ -1133,6 +1196,9 @@ module OpenAI
|
|
|
1133
1196
|
# The session failed.
|
|
1134
1197
|
FAILED = T.let(:failed, OpenAI::Beta::AgentSession::Status::TaggedSymbol)
|
|
1135
1198
|
|
|
1199
|
+
# The session is paused because its spending limit was reached.
|
|
1200
|
+
BUDGET_REACHED = T.let(:budget_reached, OpenAI::Beta::AgentSession::Status::TaggedSymbol)
|
|
1201
|
+
|
|
1136
1202
|
sig { override.returns(T::Array[OpenAI::Beta::AgentSession::Status::TaggedSymbol]) }
|
|
1137
1203
|
def self.values
|
|
1138
1204
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module OpenAI
|
|
4
|
+
module Models
|
|
5
|
+
|
|
6
|
+
module Beta
|
|
7
|
+
|
|
8
|
+
class AgentSessionBudgetReachedEvent < OpenAI::Internal::Type::BaseModel
|
|
9
|
+
|
|
10
|
+
OrHash = T.type_alias do
|
|
11
|
+
T.any(
|
|
12
|
+
OpenAI::Beta::AgentSessionBudgetReachedEvent,
|
|
13
|
+
OpenAI::Internal::AnyHash
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# The unique ID of the event.
|
|
18
|
+
sig { returns(String) }
|
|
19
|
+
attr_accessor :event_id
|
|
20
|
+
|
|
21
|
+
# The paused session.
|
|
22
|
+
sig { returns(OpenAI::Beta::AgentSession) }
|
|
23
|
+
attr_reader :session
|
|
24
|
+
|
|
25
|
+
sig { params(session: OpenAI::Beta::AgentSession::OrHash).void }
|
|
26
|
+
attr_writer :session
|
|
27
|
+
|
|
28
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
29
|
+
sig { returns(Symbol) }
|
|
30
|
+
attr_accessor :type
|
|
31
|
+
|
|
32
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
33
|
+
sig { returns(T.nilable(String)) }
|
|
34
|
+
attr_reader :obfuscation
|
|
35
|
+
|
|
36
|
+
sig { params(obfuscation: String).void }
|
|
37
|
+
attr_writer :obfuscation
|
|
38
|
+
|
|
39
|
+
# Emitted when a session pauses because its spending limit was reached.
|
|
40
|
+
sig do
|
|
41
|
+
params(
|
|
42
|
+
|
|
43
|
+
event_id: String,
|
|
44
|
+
|
|
45
|
+
session: OpenAI::Beta::AgentSession::OrHash,
|
|
46
|
+
|
|
47
|
+
obfuscation: String,
|
|
48
|
+
|
|
49
|
+
type: Symbol
|
|
50
|
+
)
|
|
51
|
+
.returns(T.attached_class)
|
|
52
|
+
end
|
|
53
|
+
def self.new(
|
|
54
|
+
|
|
55
|
+
# The unique ID of the event.
|
|
56
|
+
event_id:,
|
|
57
|
+
|
|
58
|
+
# The paused session.
|
|
59
|
+
session:,
|
|
60
|
+
|
|
61
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
62
|
+
obfuscation: nil,
|
|
63
|
+
|
|
64
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
65
|
+
|
|
66
|
+
type: :"agent.session.budget_reached"
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
sig do
|
|
71
|
+
override.returns(
|
|
72
|
+
{event_id: String, session: OpenAI::Beta::AgentSession, type: Symbol, obfuscation: String}
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
def to_hash
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -25,6 +25,7 @@ module OpenAI
|
|
|
25
25
|
OpenAI::Beta::AgentSessionTurnCancelledEvent,
|
|
26
26
|
OpenAI::Beta::AgentSessionTurnItemAddedEvent,
|
|
27
27
|
OpenAI::Beta::AgentSessionIdleEvent,
|
|
28
|
+
OpenAI::Beta::AgentSessionBudgetReachedEvent,
|
|
28
29
|
OpenAI::Beta::AgentSessionInProgressEvent,
|
|
29
30
|
OpenAI::Beta::AgentSessionRequiresActionEvent,
|
|
30
31
|
OpenAI::Beta::AgentSessionFailedEvent,
|
|
@@ -79,6 +79,16 @@ module OpenAI
|
|
|
79
79
|
sig { params(review: OpenAI::Beta::Agents::SessionCreateParams::Review::OrSymbol).void }
|
|
80
80
|
attr_writer :review
|
|
81
81
|
|
|
82
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
83
|
+
# session.
|
|
84
|
+
sig { returns(T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl)) }
|
|
85
|
+
attr_reader :spend_control
|
|
86
|
+
|
|
87
|
+
sig {
|
|
88
|
+
params(spend_control: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl::OrHash)).void
|
|
89
|
+
}
|
|
90
|
+
attr_writer :spend_control
|
|
91
|
+
|
|
82
92
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
83
93
|
sig { returns(T.nilable(OpenAI::Beta::Agents::SessionCreateParams::StreamOptions)) }
|
|
84
94
|
attr_reader :stream_options
|
|
@@ -111,6 +121,8 @@ module OpenAI
|
|
|
111
121
|
|
|
112
122
|
review: OpenAI::Beta::Agents::SessionCreateParams::Review::OrSymbol,
|
|
113
123
|
|
|
124
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl::OrHash),
|
|
125
|
+
|
|
114
126
|
stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions::OrHash,
|
|
115
127
|
|
|
116
128
|
vault_ids: T.nilable(T::Array[String]),
|
|
@@ -149,6 +161,10 @@ module OpenAI
|
|
|
149
161
|
# Action review mode. Omit to use none.
|
|
150
162
|
review: nil,
|
|
151
163
|
|
|
164
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
165
|
+
# session.
|
|
166
|
+
spend_control: nil,
|
|
167
|
+
|
|
152
168
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
153
169
|
stream_options: nil,
|
|
154
170
|
|
|
@@ -173,6 +189,7 @@ module OpenAI
|
|
|
173
189
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
174
190
|
prompt_cache_options: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions),
|
|
175
191
|
review: OpenAI::Beta::Agents::SessionCreateParams::Review::OrSymbol,
|
|
192
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl),
|
|
176
193
|
stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
177
194
|
vault_ids: T.nilable(T::Array[String]),
|
|
178
195
|
request_options: OpenAI::RequestOptions
|
|
@@ -595,6 +612,45 @@ module OpenAI
|
|
|
595
612
|
end
|
|
596
613
|
end
|
|
597
614
|
|
|
615
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
616
|
+
OrHash = T.type_alias do
|
|
617
|
+
T.any(
|
|
618
|
+
OpenAI::Beta::Agents::SessionCreateParams::SpendControl,
|
|
619
|
+
OpenAI::Internal::AnyHash
|
|
620
|
+
)
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
# Positive USD cents, or null to remove the limit.
|
|
624
|
+
sig { returns(T.nilable(Integer)) }
|
|
625
|
+
attr_accessor :limit
|
|
626
|
+
|
|
627
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
628
|
+
# session.
|
|
629
|
+
sig do
|
|
630
|
+
params(
|
|
631
|
+
|
|
632
|
+
limit: T.nilable(Integer)
|
|
633
|
+
)
|
|
634
|
+
.returns(T.attached_class)
|
|
635
|
+
end
|
|
636
|
+
def self.new(
|
|
637
|
+
|
|
638
|
+
# Positive USD cents, or null to remove the limit.
|
|
639
|
+
|
|
640
|
+
limit:
|
|
641
|
+
)
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
sig do
|
|
645
|
+
override.returns(
|
|
646
|
+
{limit: T.nilable(Integer)}
|
|
647
|
+
)
|
|
648
|
+
end
|
|
649
|
+
def to_hash
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
end
|
|
653
|
+
|
|
598
654
|
class StreamOptions < OpenAI::Internal::Type::BaseModel
|
|
599
655
|
OrHash = T.type_alias do
|
|
600
656
|
T.any(
|
|
@@ -56,6 +56,16 @@ module OpenAI
|
|
|
56
56
|
sig { params(review: OpenAI::Beta::Agents::SessionUpdateParams::Review::OrSymbol).void }
|
|
57
57
|
attr_writer :review
|
|
58
58
|
|
|
59
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
60
|
+
# spend.
|
|
61
|
+
sig { returns(T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::SpendControl)) }
|
|
62
|
+
attr_reader :spend_control
|
|
63
|
+
|
|
64
|
+
sig {
|
|
65
|
+
params(spend_control: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::SpendControl::OrHash)).void
|
|
66
|
+
}
|
|
67
|
+
attr_writer :spend_control
|
|
68
|
+
|
|
59
69
|
sig do
|
|
60
70
|
params(
|
|
61
71
|
|
|
@@ -69,6 +79,8 @@ module OpenAI
|
|
|
69
79
|
|
|
70
80
|
review: OpenAI::Beta::Agents::SessionUpdateParams::Review::OrSymbol,
|
|
71
81
|
|
|
82
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::SpendControl::OrHash),
|
|
83
|
+
|
|
72
84
|
request_options: OpenAI::RequestOptions::OrHash
|
|
73
85
|
)
|
|
74
86
|
.returns(T.attached_class)
|
|
@@ -93,6 +105,10 @@ module OpenAI
|
|
|
93
105
|
# keep their review mode.
|
|
94
106
|
review: nil,
|
|
95
107
|
|
|
108
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
109
|
+
# spend.
|
|
110
|
+
spend_control: nil,
|
|
111
|
+
|
|
96
112
|
request_options: {}
|
|
97
113
|
)
|
|
98
114
|
end
|
|
@@ -105,6 +121,7 @@ module OpenAI
|
|
|
105
121
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
106
122
|
prompt_cache_options: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions),
|
|
107
123
|
review: OpenAI::Beta::Agents::SessionUpdateParams::Review::OrSymbol,
|
|
124
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::SpendControl),
|
|
108
125
|
request_options: OpenAI::RequestOptions
|
|
109
126
|
}
|
|
110
127
|
)
|
|
@@ -415,6 +432,45 @@ module OpenAI
|
|
|
415
432
|
end
|
|
416
433
|
end
|
|
417
434
|
|
|
435
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
436
|
+
OrHash = T.type_alias do
|
|
437
|
+
T.any(
|
|
438
|
+
OpenAI::Beta::Agents::SessionUpdateParams::SpendControl,
|
|
439
|
+
OpenAI::Internal::AnyHash
|
|
440
|
+
)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
# Positive USD cents, or null to remove the limit.
|
|
444
|
+
sig { returns(T.nilable(Integer)) }
|
|
445
|
+
attr_accessor :limit
|
|
446
|
+
|
|
447
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
448
|
+
# spend.
|
|
449
|
+
sig do
|
|
450
|
+
params(
|
|
451
|
+
|
|
452
|
+
limit: T.nilable(Integer)
|
|
453
|
+
)
|
|
454
|
+
.returns(T.attached_class)
|
|
455
|
+
end
|
|
456
|
+
def self.new(
|
|
457
|
+
|
|
458
|
+
# Positive USD cents, or null to remove the limit.
|
|
459
|
+
|
|
460
|
+
limit:
|
|
461
|
+
)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
sig do
|
|
465
|
+
override.returns(
|
|
466
|
+
{limit: T.nilable(Integer)}
|
|
467
|
+
)
|
|
468
|
+
end
|
|
469
|
+
def to_hash
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
end
|
|
473
|
+
|
|
418
474
|
end
|
|
419
475
|
|
|
420
476
|
end
|
|
@@ -64,6 +64,9 @@ module OpenAI
|
|
|
64
64
|
# The model reached its output token limit before finishing the response.
|
|
65
65
|
MAX_OUTPUT_TOKENS = T.let(:max_output_tokens, OpenAI::Beta::SessionTurnError::Code::TaggedSymbol)
|
|
66
66
|
|
|
67
|
+
# The session has reached its usage budget.
|
|
68
|
+
SESSION_BUDGET_EXCEEDED = T.let(:session_budget_exceeded, OpenAI::Beta::SessionTurnError::Code::TaggedSymbol)
|
|
69
|
+
|
|
67
70
|
# The organization has reached a usage, plan, or billing limit.
|
|
68
71
|
USAGE_LIMIT_EXCEEDED = T.let(:usage_limit_exceeded, OpenAI::Beta::SessionTurnError::Code::TaggedSymbol)
|
|
69
72
|
|
|
@@ -46,6 +46,7 @@ module OpenAI
|
|
|
46
46
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
47
47
|
prompt_cache_options: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions::OrHash),
|
|
48
48
|
review: OpenAI::Beta::Agents::SessionCreateParams::Review::OrSymbol,
|
|
49
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl::OrHash),
|
|
49
50
|
stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions::OrHash,
|
|
50
51
|
vault_ids: T.nilable(T::Array[String]),
|
|
51
52
|
stream: T.noreturn,
|
|
@@ -75,6 +76,9 @@ module OpenAI
|
|
|
75
76
|
prompt_cache_options: nil,
|
|
76
77
|
# Action review mode. Omit to use none.
|
|
77
78
|
review: nil,
|
|
79
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
80
|
+
# session.
|
|
81
|
+
spend_control: nil,
|
|
78
82
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
79
83
|
stream_options: nil,
|
|
80
84
|
# The IDs of vaults made available to the session.
|
|
@@ -107,6 +111,7 @@ module OpenAI
|
|
|
107
111
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
108
112
|
prompt_cache_options: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions::OrHash),
|
|
109
113
|
review: OpenAI::Beta::Agents::SessionCreateParams::Review::OrSymbol,
|
|
114
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionCreateParams::SpendControl::OrHash),
|
|
110
115
|
stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions::OrHash,
|
|
111
116
|
vault_ids: T.nilable(T::Array[String]),
|
|
112
117
|
stream: T.noreturn,
|
|
@@ -138,6 +143,9 @@ module OpenAI
|
|
|
138
143
|
prompt_cache_options: nil,
|
|
139
144
|
# Action review mode. Omit to use none.
|
|
140
145
|
review: nil,
|
|
146
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
147
|
+
# session.
|
|
148
|
+
spend_control: nil,
|
|
141
149
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
142
150
|
stream_options: nil,
|
|
143
151
|
# The IDs of vaults made available to the session.
|
|
@@ -174,6 +182,7 @@ module OpenAI
|
|
|
174
182
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
|
175
183
|
prompt_cache_options: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions::OrHash),
|
|
176
184
|
review: OpenAI::Beta::Agents::SessionUpdateParams::Review::OrSymbol,
|
|
185
|
+
spend_control: T.nilable(OpenAI::Beta::Agents::SessionUpdateParams::SpendControl::OrHash),
|
|
177
186
|
request_options: OpenAI::RequestOptions::OrHash
|
|
178
187
|
)
|
|
179
188
|
.returns(OpenAI::Beta::AgentSession)
|
|
@@ -193,6 +202,9 @@ module OpenAI
|
|
|
193
202
|
# Default action review for new root turns. Existing turns and their subagents
|
|
194
203
|
# keep their review mode.
|
|
195
204
|
review: nil,
|
|
205
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
206
|
+
# spend.
|
|
207
|
+
spend_control: nil,
|
|
196
208
|
request_options: {}
|
|
197
209
|
)
|
|
198
210
|
end
|
|
@@ -12,6 +12,7 @@ module OpenAI
|
|
|
12
12
|
metadata: ::Hash[Symbol, String],
|
|
13
13
|
?object: :"agent.session",
|
|
14
14
|
required_actions: ::Array[OpenAI::Models::Beta::AgentSession::required_action],
|
|
15
|
+
spend_control: OpenAI::Beta::AgentSession::SpendControl,
|
|
15
16
|
status: OpenAI::Models::Beta::AgentSession::status,
|
|
16
17
|
usage: OpenAI::Beta::TokenUsage?,
|
|
17
18
|
vault_ids: ::Array[String],
|
|
@@ -47,6 +48,10 @@ module OpenAI
|
|
|
47
48
|
# Actions that must be completed before the session can continue.
|
|
48
49
|
attr_accessor required_actions: ::Array[OpenAI::Models::Beta::AgentSession::required_action]
|
|
49
50
|
|
|
51
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
52
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
53
|
+
attr_accessor spend_control: OpenAI::Beta::AgentSession::SpendControl
|
|
54
|
+
|
|
50
55
|
# The current status of the session.
|
|
51
56
|
attr_accessor status: OpenAI::Models::Beta::AgentSession::status
|
|
52
57
|
|
|
@@ -86,6 +91,9 @@ module OpenAI
|
|
|
86
91
|
# Custom string key-value pairs attached to the session.
|
|
87
92
|
# @param required_actions
|
|
88
93
|
# Actions that must be completed before the session can continue.
|
|
94
|
+
# @param spend_control
|
|
95
|
+
# Spending limit and best-effort consumption, in USD cents. The limit is null for
|
|
96
|
+
# an unlimited session. Consumption is null when unavailable.
|
|
89
97
|
# @param status
|
|
90
98
|
# The current status of the session.
|
|
91
99
|
# @param usage
|
|
@@ -109,6 +117,7 @@ module OpenAI
|
|
|
109
117
|
last_active_at: Integer,
|
|
110
118
|
metadata: ::Hash[Symbol, String],
|
|
111
119
|
required_actions: ::Array[OpenAI::Models::Beta::AgentSession::required_action],
|
|
120
|
+
spend_control: OpenAI::Beta::AgentSession::SpendControl,
|
|
112
121
|
status: OpenAI::Models::Beta::AgentSession::status,
|
|
113
122
|
usage: OpenAI::Beta::TokenUsage?,
|
|
114
123
|
vault_ids: ::Array[String],
|
|
@@ -127,6 +136,7 @@ module OpenAI
|
|
|
127
136
|
metadata: ::Hash[Symbol, String],
|
|
128
137
|
?object: :"agent.session",
|
|
129
138
|
required_actions: ::Array[OpenAI::Models::Beta::AgentSession::required_action],
|
|
139
|
+
spend_control: OpenAI::Beta::AgentSession::SpendControl,
|
|
130
140
|
status: OpenAI::Models::Beta::AgentSession::status,
|
|
131
141
|
usage: OpenAI::Beta::TokenUsage?,
|
|
132
142
|
vault_ids: ::Array[String],
|
|
@@ -680,7 +690,26 @@ module OpenAI
|
|
|
680
690
|
def self?.variants: -> ::Array[OpenAI::Models::Beta::AgentSession::required_action]
|
|
681
691
|
end
|
|
682
692
|
|
|
683
|
-
type
|
|
693
|
+
type spend_control = { consumed: Integer?, limit: Integer? }
|
|
694
|
+
|
|
695
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
696
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
697
|
+
attr_accessor consumed: Integer?
|
|
698
|
+
|
|
699
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
700
|
+
attr_accessor limit: Integer?
|
|
701
|
+
|
|
702
|
+
# @param consumed
|
|
703
|
+
# Best-effort recorded spend floored to whole USD cents, or null when unavailable.
|
|
704
|
+
# @param limit
|
|
705
|
+
# The configured positive limit in USD cents, or null when unlimited.
|
|
706
|
+
def initialize: (consumed: Integer?, limit: Integer?) -> void
|
|
707
|
+
|
|
708
|
+
def to_hash: -> { consumed: Integer?, limit: Integer? }
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
type status =
|
|
712
|
+
:idle | :in_progress | :requires_action | :failed | :budget_reached
|
|
684
713
|
|
|
685
714
|
module Status
|
|
686
715
|
extend OpenAI::Internal::Type::Enum
|
|
@@ -697,6 +726,9 @@ module OpenAI
|
|
|
697
726
|
# The session failed.
|
|
698
727
|
FAILED: :failed
|
|
699
728
|
|
|
729
|
+
# The session is paused because its spending limit was reached.
|
|
730
|
+
BUDGET_REACHED: :budget_reached
|
|
731
|
+
|
|
700
732
|
def self?.values: -> ::Array[OpenAI::Models::Beta::AgentSession::status]
|
|
701
733
|
end
|
|
702
734
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module OpenAI
|
|
2
|
+
module Models
|
|
3
|
+
module Beta
|
|
4
|
+
type agent_session_budget_reached_event =
|
|
5
|
+
{
|
|
6
|
+
event_id: String,
|
|
7
|
+
session: OpenAI::Beta::AgentSession,
|
|
8
|
+
?type: :"agent.session.budget_reached",
|
|
9
|
+
?obfuscation: String
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class AgentSessionBudgetReachedEvent < OpenAI::Internal::Type::BaseModel
|
|
13
|
+
# The unique ID of the event.
|
|
14
|
+
attr_accessor event_id: String
|
|
15
|
+
|
|
16
|
+
# The paused session.
|
|
17
|
+
attr_accessor session: OpenAI::Beta::AgentSession
|
|
18
|
+
|
|
19
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
20
|
+
attr_accessor type: :"agent.session.budget_reached"
|
|
21
|
+
|
|
22
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
23
|
+
attr_reader obfuscation: String?
|
|
24
|
+
|
|
25
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
26
|
+
def obfuscation=: (String) -> String
|
|
27
|
+
|
|
28
|
+
# @param event_id
|
|
29
|
+
# The unique ID of the event.
|
|
30
|
+
# @param session
|
|
31
|
+
# The paused session.
|
|
32
|
+
# @param obfuscation
|
|
33
|
+
# Random alphanumeric padding. Present when stream obfuscation is enabled.
|
|
34
|
+
# @param type
|
|
35
|
+
# The type of the object. Always `agent.session.budget_reached`.
|
|
36
|
+
def initialize: (
|
|
37
|
+
event_id: String,
|
|
38
|
+
session: OpenAI::Beta::AgentSession,
|
|
39
|
+
?obfuscation: String,
|
|
40
|
+
?type: :"agent.session.budget_reached"
|
|
41
|
+
) -> void
|
|
42
|
+
|
|
43
|
+
def to_hash: -> {
|
|
44
|
+
event_id: String,
|
|
45
|
+
session: OpenAI::Beta::AgentSession,
|
|
46
|
+
?type: :"agent.session.budget_reached",
|
|
47
|
+
?obfuscation: String
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -16,6 +16,7 @@ module OpenAI
|
|
|
16
16
|
| OpenAI::Beta::AgentSessionTurnCancelledEvent
|
|
17
17
|
| OpenAI::Beta::AgentSessionTurnItemAddedEvent
|
|
18
18
|
| OpenAI::Beta::AgentSessionIdleEvent
|
|
19
|
+
| OpenAI::Beta::AgentSessionBudgetReachedEvent
|
|
19
20
|
| OpenAI::Beta::AgentSessionInProgressEvent
|
|
20
21
|
| OpenAI::Beta::AgentSessionRequiresActionEvent
|
|
21
22
|
| OpenAI::Beta::AgentSessionFailedEvent
|
|
@@ -11,6 +11,7 @@ module OpenAI
|
|
|
11
11
|
?metadata: ::Hash[Symbol, String]?,
|
|
12
12
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions?,
|
|
13
13
|
?review: OpenAI::Models::Beta::Agents::SessionCreateParams::review,
|
|
14
|
+
?spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?,
|
|
14
15
|
?stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
15
16
|
?vault_ids: ::Array[String]?,
|
|
16
17
|
?request_options: OpenAI::request_opts
|
|
@@ -63,6 +64,10 @@ module OpenAI
|
|
|
63
64
|
OpenAI::Models::Beta::Agents::SessionCreateParams::review
|
|
64
65
|
) -> OpenAI::Models::Beta::Agents::SessionCreateParams::review
|
|
65
66
|
|
|
67
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
68
|
+
# session.
|
|
69
|
+
attr_accessor spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?
|
|
70
|
+
|
|
66
71
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
67
72
|
attr_reader stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions?
|
|
68
73
|
|
|
@@ -95,6 +100,9 @@ module OpenAI
|
|
|
95
100
|
# default.
|
|
96
101
|
# @param review
|
|
97
102
|
# Action review mode. Omit to use none.
|
|
103
|
+
# @param spend_control
|
|
104
|
+
# Optional spending limit in USD cents. Omission or null creates an unlimited
|
|
105
|
+
# session.
|
|
98
106
|
# @param stream_options
|
|
99
107
|
# Options for the event stream. Only allowed when `stream` is `true`.
|
|
100
108
|
# @param vault_ids
|
|
@@ -107,6 +115,7 @@ module OpenAI
|
|
|
107
115
|
?metadata: ::Hash[Symbol, String]?,
|
|
108
116
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions?,
|
|
109
117
|
?review: OpenAI::Models::Beta::Agents::SessionCreateParams::review,
|
|
118
|
+
?spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?,
|
|
110
119
|
?stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
111
120
|
?vault_ids: ::Array[String]?,
|
|
112
121
|
?request_options: OpenAI::request_opts
|
|
@@ -120,6 +129,7 @@ module OpenAI
|
|
|
120
129
|
?metadata: ::Hash[Symbol, String]?,
|
|
121
130
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions?,
|
|
122
131
|
?review: OpenAI::Models::Beta::Agents::SessionCreateParams::review,
|
|
132
|
+
?spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?,
|
|
123
133
|
?stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
124
134
|
?vault_ids: ::Array[String]?,
|
|
125
135
|
?request_options: OpenAI::RequestOptions
|
|
@@ -354,6 +364,19 @@ module OpenAI
|
|
|
354
364
|
def self?.values: -> ::Array[OpenAI::Models::Beta::Agents::SessionCreateParams::review]
|
|
355
365
|
end
|
|
356
366
|
|
|
367
|
+
type spend_control = { limit: Integer? }
|
|
368
|
+
|
|
369
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
370
|
+
# Positive USD cents, or null to remove the limit.
|
|
371
|
+
attr_accessor limit: Integer?
|
|
372
|
+
|
|
373
|
+
# @param limit
|
|
374
|
+
# Positive USD cents, or null to remove the limit.
|
|
375
|
+
def initialize: (limit: Integer?) -> void
|
|
376
|
+
|
|
377
|
+
def to_hash: -> { limit: Integer? }
|
|
378
|
+
end
|
|
379
|
+
|
|
357
380
|
type stream_options = { ?include_obfuscation: bool }
|
|
358
381
|
|
|
359
382
|
class StreamOptions < OpenAI::Internal::Type::BaseModel
|
|
@@ -9,6 +9,7 @@ module OpenAI
|
|
|
9
9
|
?metadata: ::Hash[Symbol, String]?,
|
|
10
10
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions?,
|
|
11
11
|
?review: OpenAI::Models::Beta::Agents::SessionUpdateParams::review,
|
|
12
|
+
?spend_control: OpenAI::Beta::Agents::SessionUpdateParams::SpendControl?,
|
|
12
13
|
?request_options: OpenAI::request_opts
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -45,6 +46,10 @@ module OpenAI
|
|
|
45
46
|
OpenAI::Models::Beta::Agents::SessionUpdateParams::review
|
|
46
47
|
) -> OpenAI::Models::Beta::Agents::SessionUpdateParams::review
|
|
47
48
|
|
|
49
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
50
|
+
# spend.
|
|
51
|
+
attr_accessor spend_control: OpenAI::Beta::Agents::SessionUpdateParams::SpendControl?
|
|
52
|
+
|
|
48
53
|
# @param agent
|
|
49
54
|
# Agent settings to update on this session. Omitted fields stay unchanged.
|
|
50
55
|
# @param metadata
|
|
@@ -57,12 +62,16 @@ module OpenAI
|
|
|
57
62
|
# @param review
|
|
58
63
|
# Default action review for new root turns. Existing turns and their subagents
|
|
59
64
|
# keep their review mode.
|
|
65
|
+
# @param spend_control
|
|
66
|
+
# Omit to retain the limit; null or a null limit removes it without resetting
|
|
67
|
+
# spend.
|
|
60
68
|
def initialize: (
|
|
61
69
|
session_id: String,
|
|
62
70
|
?agent: OpenAI::Beta::Agents::SessionUpdateParams::Agent,
|
|
63
71
|
?metadata: ::Hash[Symbol, String]?,
|
|
64
72
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions?,
|
|
65
73
|
?review: OpenAI::Models::Beta::Agents::SessionUpdateParams::review,
|
|
74
|
+
?spend_control: OpenAI::Beta::Agents::SessionUpdateParams::SpendControl?,
|
|
66
75
|
?request_options: OpenAI::request_opts
|
|
67
76
|
) -> void
|
|
68
77
|
|
|
@@ -72,6 +81,7 @@ module OpenAI
|
|
|
72
81
|
?metadata: ::Hash[Symbol, String]?,
|
|
73
82
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions?,
|
|
74
83
|
?review: OpenAI::Models::Beta::Agents::SessionUpdateParams::review,
|
|
84
|
+
?spend_control: OpenAI::Beta::Agents::SessionUpdateParams::SpendControl?,
|
|
75
85
|
?request_options: OpenAI::RequestOptions
|
|
76
86
|
}
|
|
77
87
|
|
|
@@ -244,6 +254,19 @@ module OpenAI
|
|
|
244
254
|
|
|
245
255
|
def self?.values: -> ::Array[OpenAI::Models::Beta::Agents::SessionUpdateParams::review]
|
|
246
256
|
end
|
|
257
|
+
|
|
258
|
+
type spend_control = { limit: Integer? }
|
|
259
|
+
|
|
260
|
+
class SpendControl < OpenAI::Internal::Type::BaseModel
|
|
261
|
+
# Positive USD cents, or null to remove the limit.
|
|
262
|
+
attr_accessor limit: Integer?
|
|
263
|
+
|
|
264
|
+
# @param limit
|
|
265
|
+
# Positive USD cents, or null to remove the limit.
|
|
266
|
+
def initialize: (limit: Integer?) -> void
|
|
267
|
+
|
|
268
|
+
def to_hash: -> { limit: Integer? }
|
|
269
|
+
end
|
|
247
270
|
end
|
|
248
271
|
end
|
|
249
272
|
end
|
|
@@ -28,6 +28,7 @@ module OpenAI
|
|
|
28
28
|
type code =
|
|
29
29
|
:context_length_exceeded
|
|
30
30
|
| :max_output_tokens
|
|
31
|
+
| :session_budget_exceeded
|
|
31
32
|
| :usage_limit_exceeded
|
|
32
33
|
| :project_spend_limit_exceeded
|
|
33
34
|
| :organization_spend_limit_exceeded
|
|
@@ -59,6 +60,9 @@ module OpenAI
|
|
|
59
60
|
# The model reached its output token limit before finishing the response.
|
|
60
61
|
MAX_OUTPUT_TOKENS: :max_output_tokens
|
|
61
62
|
|
|
63
|
+
# The session has reached its usage budget.
|
|
64
|
+
SESSION_BUDGET_EXCEEDED: :session_budget_exceeded
|
|
65
|
+
|
|
62
66
|
# The organization has reached a usage, plan, or billing limit.
|
|
63
67
|
USAGE_LIMIT_EXCEEDED: :usage_limit_exceeded
|
|
64
68
|
|
|
@@ -23,6 +23,7 @@ module OpenAI
|
|
|
23
23
|
?metadata: ::Hash[Symbol, String]?,
|
|
24
24
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions?,
|
|
25
25
|
?review: OpenAI::Models::Beta::Agents::SessionCreateParams::review,
|
|
26
|
+
?spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?,
|
|
26
27
|
?stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
27
28
|
?vault_ids: ::Array[String]?,
|
|
28
29
|
?request_options: OpenAI::request_opts
|
|
@@ -38,6 +39,7 @@ module OpenAI
|
|
|
38
39
|
?metadata: ::Hash[Symbol, String]?,
|
|
39
40
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionCreateParams::PromptCacheOptions?,
|
|
40
41
|
?review: OpenAI::Models::Beta::Agents::SessionCreateParams::review,
|
|
42
|
+
?spend_control: OpenAI::Beta::Agents::SessionCreateParams::SpendControl?,
|
|
41
43
|
?stream_options: OpenAI::Beta::Agents::SessionCreateParams::StreamOptions,
|
|
42
44
|
?vault_ids: ::Array[String]?,
|
|
43
45
|
?request_options: OpenAI::request_opts
|
|
@@ -54,6 +56,7 @@ module OpenAI
|
|
|
54
56
|
?metadata: ::Hash[Symbol, String]?,
|
|
55
57
|
?prompt_cache_options: OpenAI::Beta::Agents::SessionUpdateParams::PromptCacheOptions?,
|
|
56
58
|
?review: OpenAI::Models::Beta::Agents::SessionUpdateParams::review,
|
|
59
|
+
?spend_control: OpenAI::Beta::Agents::SessionUpdateParams::SpendControl?,
|
|
57
60
|
?request_options: OpenAI::request_opts
|
|
58
61
|
) -> OpenAI::Beta::AgentSession
|
|
59
62
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenAI
|
|
@@ -538,6 +538,7 @@ files:
|
|
|
538
538
|
- lib/openai/models/beta/agent_send_subagent_input_call_item.rb
|
|
539
539
|
- lib/openai/models/beta/agent_session.rb
|
|
540
540
|
- lib/openai/models/beta/agent_session_assistant_message.rb
|
|
541
|
+
- lib/openai/models/beta/agent_session_budget_reached_event.rb
|
|
541
542
|
- lib/openai/models/beta/agent_session_created_event.rb
|
|
542
543
|
- lib/openai/models/beta/agent_session_deleted.rb
|
|
543
544
|
- lib/openai/models/beta/agent_session_environment_connected_event.rb
|
|
@@ -2167,6 +2168,7 @@ files:
|
|
|
2167
2168
|
- rbi/openai/models/beta/agent_send_subagent_input_call_item.rbi
|
|
2168
2169
|
- rbi/openai/models/beta/agent_session.rbi
|
|
2169
2170
|
- rbi/openai/models/beta/agent_session_assistant_message.rbi
|
|
2171
|
+
- rbi/openai/models/beta/agent_session_budget_reached_event.rbi
|
|
2170
2172
|
- rbi/openai/models/beta/agent_session_created_event.rbi
|
|
2171
2173
|
- rbi/openai/models/beta/agent_session_deleted.rbi
|
|
2172
2174
|
- rbi/openai/models/beta/agent_session_environment_connected_event.rbi
|
|
@@ -3783,6 +3785,7 @@ files:
|
|
|
3783
3785
|
- sig/openai/models/beta/agent_send_subagent_input_call_item.rbs
|
|
3784
3786
|
- sig/openai/models/beta/agent_session.rbs
|
|
3785
3787
|
- sig/openai/models/beta/agent_session_assistant_message.rbs
|
|
3788
|
+
- sig/openai/models/beta/agent_session_budget_reached_event.rbs
|
|
3786
3789
|
- sig/openai/models/beta/agent_session_created_event.rbs
|
|
3787
3790
|
- sig/openai/models/beta/agent_session_deleted.rbs
|
|
3788
3791
|
- sig/openai/models/beta/agent_session_environment_connected_event.rbs
|