Skip to content

Commit d7f63cd

Browse files
committed
fix typecheck
1 parent 0f6004b commit d7f63cd

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

evals/git-evals/prompting-agent.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,28 @@ Note that files can only be changed with tools. If no tools are called, no files
7979
8080
Analyze the conversation and decide your next action.`
8181

82+
let lastErrorMessage = ''
8283
const result = await client.run({
8384
agent: 'eval-prompting-agent',
8485
prompt,
8586
agentDefinitions: [promptingAgentDefinition],
8687
maxAgentSteps: 5,
8788
handleEvent: (event) => {
8889
console.log('event:', event)
90+
if (event.type === 'error') {
91+
lastErrorMessage = event.message
92+
}
8993
},
9094
})
9195

96+
if (!result) {
97+
return {
98+
decision: 'halt',
99+
reasoning: `No valid response from prompting agent. Error:\n${lastErrorMessage}`,
100+
next_prompt: '',
101+
}
102+
}
103+
92104
const output = result.sessionState.mainAgentState.output
93105
if (output) {
94106
return output as z.infer<typeof AgentDecisionSchema>

evals/git-evals/runners/codebuff.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path'
22

3-
import { API_KEY_ENV_VAR } from '@codebuff/common/old-constants'
43
import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
4+
import { API_KEY_ENV_VAR } from '@codebuff/common/old-constants'
55
import { loadLocalAgents } from '@codebuff/npm-app/agents/load-agents'
66
import { getUserCredentials } from '@codebuff/npm-app/credentials'
77

@@ -41,9 +41,6 @@ export class CodebuffRunner implements Runner {
4141
const client = new CodebuffClient({
4242
apiKey,
4343
cwd: this.runState.sessionState.fileContext.cwd,
44-
onError: (error) => {
45-
throw new Error(error.message)
46-
},
4744
})
4845

4946
const agentsPath = path.join(__dirname, '../../../.agents')
@@ -57,13 +54,15 @@ export class CodebuffRunner implements Runner {
5754
localAgentDefinitions.map((a) => a.id),
5855
)
5956

60-
this.runState = await client.run({
57+
let lastErrorMessage = ''
58+
const run = await client.run({
6159
agent: this.agent,
6260
previousRun: this.runState,
6361
prompt,
6462
handleEvent: (event) => {
6563
if (event.type === 'error') {
6664
console.log('\n\n' + JSON.stringify(event, null, 2))
65+
lastErrorMessage = event.message
6766
}
6867
if (event.type === 'text') {
6968
if (toolResults.length > 0) {
@@ -98,7 +97,11 @@ export class CodebuffRunner implements Runner {
9897
})
9998
flushStep()
10099

101-
client.closeConnection()
100+
if (!run) {
101+
throw new Error(`Failed to run Codebuff:\n${lastErrorMessage}`)
102+
}
103+
104+
this.runState = run
102105

103106
return {
104107
steps,

0 commit comments

Comments
 (0)