Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,23 +712,27 @@ Raw CSS content to be injected into frame.
## async method: Page.agent
* since: v1.58
* langs: js
* hidden
- returns: <[PageAgent]>

Initialize page agent with the llm provider and cache.

### option: Page.agent.cache
* since: v1.58
* hidden
- `cache` <[Object]>
- `cacheFile` ?<[string]> Cache file to use/generate code for performed actions into. Cache is not used if not specified (default).
- `cacheOutFile` ?<[string]> When specified, generated entries are written into the `cacheOutFile` instead of updating the `cacheFile`.

### option: Page.agent.expect
* since: v1.58
* hidden
- `expect` <[Object]>
- `timeout` ?<[int]> Default timeout for expect calls in milliseconds, defaults to 5000ms.

### option: Page.agent.limits
* since: v1.58
* hidden
- `limits` <[Object]>
- `maxTokens` ?<[int]> Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value. Defaults to unlimited.
- `maxActions` ?<[int]> Maximum number of agentic actions to generate, defaults to 10.
Expand All @@ -738,6 +742,7 @@ Limits to use for the agentic loop.

### option: Page.agent.provider
* since: v1.58
* hidden
- `provider` <[Object]>
- `api` <[PageAgentAPI]<"openai"|"openai-compatible"|"anthropic"|"google">> API to use.
- `apiEndpoint` ?<[string]> Endpoint to use if different from default.
Expand All @@ -747,12 +752,14 @@ Limits to use for the agentic loop.

### option: Page.agent.secrets
* since: v1.58
* hidden
- `secrets` ?<[Object]<[string], [string]>>

Secrets to hide from the LLM.

### option: Page.agent.systemPrompt
* since: v1.58
* hidden
- `systemPrompt` <[string]>

System prompt for the agent's loop.
Expand Down
16 changes: 15 additions & 1 deletion docs/src/api/class-pageagent.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# class: PageAgent
* since: v1.58
* langs: js
* hidden

## event: PageAgent.turn
* since: v1.58
* hidden
- argument: <[Object]>
- `role` <[string]>
- `message` <[string]>
Expand All @@ -14,11 +16,13 @@
Emitted when the agent makes a turn.

## async method: PageAgent.dispose
* hidden
* since: v1.58

Dispose this agent.

## async method: PageAgent.expect
* hidden
* since: v1.58

Expect certain condition to be met.
Expand All @@ -31,12 +35,14 @@ await agent.expect('"0 items" to be reported');

### param: PageAgent.expect.expectation
* since: v1.58
* hidden
- `expectation` <[string]>

Expectation to assert.

### option: PageAgent.expect.timeout
* since: v1.58
* hidden
- `timeout` <[float]>

Expect timeout in milliseconds. Defaults to `5000`. The default value can be changed via `expect.timeout` option in the config, or by specifying the `expect` property of the [`option: Page.agent.expect`] option. Pass `0` to disable timeout.
Expand All @@ -46,6 +52,7 @@ Expect timeout in milliseconds. Defaults to `5000`. The default value can be cha

## async method: PageAgent.extract
* since: v1.58
* hidden
- returns: <[Object]>
- `result` <[any]>
- `usage` <[Object]>
Expand All @@ -66,16 +73,19 @@ await agent.extract('List of items in the cart', z.object({

### param: PageAgent.extract.query
* since: v1.58
* hidden
- `query` <[string]>

Task to perform using agentic loop.

### param: PageAgent.extract.schema
* since: v1.58
* hidden
- `schema` <[z.ZodSchema]>

### option: PageAgent.extract.timeout
* since: v1.58
* hidden
- `timeout` <[float]>

Extract timeout in milliseconds. Defaults to `5000`. The default value can be changed via `actionTimeout` option in the config, or by using the [`method: BrowserContext.setDefaultTimeout`] or
Expand All @@ -84,9 +94,9 @@ Extract timeout in milliseconds. Defaults to `5000`. The default value can be ch
### option: PageAgent.extract.-inline- = %%-page-agent-call-options-v1.58-%%
* since: v1.58


## async method: PageAgent.perform
* since: v1.58
* hidden
- returns: <[Object]>
- `usage` <[Object]>
- `turns` <[int]>
Expand All @@ -103,22 +113,26 @@ await agent.perform('Click submit button');

### param: PageAgent.perform.task
* since: v1.58
* hidden
- `task` <[string]>

Task to perform using agentic loop.

### option: PageAgent.perform.timeout
* since: v1.58
* hidden
- `timeout` <[float]>

Perform timeout in milliseconds. Defaults to `5000`. The default value can be changed via `actionTimeout` option in the config, or by using the [`method: BrowserContext.setDefaultTimeout`] or
[`method: Page.setDefaultTimeout`] methods. Pass `0` to disable timeout.

### option: PageAgent.perform.-inline- = %%-page-agent-call-options-v1.58-%%
* since: v1.58
* hidden

## async method: PageAgent.usage
* since: v1.58
* hidden
- returns: <[Object]>
- `turns` <[int]>
- `inputTokens` <[int]>
Expand Down
4 changes: 4 additions & 0 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,30 @@ Emulates consistent window screen size available inside web page via `window.scr

## page-agent-cache-key
* since: v1.58
* hidden
- `cacheKey` <[string]>

All the agentic actions are converted to the Playwright calls and are cached.
By default, they are cached globally with the `task` as a key. This option allows controlling the cache key explicitly.

## page-agent-max-tokens
* since: v1.58
* hidden
- `maxTokens` <[int]>

Maximum number of tokens to consume. The agentic loop will stop after input + output tokens exceed this value.
Defaults to context-wide value specified in `agent` property.

## page-agent-max-actions
* since: v1.58
* hidden
- `maxActions` <[int]>

Maximum number of agentic actions to generate, defaults to context-wide value specified in `agent` property.

## page-agent-max-action-retries
* since: v1.58
* hidden
- `maxActionRetries` <[int]>

Maximum number of retries when generating each action, defaults to context-wide value specified in `agent` property.
Expand Down
1 change: 1 addition & 0 deletions docs/src/test-api/class-fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Playwright Test comes with builtin fixtures listed below, and you can add your o

## property: Fixtures.agent
* since: v1.58
* hidden
- type: <[PageAgent]>

## property: Fixtures.browser
Expand Down
1 change: 1 addition & 0 deletions docs/src/test-api/class-fullconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Base directory for all relative paths used in the reporters.

## property: FullConfig.runAgents
* since: v1.58
* hidden
- type: <['RunAgentsMode]<"all"|"missing"|"none">>

Whether to run LLM agent for [PageAgent]:
Expand Down
1 change: 1 addition & 0 deletions docs/src/test-api/class-testconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ export default defineConfig({

## property: TestConfig.runAgents
* since: v1.58
* hidden
- type: ?<['RunAgentsMode]<"all"|"missing"|"none">>

Whether to run LLM agent for [PageAgent]:
Expand Down
1 change: 1 addition & 0 deletions docs/src/test-api/class-testoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default defineConfig({

## property: TestOptions.agentOptions
* since: v1.58
* hidden
- type: <[Object]>
- `provider` <[Object]>
- `api` <[PageAgentAPI]<"openai"|"openai-compatible"|"anthropic"|"google">> API to use.
Expand Down
Loading
Loading