Skip to content

Commit 1eba405

Browse files
authored
chore: allow all/missing/none run agents modes (#38628)
1 parent 6a00a6a commit 1eba405

File tree

11 files changed

+33
-19
lines changed

11 files changed

+33
-19
lines changed

docs/src/test-api/class-fullconfig.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ Base directory for all relative paths used in the reporters.
106106

107107
## property: FullConfig.runAgents
108108
* since: v1.58
109-
- type: <boolean>
109+
- type: <['RunAgentsMode]<"all"|"missing"|"none">>
110110

111-
Run agents to generate the code for [`method: Page.perform`] and similar.
111+
Whether to run LLM agent for [`method: Page.perform`]:
112+
* "all" disregards existing cache and performs all actions via LLM
113+
* "missing" only performs actions that don't have generated cache actions
114+
* "none" does not talk to LLM at all, relies on the cached actions (default)
112115

113116
## property: FullConfig.shard
114117
* since: v1.10

docs/src/test-api/class-testconfig.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,12 @@ export default defineConfig({
516516

517517
## property: TestConfig.runAgents
518518
* since: v1.58
519-
- type: ?<boolean>
519+
- type: ?<['RunAgentsMode]<"all"|"missing"|"none">>
520520

521-
Run agents to generate the code for [`method: Page.perform`] and similar.
521+
Whether to run LLM agent for [`method: Page.perform`]:
522+
* "all" disregards existing cache and performs all actions via LLM
523+
* "missing" only performs actions that don't have generated cache actions
524+
* "none" does not talk to LLM at all, relies on the cached actions (default)
522525

523526
## property: TestConfig.shard
524527
* since: v1.10

packages/playwright/src/common/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class FullConfigInternal {
112112
quiet: takeFirst(configCLIOverrides.quiet, userConfig.quiet, false),
113113
reporter: takeFirst(configCLIOverrides.reporter, resolveReporters(userConfig.reporter, configDir), [[defaultReporter]]),
114114
reportSlowTests: takeFirst(userConfig.reportSlowTests, { max: 5, threshold: 300_000 /* 5 minutes */ }),
115-
runAgents: takeFirst(configCLIOverrides.runAgents, userConfig.runAgents, false),
115+
runAgents: takeFirst(configCLIOverrides.runAgents, userConfig.runAgents, 'none'),
116116
shard: takeFirst(configCLIOverrides.shard, userConfig.shard, null),
117117
tags: globalTags,
118118
updateSnapshots: takeFirst(configCLIOverrides.updateSnapshots, userConfig.updateSnapshots, 'missing'),

packages/playwright/src/common/ipc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export type ConfigCLIOverrides = {
4343
ignoreSnapshots?: boolean;
4444
updateSnapshots?: 'all' | 'changed' | 'missing' | 'none';
4545
updateSourceMethod?: 'overwrite' | 'patch' | '3way';
46-
runAgents?: boolean;
46+
runAgents?: 'all' | 'missing' | 'none';
4747
workers?: number | string;
4848
projects?: { name: string, use?: any }[],
4949
use?: any;

packages/playwright/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,11 @@ class ArtifactsRecorder {
716716
this._agentCacheFile = this._testInfo._applyPathTemplate(cachePathTemplate, '', '.json');
717717
this._agentCacheOutFile = path.join(this._testInfo.artifactsDir(), 'agent-cache-' + createGuid() + '.json');
718718

719-
const cacheFile = this._testInfo.config.runAgents ? undefined : await this._testInfo._cloneStorage(this._agentCacheFile);
719+
const cacheFile = this._testInfo.config.runAgents === 'all' ? undefined : await this._testInfo._cloneStorage(this._agentCacheFile);
720720
options.agent = {
721721
...this._agent,
722+
provider: this._testInfo.config.runAgents !== 'none' ? this._agent.provider : undefined,
723+
model: this._testInfo.config.runAgents !== 'none' ? this._agent.model : undefined,
722724
cacheFile,
723725
cacheOutFile: this._agentCacheOutFile,
724726
};

packages/playwright/src/isomorphic/teleReceiver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ export const baseFullConfig: reporterTypes.FullConfig = {
782782
tags: [],
783783
updateSnapshots: 'missing',
784784
updateSourceMethod: 'patch',
785-
runAgents: false,
785+
runAgents: 'none',
786786
version: '',
787787
workers: 0,
788788
webServer: null,

packages/playwright/src/isomorphic/testServerInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export interface TestServerInterface {
9797
workers?: number | string;
9898
updateSnapshots?: 'all' | 'changed' | 'missing' | 'none';
9999
updateSourceMethod?: 'overwrite' | 'patch' | '3way';
100-
runAgents?: boolean;
100+
runAgents?: 'all' | 'missing' | 'none';
101101
reporters?: string[],
102102
trace?: 'on' | 'off';
103103
video?: 'on' | 'off';

packages/playwright/src/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ const testOptions: [string, { description: string, choices?: string[], preset?:
422422
['--repeat-each <N>', { description: `Run each test N times (default: 1)` }],
423423
['--reporter <reporter>', { description: `Reporter to use, comma-separated, can be ${builtInReporters.map(name => `"${name}"`).join(', ')} (default: "${defaultReporter}")` }],
424424
['--retries <retries>', { description: `Maximum retry count for flaky tests, zero for no retries (default: no retries)` }],
425-
['--run-agents', { description: `Run agents to generate the code for page.perform` }],
425+
['--run-agents <mode>', { description: `Run agents to generate the code for page.perform`, choices: ['missing', 'all', 'none'], preset: 'none' }],
426426
['--shard <shard>', { description: `Shard tests and execute only the selected shard, specify in the form "current/all", 1-based, for example "3/5"` }],
427427
['--shard-weights <weights>', { description: `Weights for each shard, colon-separated, for example "2:1:1" for 3 shards where the first shard should be allocated half of the work` }],
428428
['--test-list <file>', { description: `Path to a file containing a list of tests to run. See https://playwright.dev/docs/test-cli for more details.` }],

packages/playwright/src/runner/testRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export type RunTestsParams = {
6868
workers?: number | string;
6969
updateSnapshots?: 'all' | 'changed' | 'missing' | 'none';
7070
updateSourceMethod?: 'overwrite' | 'patch' | '3way';
71-
runAgents?: boolean;
71+
runAgents?: 'all' | 'missing' | 'none';
7272
reporters?: string[],
7373
trace?: 'on' | 'off';
7474
video?: 'on' | 'off';

packages/playwright/types/test.d.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,10 +1612,13 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
16121612
retries?: number;
16131613

16141614
/**
1615-
* Run agents to generate the code for
1616-
* [page.perform(task[, options])](https://playwright.dev/docs/api/class-page#page-perform) and similar.
1615+
* Whether to run LLM agent for
1616+
* [page.perform(task[, options])](https://playwright.dev/docs/api/class-page#page-perform):
1617+
* - "all" disregards existing cache and performs all actions via LLM
1618+
* - "missing" only performs actions that don't have generated cache actions
1619+
* - "none" does not talk to LLM at all, relies on the cached actions (default)
16171620
*/
1618-
runAgents?: boolean;
1621+
runAgents?: "all"|"missing"|"none";
16191622

16201623
/**
16211624
* Shard tests and execute only the selected shard. Specify in the one-based form like `{ total: 5, current: 2 }`.
@@ -2074,10 +2077,13 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
20742077
rootDir: string;
20752078

20762079
/**
2077-
* Run agents to generate the code for
2078-
* [page.perform(task[, options])](https://playwright.dev/docs/api/class-page#page-perform) and similar.
2080+
* Whether to run LLM agent for
2081+
* [page.perform(task[, options])](https://playwright.dev/docs/api/class-page#page-perform):
2082+
* - "all" disregards existing cache and performs all actions via LLM
2083+
* - "missing" only performs actions that don't have generated cache actions
2084+
* - "none" does not talk to LLM at all, relies on the cached actions (default)
20792085
*/
2080-
runAgents: boolean;
2086+
runAgents: "all"|"missing"|"none";
20812087

20822088
/**
20832089
* See [testConfig.shard](https://playwright.dev/docs/api/class-testconfig#test-config-shard).
@@ -6952,7 +6958,7 @@ export type Agent = {
69526958
cachePathTemplate?: string;
69536959
maxTurns?: number;
69546960
maxTokens?: number;
6955-
runAgents?: boolean;
6961+
runAgents?: 'all' | 'missing' | 'none';
69566962
secrets?: { [key: string]: string };
69576963
};
69586964

0 commit comments

Comments
 (0)