Skip to content

Commit 498c5a5

Browse files
committed
refactor: allow agents to configure the timeouts
Allows for agents inheriting from the `BaseCliAgentRunner` to override the timeout values.
1 parent 366503b commit 498c5a5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

runner/codegen/base-cli-agent-runner.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export abstract class BaseCliAgentRunner {
1919
protected abstract readonly ignoredFilePatterns: string[];
2020
protected abstract getCommandLineFlags(options: LlmGenerateFilesRequestOptions): string[];
2121
protected abstract writeAgentFiles(options: LlmGenerateFilesRequestOptions): Promise<void>;
22+
protected inactivityTimeoutMins = 2;
23+
protected totalRequestTimeoutMins = 10;
2224

2325
private pendingTimeouts = new Set<ReturnType<typeof setTimeout>>();
2426
private pendingProcesses = new Set<ChildProcess>();
@@ -46,7 +48,7 @@ export abstract class BaseCliAgentRunner {
4648

4749
await this.writeAgentFiles(options);
4850

49-
const reasoning = await this.runAgentProcess(options, 2, 10);
51+
const reasoning = await this.runAgentProcess(options);
5052
const finalSnapshot = await DirectorySnapshot.forDirectory(context.directory, ignoredPatterns);
5153

5254
const diff = finalSnapshot.getChangedOrAddedFiles(initialSnapshot);
@@ -168,15 +170,13 @@ export abstract class BaseCliAgentRunner {
168170
return binaryPath;
169171
}
170172

171-
private runAgentProcess(
172-
options: LlmGenerateFilesRequestOptions,
173-
inactivityTimeoutMins: number,
174-
totalRequestTimeoutMins: number,
175-
): Promise<string> {
173+
private runAgentProcess(options: LlmGenerateFilesRequestOptions): Promise<string> {
176174
return new Promise<string>(resolve => {
177175
let stdoutBuffer = '';
178176
let stdErrBuffer = '';
179177
let isDone = false;
178+
const inactivityTimeoutMins = this.inactivityTimeoutMins;
179+
const totalRequestTimeoutMins = this.totalRequestTimeoutMins;
180180
const msPerMin = 1000 * 60;
181181
const finalize = (finalMessage: string) => {
182182
if (isDone) {

0 commit comments

Comments
 (0)