Skip to content

Commit e63debc

Browse files
committed
buffbench: Wrap more of agent run in a timeout
1 parent 37980e7 commit e63debc

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

evals/buffbench/agent-runner.ts

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ export async function runAgentOnCommit({
5656
let finalCheckOutputs: FinalCheckOutput[] | undefined
5757

5858
try {
59-
await withTestRepo(
60-
{
61-
repoUrl,
62-
parentSha: commit.parentSha,
63-
initCommand,
64-
env,
65-
},
66-
async (repoDir) => {
67-
const timeoutMs = 30 * 60 * 1000 // 30 minutes
68-
const maxAgentSteps = 40
69-
const result = await withTimeout(
70-
client.run({
59+
const timeoutMs = 30 * 60 * 1000 // 30 minutes
60+
await withTimeout(
61+
withTestRepo(
62+
{
63+
repoUrl,
64+
parentSha: commit.parentSha,
65+
initCommand,
66+
env,
67+
},
68+
async (repoDir) => {
69+
const maxAgentSteps = 40
70+
const result = await client.run({
7171
agent: agentId,
7272
prompt: commit.prompt,
7373
agentDefinitions: localAgentDefinitions,
@@ -111,56 +111,56 @@ export async function runAgentOnCommit({
111111
}
112112
trace.push(event)
113113
},
114-
}),
115-
timeoutMs,
116-
`Agent ${agentId} timed out after ${timeoutMs / 1000} seconds`,
117-
)
118-
cost = result.sessionState.mainAgentState.creditsUsed / 100
119-
120-
execSync('git add .', { cwd: repoDir, stdio: 'ignore' })
121-
diff = execSync(`git diff ${commit.parentSha}`, {
122-
cwd: repoDir,
123-
encoding: 'utf-8',
124-
})
125-
126-
const contextFilePaths = new Set<string>([
127-
...commit.supplementalFiles,
128-
...commit.fileDiffs.map((fd) => fd.path),
129-
])
130-
for (const { status, path } of commit.fileDiffs) {
131-
if (status === 'added') {
132-
contextFilePaths.delete(path)
114+
})
115+
cost = result.sessionState.mainAgentState.creditsUsed / 100
116+
117+
execSync('git add .', { cwd: repoDir, stdio: 'ignore' })
118+
diff = execSync(`git diff ${commit.parentSha}`, {
119+
cwd: repoDir,
120+
encoding: 'utf-8',
121+
})
122+
123+
const contextFilePaths = new Set<string>([
124+
...commit.supplementalFiles,
125+
...commit.fileDiffs.map((fd) => fd.path),
126+
])
127+
for (const { status, path } of commit.fileDiffs) {
128+
if (status === 'added') {
129+
contextFilePaths.delete(path)
130+
}
131+
}
132+
133+
for (const filePath of contextFilePaths) {
134+
try {
135+
const content = execSync(
136+
`git show ${commit.parentSha}:${JSON.stringify(filePath)}`,
137+
{
138+
cwd: repoDir,
139+
encoding: 'utf-8',
140+
maxBuffer: 10 * 1024 * 1024,
141+
},
142+
)
143+
contextFiles[filePath] = content
144+
} catch (error) {
145+
contextFiles[filePath] = ''
146+
}
133147
}
134-
}
135-
136-
for (const filePath of contextFilePaths) {
137-
try {
138-
const content = execSync(
139-
`git show ${commit.parentSha}:${JSON.stringify(filePath)}`,
140-
{
141-
cwd: repoDir,
142-
encoding: 'utf-8',
143-
maxBuffer: 10 * 1024 * 1024,
144-
},
148+
149+
// Run final check commands if specified
150+
if (finalCheckCommands && finalCheckCommands.length > 0) {
151+
console.log(
152+
`[${commit.id}] Running ${finalCheckCommands.length} final check commands...`,
153+
)
154+
finalCheckOutputs = await runFinalCheckCommands(
155+
finalCheckCommands,
156+
repoDir,
157+
env,
145158
)
146-
contextFiles[filePath] = content
147-
} catch (error) {
148-
contextFiles[filePath] = ''
149159
}
150-
}
151-
152-
// Run final check commands if specified
153-
if (finalCheckCommands && finalCheckCommands.length > 0) {
154-
console.log(
155-
`[${commit.id}] Running ${finalCheckCommands.length} final check commands...`,
156-
)
157-
finalCheckOutputs = await runFinalCheckCommands(
158-
finalCheckCommands,
159-
repoDir,
160-
env,
161-
)
162-
}
163-
},
160+
},
161+
),
162+
timeoutMs,
163+
`Agent ${agentId} timed out after ${timeoutMs / 1000} seconds`,
164164
)
165165
} catch (e) {
166166
error = e instanceof Error ? `${e.message}\n${e.stack}` : String(e)

0 commit comments

Comments
 (0)