Skip to content

Commit 460067e

Browse files
feat: Add executionModel serialization to api client
1 parent 7d27ca0 commit 460067e

File tree

5 files changed

+88
-5
lines changed

5 files changed

+88
-5
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 8
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-43e6dd4ce19381de488d296e9036fea15bfea9a6f946cf8ccf4e02aecc8fb765.yml
3-
openapi_spec_hash: f736e7a8acea0d73e1031c86ea803246
4-
config_hash: b375728ccf7d33287335852f4f59c293
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-8fbb3fa8f3a37c1c7408de427fe125aadec49f705e8e30d191601a9b69c4cc41.yml
3+
openapi_spec_hash: 48b4dfac35a842d7fb0d228caf87544e
4+
config_hash: 242651c4871c2869ba3c2e3d337505b9

lib/stagehand/internal/stream.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Stream
2323
next if consume
2424

2525
case msg
26-
in {data: String => data} if data.start_with?("{\"data\":{\"status\":\"finished\"")
26+
in {data: String => data} if data.start_with?("finished")
2727
consume = true
2828
next
2929
in {data: String => data} if data.start_with?("error")

lib/stagehand/models/session_execute_params.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ class AgentConfig < Stagehand::Internal::Type::BaseModel
6060
# @return [Boolean, nil]
6161
optional :cua, Stagehand::Internal::Type::Boolean
6262

63+
# @!attribute execution_model
64+
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
65+
# tool execution (observe/act calls within agent tools). If not specified,
66+
# inherits from the main model configuration.
67+
#
68+
# @return [Stagehand::Models::ModelConfig, String, nil]
69+
optional :execution_model,
70+
union: -> { Stagehand::SessionExecuteParams::AgentConfig::ExecutionModel },
71+
api_name: :executionModel
72+
6373
# @!attribute mode
6474
# Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
6575
#
@@ -84,12 +94,14 @@ class AgentConfig < Stagehand::Internal::Type::BaseModel
8494
# @return [String, nil]
8595
optional :system_prompt, String, api_name: :systemPrompt
8696

87-
# @!method initialize(cua: nil, mode: nil, model: nil, provider: nil, system_prompt: nil)
97+
# @!method initialize(cua: nil, execution_model: nil, mode: nil, model: nil, provider: nil, system_prompt: nil)
8898
# Some parameter documentations has been truncated, see
8999
# {Stagehand::Models::SessionExecuteParams::AgentConfig} for more details.
90100
#
91101
# @param cua [Boolean] Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence
92102
#
103+
# @param execution_model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
104+
#
93105
# @param mode [Symbol, Stagehand::Models::SessionExecuteParams::AgentConfig::Mode] Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
94106
#
95107
# @param model [Stagehand::Models::ModelConfig, String] Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
@@ -98,6 +110,22 @@ class AgentConfig < Stagehand::Internal::Type::BaseModel
98110
#
99111
# @param system_prompt [String] Custom system prompt for the agent
100112

113+
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
114+
# tool execution (observe/act calls within agent tools). If not specified,
115+
# inherits from the main model configuration.
116+
#
117+
# @see Stagehand::Models::SessionExecuteParams::AgentConfig#execution_model
118+
module ExecutionModel
119+
extend Stagehand::Internal::Type::Union
120+
121+
variant -> { Stagehand::ModelConfig }
122+
123+
variant String
124+
125+
# @!method self.variants
126+
# @return [Array(Stagehand::Models::ModelConfig, String)]
127+
end
128+
101129
# Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
102130
#
103131
# @see Stagehand::Models::SessionExecuteParams::AgentConfig#mode

rbi/stagehand/models/session_execute_params.rbi

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ module Stagehand
117117
sig { params(cua: T::Boolean).void }
118118
attr_writer :cua
119119

120+
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
121+
# tool execution (observe/act calls within agent tools). If not specified,
122+
# inherits from the main model configuration.
123+
sig { returns(T.nilable(T.any(Stagehand::ModelConfig, String))) }
124+
attr_reader :execution_model
125+
126+
sig do
127+
params(
128+
execution_model: T.any(Stagehand::ModelConfig::OrHash, String)
129+
).void
130+
end
131+
attr_writer :execution_model
132+
120133
# Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
121134
sig do
122135
returns(
@@ -171,6 +184,7 @@ module Stagehand
171184
sig do
172185
params(
173186
cua: T::Boolean,
187+
execution_model: T.any(Stagehand::ModelConfig::OrHash, String),
174188
mode: Stagehand::SessionExecuteParams::AgentConfig::Mode::OrSymbol,
175189
model: T.any(Stagehand::ModelConfig::OrHash, String),
176190
provider:
@@ -182,6 +196,10 @@ module Stagehand
182196
# Deprecated. Use mode: 'cua' instead. If both are provided, mode takes
183197
# precedence.
184198
cua: nil,
199+
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
200+
# tool execution (observe/act calls within agent tools). If not specified,
201+
# inherits from the main model configuration.
202+
execution_model: nil,
185203
# Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
186204
mode: nil,
187205
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
@@ -197,6 +215,7 @@ module Stagehand
197215
override.returns(
198216
{
199217
cua: T::Boolean,
218+
execution_model: T.any(Stagehand::ModelConfig, String),
200219
mode:
201220
Stagehand::SessionExecuteParams::AgentConfig::Mode::OrSymbol,
202221
model: T.any(Stagehand::ModelConfig, String),
@@ -209,6 +228,25 @@ module Stagehand
209228
def to_hash
210229
end
211230

231+
# Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
232+
# tool execution (observe/act calls within agent tools). If not specified,
233+
# inherits from the main model configuration.
234+
module ExecutionModel
235+
extend Stagehand::Internal::Type::Union
236+
237+
Variants = T.type_alias { T.any(Stagehand::ModelConfig, String) }
238+
239+
sig do
240+
override.returns(
241+
T::Array[
242+
Stagehand::SessionExecuteParams::AgentConfig::ExecutionModel::Variants
243+
]
244+
)
245+
end
246+
def self.variants
247+
end
248+
end
249+
212250
# Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.
213251
module Mode
214252
extend Stagehand::Internal::Type::Enum

sig/stagehand/models/session_execute_params.rbs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Stagehand
5151
type agent_config =
5252
{
5353
cua: bool,
54+
execution_model: Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model,
5455
mode: Stagehand::Models::SessionExecuteParams::AgentConfig::mode,
5556
model: Stagehand::Models::SessionExecuteParams::AgentConfig::model,
5657
provider: Stagehand::Models::SessionExecuteParams::AgentConfig::provider,
@@ -62,6 +63,12 @@ module Stagehand
6263

6364
def cua=: (bool) -> bool
6465

66+
attr_reader execution_model: Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model?
67+
68+
def execution_model=: (
69+
Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model
70+
) -> Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model
71+
6572
attr_reader mode: Stagehand::Models::SessionExecuteParams::AgentConfig::mode?
6673

6774
def mode=: (
@@ -86,6 +93,7 @@ module Stagehand
8693

8794
def initialize: (
8895
?cua: bool,
96+
?execution_model: Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model,
8997
?mode: Stagehand::Models::SessionExecuteParams::AgentConfig::mode,
9098
?model: Stagehand::Models::SessionExecuteParams::AgentConfig::model,
9199
?provider: Stagehand::Models::SessionExecuteParams::AgentConfig::provider,
@@ -94,12 +102,21 @@ module Stagehand
94102

95103
def to_hash: -> {
96104
cua: bool,
105+
execution_model: Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model,
97106
mode: Stagehand::Models::SessionExecuteParams::AgentConfig::mode,
98107
model: Stagehand::Models::SessionExecuteParams::AgentConfig::model,
99108
provider: Stagehand::Models::SessionExecuteParams::AgentConfig::provider,
100109
system_prompt: String
101110
}
102111

112+
type execution_model = Stagehand::ModelConfig | String
113+
114+
module ExecutionModel
115+
extend Stagehand::Internal::Type::Union
116+
117+
def self?.variants: -> ::Array[Stagehand::Models::SessionExecuteParams::AgentConfig::execution_model]
118+
end
119+
103120
type mode = :dom | :hybrid | :cua
104121

105122
module Mode

0 commit comments

Comments
 (0)