From 9862e478422c5fd36461cca680eb982b0c436881 Mon Sep 17 00:00:00 2001 From: RoomWithOutRoof Date: Thu, 12 Mar 2026 14:51:00 +0800 Subject: [PATCH 1/2] fix: change request.get to requests.get in README example The example code incorrectly uses request.get() instead of requests.get(). This is a simple documentation fix to ensure accuracy. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d41fe4e..78493833 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ llm_cfg = { # Step 3: Create an agent. Here we use the `Assistant` agent as an example, which is capable of using tools and reading files. system_instruction = '''After receiving the user's request, you should: - first draw an image and obtain the image url, -- then run code `request.get(image_url)` to download the image, +- then run code `requests.get(image_url)` to download the image, - and finally select an image operation from the given document to process the image. Please show the image using `plt.show()`.''' tools = ['my_image_gen', 'code_interpreter'] # `code_interpreter` is a built-in tool for executing code. For configuration details, please refer to the FAQ. From 3f78deaa5fa4065aca6da59def50839f290457a8 Mon Sep 17 00:00:00 2001 From: Jah-yee Date: Thu, 12 Mar 2026 19:05:25 +0800 Subject: [PATCH 2/2] Fix thread-unsafe singleton pattern in MCPManager Add thread-safe singleton using double-checked locking pattern. This prevents race conditions when multiple threads try to create the MCPManager instance simultaneously (e.g., in Gradio WebUI or ASGI server environments). Fixes: #812 --- qwen_agent/tools/mcp_manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qwen_agent/tools/mcp_manager.py b/qwen_agent/tools/mcp_manager.py index 9920978f..dbf8e072 100644 --- a/qwen_agent/tools/mcp_manager.py +++ b/qwen_agent/tools/mcp_manager.py @@ -30,10 +30,14 @@ class MCPManager: _instance = None # Private class variable to store the unique instance + _lock = threading.Lock() # Lock for thread-safe singleton def __new__(cls, *args, **kwargs): if cls._instance is None: - cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs) + with cls._lock: + # Double-checked locking pattern + if cls._instance is None: + cls._instance = super(MCPManager, cls).__new__(cls, *args, **kwargs) return cls._instance def __init__(self):