Skip to content

Commit eeb8acf

Browse files
AlemTuzlaktombeckenham
authored andcommitted
fix(ai-code-mode-models-eval): handle multimodal tool result content in metrics
ToolResultPart.content was widened to string | Array<ContentPart> for multimodal tool results, breaking the string-typed lookup in metrics.ts. Coerce non-string content to a serialized form so the type check passes while preserving the existing execute_typescript JSON-parse behavior.
1 parent ccc044b commit eeb8acf

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/ai-code-mode/models-eval/metrics.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ export function computeMetrics(messages: Array<UIMessage>): ComputedMetrics {
7676

7777
if (part.type === 'tool-result') {
7878
toolResultLookup.set(part.toolCallId, {
79-
content: part.content,
79+
// `content` may be multimodal (`Array<ContentPart>`) since tool
80+
// results can now carry images/etc. The eval only inspects the JSON
81+
// string `execute_typescript` returns, so coerce non-string content
82+
// to a serialized form that `safeJsonParse` can handle.
83+
content:
84+
typeof part.content === 'string'
85+
? part.content
86+
: JSON.stringify(part.content),
8087
state: part.state,
8188
error: part.error,
8289
})

0 commit comments

Comments
 (0)