From f6b408ae8af4fec5c54809111a1bfd7cc08e100e Mon Sep 17 00:00:00 2001 From: Sun Tao <2605127667@qq.com> Date: Wed, 28 Jan 2026 15:40:08 +0800 Subject: [PATCH] update --- backend/app/utils/agent.py | 15 ++++----------- src/store/chatStore.ts | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/backend/app/utils/agent.py b/backend/app/utils/agent.py index 86639305..f9359589 100644 --- a/backend/app/utils/agent.py +++ b/backend/app/utils/agent.py @@ -17,7 +17,8 @@ import contextvars import json import os import platform -from threading import Event, Lock +import time +from threading import Event, Lock, current_thread import traceback from typing import Any, Callable, Dict, List, Tuple import uuid @@ -556,16 +557,8 @@ class ListenChatAgent(ChatAgent): with set_process_task(self.process_task_id): # Try different invocation paths in order of preference if hasattr(tool, "func") and hasattr(tool.func, "async_call"): - # Case: FunctionTool wrapping an MCP tool - # Check if the wrapped tool is sync to avoid run_in_executor - if hasattr(tool, "is_async") and not tool.is_async: - # Sync tool: call directly to preserve ContextVar - result = tool(**args) - if asyncio.iscoroutine(result): - result = await result - else: - # Async tool: use async_call - result = await tool.func.async_call(**args) + # MCP FunctionTool: always use async_call (sync wrapper can timeout) + result = await tool.func.async_call(**args) elif hasattr(tool, "async_call") and callable(tool.async_call): # Case: tool itself has async_call diff --git a/src/store/chatStore.ts b/src/store/chatStore.ts index b0f36657..a1dd0017 100644 --- a/src/store/chatStore.ts +++ b/src/store/chatStore.ts @@ -614,7 +614,7 @@ const chatStore = (initial?: Partial) => createStore()( api_key: apiModel.api_key, api_url: apiModel.api_url, extra_params: apiModel.extra_params, - installed_mcp: { mcpServers: {} }, + installed_mcp: (mcpLocal && Object.keys(mcpLocal).length > 0) ? mcpLocal : { mcpServers: {} }, language: systemLanguage, allow_local_system: true, attaches: (messageAttaches || targetChatStore.getState().tasks[newTaskId]?.attaches || []).map(f => f.filePath),