Skip to content

Commit 60da5fb

Browse files
committed
Pass env through to agents
1 parent 43ad60c commit 60da5fb

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

evals/buffbench/agent-runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export async function runAgentOnCommit({
7777
if (externalAgentType) {
7878
const runner: Runner =
7979
externalAgentType === 'claude'
80-
? new ClaudeRunner(repoDir)
81-
: new CodexRunner(repoDir)
80+
? new ClaudeRunner(repoDir, env)
81+
: new CodexRunner(repoDir, env)
8282

8383
console.log(
8484
`[${commit.id}] Running external agent: ${externalAgentType}`,

evals/buffbench/runners/claude.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ import type {
99

1010
export class ClaudeRunner implements Runner {
1111
private cwd: string
12+
private env: Record<string, string>
1213

13-
constructor(cwd: string) {
14+
constructor(cwd: string, env: Record<string, string> = {}) {
1415
this.cwd = cwd
16+
this.env = env
1517
}
1618

1719
async run(prompt: string): Promise<RunnerResult> {
@@ -34,6 +36,7 @@ export class ClaudeRunner implements Runner {
3436
cwd: this.cwd,
3537
env: {
3638
...process.env,
39+
...this.env,
3740
// Ensure ANTHROPIC_API_KEY is set from CLAUDE_CODE_KEY if available
3841
ANTHROPIC_API_KEY:
3942
process.env.CLAUDE_CODE_KEY || process.env.ANTHROPIC_API_KEY,
@@ -156,9 +159,7 @@ export class ClaudeRunner implements Runner {
156159

157160
if (code !== 0) {
158161
reject(
159-
new Error(
160-
`Claude CLI exited with code ${code}. stderr: ${stderr}`,
161-
),
162+
new Error(`Claude CLI exited with code ${code}. stderr: ${stderr}`),
162163
)
163164
return
164165
}

evals/buffbench/runners/codex.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import type { AgentStep } from '../agent-runner'
55

66
export class CodexRunner implements Runner {
77
private cwd: string
8+
private env: Record<string, string>
89

9-
constructor(cwd: string) {
10+
constructor(cwd: string, env: Record<string, string> = {}) {
1011
this.cwd = cwd
12+
this.env = env
1113
}
1214

1315
async run(prompt: string): Promise<RunnerResult> {
@@ -25,8 +27,12 @@ export class CodexRunner implements Runner {
2527

2628
const child = spawn('codex', args, {
2729
cwd: this.cwd,
28-
env: process.env,
29-
stdio: ['pipe', 'pipe', 'pipe'],
30+
env: {
31+
...process.env,
32+
...this.env,
33+
},
34+
// Use 'ignore' for stdin to prevent the CLI from waiting for input
35+
stdio: ['ignore', 'pipe', 'pipe'],
3036
})
3137

3238
let stdout = ''
@@ -47,7 +53,10 @@ export class CodexRunner implements Runner {
4753
type: 'text',
4854
text: event.content || event.message || '',
4955
})
50-
} else if (event.type === 'function_call' || event.type === 'tool') {
56+
} else if (
57+
event.type === 'function_call' ||
58+
event.type === 'tool'
59+
) {
5160
steps.push({
5261
type: 'tool_call',
5362
toolName: event.name || event.function?.name || 'unknown',
@@ -111,9 +120,7 @@ export class CodexRunner implements Runner {
111120

112121
if (code !== 0) {
113122
reject(
114-
new Error(
115-
`Codex CLI exited with code ${code}. stderr: ${stderr}`,
116-
),
123+
new Error(`Codex CLI exited with code ${code}. stderr: ${stderr}`),
117124
)
118125
return
119126
}

0 commit comments

Comments
 (0)