Skip to content

Commit 22dd688

Browse files
feat: Add executionModel serialization to api client
1 parent 0c9bb8c commit 22dd688

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</a>
2929
</p>
3030
<!-- prettier-ignore -->
31-
[![PyPI version](https://img.shields.io/pypi/v/stagehand-alpha.svg?label=pypi%20(stable))](https://pypi.org/project/stagehand-alpha/)
31+
[![PyPI version](https://img.shields.io/pypi/v/stagehand.svg?label=pypi%20(stable))](https://pypi.org/project/stagehand/)
3232

3333
<p align="center">
3434
<a href="https://trendshift.io/repositories/12122" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12122" alt="browserbase%2Fstagehand | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>

src/stagehand/types/session_execute_params.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
from __future__ import annotations
44

55
from typing import Union, Optional
6-
from typing_extensions import Literal, Required, Annotated, TypedDict
6+
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

88
from .._utils import PropertyInfo
99
from .model_config_param import ModelConfigParam
1010

1111
__all__ = [
1212
"SessionExecuteParamsBase",
1313
"AgentConfig",
14+
"AgentConfigExecutionModel",
15+
"AgentConfigModel",
1416
"ExecuteOptions",
1517
"SessionExecuteParamsNonStreaming",
1618
"SessionExecuteParamsStreaming",
@@ -32,13 +34,25 @@ class SessionExecuteParamsBase(TypedDict, total=False):
3234
"""Whether to stream the response via SSE"""
3335

3436

37+
AgentConfigExecutionModel: TypeAlias = Union[ModelConfigParam, str]
38+
39+
AgentConfigModel: TypeAlias = Union[ModelConfigParam, str]
40+
41+
3542
class AgentConfig(TypedDict, total=False):
3643
cua: bool
3744
"""Deprecated.
3845
3946
Use mode: 'cua' instead. If both are provided, mode takes precedence.
4047
"""
4148

49+
execution_model: Annotated[AgentConfigExecutionModel, PropertyInfo(alias="executionModel")]
50+
"""
51+
Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for
52+
tool execution (observe/act calls within agent tools). If not specified,
53+
inherits from the main model configuration.
54+
"""
55+
4256
mode: Literal["dom", "hybrid", "cua"]
4357
"""Tool mode for the agent (dom, hybrid, cua). If set, overrides cua."""
4458

tests/api_resources/test_sessions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def test_method_execute_with_all_params_overload_1(self, client: Stagehand) -> N
232232
"provider": "openai",
233233
},
234234
"mode": "cua",
235+
"model": {
236+
"model_name": "openai/gpt-5-nano",
237+
"api_key": "sk-some-openai-api-key",
238+
"base_url": "https://api.openai.com/v1",
239+
"provider": "openai",
240+
},
241+
"mode": "cua",
235242
"model": {"model_name": "openai/gpt-5-nano"},
236243
"provider": "openai",
237244
"system_prompt": "systemPrompt",
@@ -321,6 +328,13 @@ def test_method_execute_with_all_params_overload_2(self, client: Stagehand) -> N
321328
"provider": "openai",
322329
},
323330
"mode": "cua",
331+
"model": {
332+
"model_name": "openai/gpt-5-nano",
333+
"api_key": "sk-some-openai-api-key",
334+
"base_url": "https://api.openai.com/v1",
335+
"provider": "openai",
336+
},
337+
"mode": "cua",
324338
"model": {"model_name": "openai/gpt-5-nano"},
325339
"provider": "openai",
326340
"system_prompt": "systemPrompt",
@@ -1077,6 +1091,13 @@ async def test_method_execute_with_all_params_overload_1(self, async_client: Asy
10771091
"provider": "openai",
10781092
},
10791093
"mode": "cua",
1094+
"model": {
1095+
"model_name": "openai/gpt-5-nano",
1096+
"api_key": "sk-some-openai-api-key",
1097+
"base_url": "https://api.openai.com/v1",
1098+
"provider": "openai",
1099+
},
1100+
"mode": "cua",
10801101
"model": {"model_name": "openai/gpt-5-nano"},
10811102
"provider": "openai",
10821103
"system_prompt": "systemPrompt",
@@ -1166,6 +1187,13 @@ async def test_method_execute_with_all_params_overload_2(self, async_client: Asy
11661187
"provider": "openai",
11671188
},
11681189
"mode": "cua",
1190+
"model": {
1191+
"model_name": "openai/gpt-5-nano",
1192+
"api_key": "sk-some-openai-api-key",
1193+
"base_url": "https://api.openai.com/v1",
1194+
"provider": "openai",
1195+
},
1196+
"mode": "cua",
11691197
"model": {"model_name": "openai/gpt-5-nano"},
11701198
"provider": "openai",
11711199
"system_prompt": "systemPrompt",

0 commit comments

Comments
 (0)