fix: handle non-string tool results to fix #631 (#633)

- Backend: Convert non-string content (lists, dicts) to JSON strings in _create_event_stream_message to ensure frontend always receives string content
- Frontend: Add type guard before calling startsWith() on toolCall.result for defensive programming

This fixes the TypeError: toolCall.result.startsWith is not a function when tools return complex objects.
This commit is contained in:
Willem Jiang
2025-10-20 23:10:58 +08:00
committed by GitHub
parent 984aa69acf
commit 3689bc0e69
2 changed files with 6 additions and 2 deletions

View File

@@ -105,7 +105,7 @@ const ActivityListItem = React.memo(({ messageId }: { messageId: string }) => {
if (message) {
if (!message.isStreaming && message.toolCalls?.length) {
for (const toolCall of message.toolCalls) {
if (toolCall.result?.startsWith("Error")) {
if (typeof toolCall.result === "string" && toolCall.result?.startsWith("Error")) {
return null;
}
if (toolCall.name === "web_search") {