Skip to content

Commit 1fe9858

Browse files
committed
evals: do not throw error on invalid tool call
1 parent 691865c commit 1fe9858

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

backend/src/xml-stream-parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export async function* processStreamWithTags(
8383
},
8484
)
8585
const shortenedContents =
86-
contents.length < 50
86+
contents.length < 200
8787
? contents
88-
: contents.slice(0, 20) + '...' + contents.slice(-20)
88+
: contents.slice(0, 100) + '...' + contents.slice(-100)
8989
const errorMessage = `Invalid JSON: ${JSON.stringify(shortenedContents)}\nError: ${error.message}`
9090
onResponseChunk({
9191
type: 'error',

common/src/util/messages.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { has, isEqual } from 'lodash'
1+
import { cloneDeep, has, isEqual } from 'lodash'
22

33
import { buildArray } from './array'
4-
import { deepCopy } from './object'
54
import { getToolCallString } from '../tools/utils'
65

76
import type {
@@ -23,7 +22,7 @@ export function toContentString(msg: ModelMessage): string {
2322
export function withCacheControl<
2423
T extends { providerOptions?: ProviderMetadata },
2524
>(obj: T): T {
26-
const wrapper = deepCopy(obj)
25+
const wrapper = cloneDeep(obj)
2726
if (!wrapper.providerOptions) {
2827
wrapper.providerOptions = {}
2928
}
@@ -41,7 +40,7 @@ export function withCacheControl<
4140
export function withoutCacheControl<
4241
T extends { providerOptions?: ProviderMetadata },
4342
>(obj: T): T {
44-
const wrapper = deepCopy(obj)
43+
const wrapper = cloneDeep(obj)
4544
if (has(wrapper.providerOptions?.anthropic?.cacheControl, 'type')) {
4645
delete wrapper.providerOptions?.anthropic?.cacheControl?.type
4746
}

common/src/util/object.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,3 @@ export function errorToObject(value: any) {
129129
}
130130
return value
131131
}
132-
133-
export function deepCopy<T>(obj: T): T {
134-
return JSON.parse(JSON.stringify(obj)) as T
135-
}

evals/git-evals/run-git-evals.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { promptAiSdkStructured } from '@codebuff/backend/llm-apis/vercel-ai-sdk/
77
import { models } from '@codebuff/common/constants'
88
import { withTimeout } from '@codebuff/common/util/promise'
99
import { generateCompactId } from '@codebuff/common/util/string'
10+
import { cloneDeep } from 'lodash'
1011
import pLimit from 'p-limit'
1112

1213
import { resetRepoToCommit } from '../scaffolding'
@@ -487,7 +488,7 @@ export async function runGitEvals(
487488
`Completed eval for commit ${testRepoName} - ${evalCommit.spec.split('\n')[0]}`,
488489
)
489490
if (!logToStdout) {
490-
const finalResult = message.result
491+
const finalResult = cloneDeep(message.result)
491492
for (const cbTrace of finalResult.trace) {
492493
delete (cbTrace as any).steps
493494
}

evals/git-evals/runners/codebuff.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class CodebuffRunner implements Runner {
6262
prompt,
6363
handleEvent: (event) => {
6464
if (event.type === 'error') {
65-
throw new Error(event.message)
65+
console.log('\n\n' + JSON.stringify(event, null, 2))
6666
}
6767
if (event.type === 'text') {
6868
if (toolResults.length > 0) {

0 commit comments

Comments
 (0)