Skip to content

Commit ca388e7

Browse files
author
stlc-bot
committed
[AP-2931] docs(agents): pausing and resuming runs (#12265)
Stainless-Generated-From: f71c45a5c0e01a1a6b50a10361e5940952a9fa63
1 parent 94ac1c2 commit ca388e7

8 files changed

Lines changed: 46 additions & 7 deletions

File tree

‎scripts/mock‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎src/browserbase/resources/agents/runs.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def create(
5454
task: str,
5555
agent_id: str | Omit = omit,
5656
browser_settings: run_create_params.BrowserSettings | Omit = omit,
57+
pause_when: str | Omit = omit,
5758
result_schema: Dict[str, object] | Omit = omit,
5859
variables: Dict[str, run_create_params.Variables] | Omit = omit,
5960
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -78,6 +79,12 @@ def create(
7879
browser_settings: Browser configuration for the agent's session. When omitted, runner defaults
7980
apply.
8081
82+
pause_when: Optional description of when the agent should pause and wait for input from your
83+
application (e.g. a verification code, an approval, or an answer from another
84+
system). When set, the agent is given a `pause` tool; calling it transitions the
85+
run to `PAUSED` (the agent's request is the trailing `pause` tool call in the
86+
run's messages) until it is resumed via the resume endpoint.
87+
8188
result_schema: An optional [JSON Schema](https://json-schema.org/specification) object. If
8289
provided, the agent will aim to return a `result` that conforms to this schema
8390
when the run completes. Overrides the referenced agent's default `resultSchema`
@@ -103,6 +110,7 @@ def create(
103110
"task": task,
104111
"agent_id": agent_id,
105112
"browser_settings": browser_settings,
113+
"pause_when": pause_when,
106114
"result_schema": result_schema,
107115
"variables": variables,
108116
},
@@ -157,7 +165,7 @@ def list(
157165
end_at: Union[str, datetime] | Omit = omit,
158166
limit: int | Omit = omit,
159167
start_at: Union[str, datetime] | Omit = omit,
160-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"] | Omit = omit,
168+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"] | Omit = omit,
161169
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
162170
# The extra values given here take precedence over values defined on the client or passed to this method.
163171
extra_headers: Headers | None = None,
@@ -192,6 +200,8 @@ def list(
192200
- `FAILED` - agent has failed the run
193201
- `STOPPED` - run was stopped by the user
194202
- `TIMED_OUT` - run exceeded maximum time
203+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
204+
is the trailing `pause` tool call in the run's messages
195205
196206
extra_headers: Send extra headers
197207
@@ -310,6 +320,7 @@ async def create(
310320
task: str,
311321
agent_id: str | Omit = omit,
312322
browser_settings: run_create_params.BrowserSettings | Omit = omit,
323+
pause_when: str | Omit = omit,
313324
result_schema: Dict[str, object] | Omit = omit,
314325
variables: Dict[str, run_create_params.Variables] | Omit = omit,
315326
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -334,6 +345,12 @@ async def create(
334345
browser_settings: Browser configuration for the agent's session. When omitted, runner defaults
335346
apply.
336347
348+
pause_when: Optional description of when the agent should pause and wait for input from your
349+
application (e.g. a verification code, an approval, or an answer from another
350+
system). When set, the agent is given a `pause` tool; calling it transitions the
351+
run to `PAUSED` (the agent's request is the trailing `pause` tool call in the
352+
run's messages) until it is resumed via the resume endpoint.
353+
337354
result_schema: An optional [JSON Schema](https://json-schema.org/specification) object. If
338355
provided, the agent will aim to return a `result` that conforms to this schema
339356
when the run completes. Overrides the referenced agent's default `resultSchema`
@@ -359,6 +376,7 @@ async def create(
359376
"task": task,
360377
"agent_id": agent_id,
361378
"browser_settings": browser_settings,
379+
"pause_when": pause_when,
362380
"result_schema": result_schema,
363381
"variables": variables,
364382
},
@@ -413,7 +431,7 @@ async def list(
413431
end_at: Union[str, datetime] | Omit = omit,
414432
limit: int | Omit = omit,
415433
start_at: Union[str, datetime] | Omit = omit,
416-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"] | Omit = omit,
434+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"] | Omit = omit,
417435
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
418436
# The extra values given here take precedence over values defined on the client or passed to this method.
419437
extra_headers: Headers | None = None,
@@ -448,6 +466,8 @@ async def list(
448466
- `FAILED` - agent has failed the run
449467
- `STOPPED` - run was stopped by the user
450468
- `TIMED_OUT` - run exceeded maximum time
469+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
470+
is the trailing `pause` tool call in the run's messages
451471
452472
extra_headers: Send extra headers
453473

‎src/browserbase/types/agents/run_create_params.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ class RunCreateParams(TypedDict, total=False):
3737
When omitted, runner defaults apply.
3838
"""
3939

40+
pause_when: Annotated[str, PropertyInfo(alias="pauseWhen")]
41+
"""
42+
Optional description of when the agent should pause and wait for input from your
43+
application (e.g. a verification code, an approval, or an answer from another
44+
system). When set, the agent is given a `pause` tool; calling it transitions the
45+
run to `PAUSED` (the agent's request is the trailing `pause` tool call in the
46+
run's messages) until it is resumed via the resume endpoint.
47+
"""
48+
4049
result_schema: Annotated[Dict[str, object], PropertyInfo(alias="resultSchema")]
4150
"""An optional [JSON Schema](https://json-schema.org/specification) object.
4251

‎src/browserbase/types/agents/run_create_response.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RunCreateResponse(BaseModel):
3030
run_id: str = FieldInfo(alias="runId")
3131
"""Unique identifier for the run."""
3232

33-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]
33+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"]
3434
"""Current status of the run.
3535
3636
- `PENDING` - agent will run soon
@@ -39,6 +39,8 @@ class RunCreateResponse(BaseModel):
3939
- `FAILED` - agent has failed the run
4040
- `STOPPED` - run was stopped by the user
4141
- `TIMED_OUT` - run exceeded maximum time
42+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
43+
is the trailing `pause` tool call in the run's messages
4244
"""
4345

4446
task: str

‎src/browserbase/types/agents/run_list_params.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RunListParams(TypedDict, total=False):
3737
RFC 3339, e.g. 2026-01-19T00:00:00Z.
3838
"""
3939

40-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]
40+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"]
4141
"""Current status of the run.
4242
4343
- `PENDING` - agent will run soon
@@ -46,4 +46,6 @@ class RunListParams(TypedDict, total=False):
4646
- `FAILED` - agent has failed the run
4747
- `STOPPED` - run was stopped by the user
4848
- `TIMED_OUT` - run exceeded maximum time
49+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
50+
is the trailing `pause` tool call in the run's messages
4951
"""

‎src/browserbase/types/agents/run_list_response.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Data(BaseModel):
3030
run_id: str = FieldInfo(alias="runId")
3131
"""Unique identifier for the run."""
3232

33-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]
33+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"]
3434
"""Current status of the run.
3535
3636
- `PENDING` - agent will run soon
@@ -39,6 +39,8 @@ class Data(BaseModel):
3939
- `FAILED` - agent has failed the run
4040
- `STOPPED` - run was stopped by the user
4141
- `TIMED_OUT` - run exceeded maximum time
42+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
43+
is the trailing `pause` tool call in the run's messages
4244
"""
4345

4446
task: str

‎src/browserbase/types/agents/run_retrieve_response.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RunRetrieveResponse(BaseModel):
3030
run_id: str = FieldInfo(alias="runId")
3131
"""Unique identifier for the run."""
3232

33-
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT"]
33+
status: Literal["PENDING", "RUNNING", "COMPLETED", "FAILED", "STOPPED", "TIMED_OUT", "PAUSED"]
3434
"""Current status of the run.
3535
3636
- `PENDING` - agent will run soon
@@ -39,6 +39,8 @@ class RunRetrieveResponse(BaseModel):
3939
- `FAILED` - agent has failed the run
4040
- `STOPPED` - run was stopped by the user
4141
- `TIMED_OUT` - run exceeded maximum time
42+
- `PAUSED` - run is paused awaiting input from the caller; the agent's request
43+
is the trailing `pause` tool call in the run's messages
4244
"""
4345

4446
task: str

‎tests/api_resources/agents/test_runs.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def test_method_create_with_all_params(self, client: Browserbase) -> None:
5353
],
5454
"verified": True,
5555
},
56+
pause_when="x",
5657
result_schema={"foo": "bar"},
5758
variables={
5859
"foo": {
@@ -246,6 +247,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncBrowserbas
246247
],
247248
"verified": True,
248249
},
250+
pause_when="x",
249251
result_schema={"foo": "bar"},
250252
variables={
251253
"foo": {

0 commit comments

Comments
 (0)