Skip to content

Commit bcff87e

Browse files
committed
handle undefined toolName
1 parent 45c8efd commit bcff87e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

backend/src/xml-stream-parser.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ export async function* processStreamWithTags(
101101
}
102102

103103
const toolName = parsedParams[toolNameParam] as keyof typeof processors
104-
const processor = processors[toolName] ?? defaultProcessor(toolName)
104+
const processor =
105+
typeof toolName === 'string'
106+
? processors[toolName] ?? defaultProcessor(toolName)
107+
: undefined
105108
if (!processor) {
106109
trackEvent(
107110
AnalyticsEvent.UNKNOWN_TOOL_CALL,
@@ -114,6 +117,11 @@ export async function* processStreamWithTags(
114117
autocompleted,
115118
},
116119
)
120+
onError(
121+
'parse_error',
122+
`Unknown tool ${JSON.stringify(toolName)} for tool call: ${contents}`,
123+
)
124+
return
117125
}
118126

119127
trackEvent(AnalyticsEvent.TOOL_USE, loggerOptions?.userId ?? '', {

0 commit comments

Comments
 (0)