diff --git a/backend/app/utils/agent.py b/backend/app/utils/agent.py index ac7143dd..68c6b24d 100644 --- a/backend/app/utils/agent.py +++ b/backend/app/utils/agent.py @@ -1,5 +1,6 @@ import asyncio import contextvars +import copy import json import os import platform @@ -835,8 +836,9 @@ class ListenChatAgent(ChatAgent): new_agent.process_task_id = self.process_task_id # Preserve model_config_dict (including stream setting) from original agent + # Use deep copy to ensure isolation - nested dicts won't affect other agents if hasattr(self, 'model_backend') and hasattr(self.model_backend, 'model_config_dict'): - new_agent.model_backend.model_config_dict.update(self.model_backend.model_config_dict) + new_agent.model_backend.model_config_dict = copy.deepcopy(self.model_backend.model_config_dict) # Copy memory if requested if with_memory: diff --git a/src/store/chatStore.ts b/src/store/chatStore.ts index 04872073..5c8468f6 100644 --- a/src/store/chatStore.ts +++ b/src/store/chatStore.ts @@ -849,18 +849,16 @@ const chatStore = (initial?: Partial) => createStore()( // Handle streaming agent output during task execution if (agentMessages.step === "streaming_agent_output") { - const data = agentMessages.data as { process_task_id?: string; content?: string; is_final?: boolean }; - const { process_task_id, content, is_final } = data; - const currentId = getCurrentTaskId(); + const { process_task_id, content, is_final } = agentMessages.data; if (!process_task_id) return; if (is_final) { // Clear streaming output when final marker received - clearStreamingAgentOutput(currentId, process_task_id); + clearStreamingAgentOutput(currentTaskId, process_task_id); } else if (content) { // Append streaming content - updateStreamingAgentOutput(currentId, process_task_id, content); + updateStreamingAgentOutput(currentTaskId, process_task_id, content); } return; } diff --git a/src/types/chatbox.d.ts b/src/types/chatbox.d.ts index 94beef44..e61b59ca 100644 --- a/src/types/chatbox.d.ts +++ b/src/types/chatbox.d.ts @@ -127,6 +127,8 @@ declare global { current_length?: number; max_length?: number; text?: string; + // Streaming agent output + is_final?: boolean; }; status?: 'running' | 'filled' | 'completed'; }