diff --git a/pkg/channels/manager_test.go b/pkg/channels/manager_test.go index 1a783cc3e..6c518780d 100644 --- a/pkg/channels/manager_test.go +++ b/pkg/channels/manager_test.go @@ -1214,7 +1214,7 @@ func TestSendWithRetry_ToolCallsPlaceholderDeleteAndFallsThroughToSend(t *testin ChatID: "123", Raw: map[string]string{ "message_kind": "tool_calls", - "tool_calls": `[{"tool_feedback_explanation":"Looking up config","function":{"name":"read_file","arguments":"{}"}}]`, + "tool_calls": `[{"id":"call_1","type":"function","function":{"name":"read_file","arguments":"{}"},"extra_content":{"tool_feedback_explanation":"Looking up config"}}]`, }, }, }) diff --git a/web/frontend/src/features/chat/assistant-message-state.ts b/web/frontend/src/features/chat/assistant-message-state.ts index b38b9c3a4..54eb6163f 100644 --- a/web/frontend/src/features/chat/assistant-message-state.ts +++ b/web/frontend/src/features/chat/assistant-message-state.ts @@ -1,8 +1,8 @@ import { parseToolCallsFromContent, parseToolCallsValue, -} from "@/features/chat/tool-calls.ts" -import type { AssistantMessageKind, ChatMessage } from "@/store/chat.ts" +} from "@/features/chat/tool-calls" +import type { AssistantMessageKind, ChatMessage } from "@/store/chat" type AssistantToolCalls = ChatMessage["toolCalls"] type ExistingAssistantMessageState = Pick @@ -15,7 +15,7 @@ export interface AssistantMessageCreateState { export interface AssistantMessageUpdateState { content: string - kind?: AssistantMessageKind + kind: AssistantMessageKind toolCalls?: AssistantToolCalls } @@ -100,9 +100,13 @@ export function parseAssistantMessageUpdateState( if (existing?.toolCalls) { return { content, + kind: existing.kind ?? "normal", toolCalls: undefined, } } - return { content } + return { + content, + kind: existing?.kind ?? "normal", + } } diff --git a/web/frontend/src/features/chat/tool-calls.ts b/web/frontend/src/features/chat/tool-calls.ts index bf306c5e5..31d685863 100644 --- a/web/frontend/src/features/chat/tool-calls.ts +++ b/web/frontend/src/features/chat/tool-calls.ts @@ -14,7 +14,9 @@ function parseLegacyToolFeedbackContent( const body = match[2]?.trim() ?? "" const codeFence = /```(?:json)?\r?\n([\s\S]*?)\r?\n```/m.exec(body) const argumentsText = codeFence?.[1]?.trim() ?? "" - const explanation = body.replace(/```(?:json)?\r?\n[\s\S]*?\r?\n```/gm, "").trim() + const explanation = body + .replace(/```(?:json)?\r?\n[\s\S]*?\r?\n```/gm, "") + .trim() return [ {