Skip to content

Commit 1170f60

Browse files
committed
feat: support controlling build repair attempts
Support controlling build repair attempts.
1 parent 53ec5e5 commit 1170f60

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ You can customize the `web-codegen-scorer eval` script with the following flags:
132132
- `--mcp`: Whether to start an MCP for the evaluation. Defaults to `false`.
133133
- Example: `web-codegen-scorer eval --mcp --env=<config path>`
134134

135+
-- `--max-build-repair-attempts`: Number of repair attempts when build errors are discovered. Defaults to `1` attempt.
136+
135137
- `--help`: Prints out usage information about the script.
136138

137139
### Additional configuration options

runner/configuration/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const LLM_OUTPUT_DIR = join(rootDir, 'llm-output');
2424
* Number of times we'll try to ask LLM to repair a build failure,
2525
* providing the build output and the code that causes the problem.
2626
*/
27+
// Note: When updating, also adjust the default description in `README.md`.
2728
export const DEFAULT_MAX_REPAIR_ATTEMPTS = 1;
2829

2930
/** Name of the folder where we store all generated reports */

runner/eval-cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import chalk from 'chalk';
33
import {
44
BUILT_IN_ENVIRONMENTS,
55
DEFAULT_AUTORATER_MODEL_NAME,
6+
DEFAULT_MAX_REPAIR_ATTEMPTS,
67
DEFAULT_MODEL_NAME,
78
} from './configuration/constants.js';
89
import {generateCodeAndAssess} from './orchestration/generate.js';
@@ -39,6 +40,7 @@ interface Options {
3940
a11yRepairAttempts?: number;
4041
logging?: 'text-only' | 'dynamic';
4142
skipLighthouse?: boolean;
43+
maxBuildRepairAttempts?: number;
4244
}
4345

4446
function builder(argv: Argv): Argv<Options> {
@@ -159,6 +161,11 @@ function builder(argv: Argv): Argv<Options> {
159161
default: false,
160162
description: 'Whether to skip collecting Lighthouse data',
161163
})
164+
.option('max-build-repair-attempts', {
165+
type: 'number',
166+
default: DEFAULT_MAX_REPAIR_ATTEMPTS,
167+
description: 'Number of repair attempts when build errors are discovered',
168+
})
162169
.strict()
163170
.version(false)
164171
.help()
@@ -204,6 +211,7 @@ async function handler(cliArgs: Arguments<Options>): Promise<void> {
204211
skipAiSummary: cliArgs.skipAiSummary,
205212
a11yRepairAttempts: cliArgs.a11yRepairAttempts,
206213
skipLighthouse: cliArgs.skipLighthouse,
214+
maxBuildRepairAttempts: cliArgs.maxBuildRepairAttempts,
207215
});
208216

209217
logReportToConsole(runInfo);

runner/orchestration/build-serve-loop.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88
LlmContextFile,
99
RootPromptDefinition,
1010
} from '../shared-interfaces.js';
11-
import {DEFAULT_MAX_REPAIR_ATTEMPTS} from '../configuration/constants.js';
1211
import {ProgressLogger} from '../progress/progress-logger.js';
1312
import {runBuild} from './build-worker.js';
1413
import {repairAndBuild} from './build-repair.js';
15-
import {EvalID, Executor} from './executors/executor.js';
14+
import {EvalID} from './executors/executor.js';
1615
import {serveAndTestApp} from './serve-testing-worker.js';
1716
import {BrowserAgentTaskInput} from '../testing/browser-agent/models.js';
17+
import {DEFAULT_MAX_REPAIR_ATTEMPTS} from '../configuration/constants.js';
1818

1919
/**
2020
* Attempts to build the code that an LLM generated. If the build fails, attempts
@@ -59,7 +59,7 @@ export async function attemptBuild(
5959
);
6060
let repairAttempts = 0;
6161
const maxRepairAttempts = (await env.executor.shouldRepairFailedBuilds(evalID))
62-
? DEFAULT_MAX_REPAIR_ATTEMPTS
62+
? (config.maxBuildRepairAttempts ?? DEFAULT_MAX_REPAIR_ATTEMPTS)
6363
: 0;
6464

6565
const initialAttempt = {

runner/shared-interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface AssessmentConfig {
2929
autoraterModel?: string;
3030
a11yRepairAttempts?: number;
3131
skipLighthouse?: boolean;
32+
maxBuildRepairAttempts?: number;
3233
}
3334

3435
/**

0 commit comments

Comments
 (0)