Agent Zero AI framework
Added: Contextual reminder for mcps with multi-step-processes for agent to not get distracted, to continue process.
deci36b6dc93cea6
diff --git a/python/helpers/mcp_handler.py b/python/helpers/mcp_handler.pyindex 666a85362..595cdb1e6 100644--- a/python/helpers/mcp_handler.py+++ b/python/helpers/mcp_handler.py@@ -5,6 +5,7 @@ import asynciofrom contextlib import AsyncExitStackfrom shutil import whichfrom datetime import timedelta+import jsonimport os# print(f"DEBUG: Listing /opt/venv/lib/python3.11/site-packages/ before mcp import: {os.listdir('/opt/venv/lib/python3.11/site-packages/')}") # This line caused FileNotFoundError, **FOR CUDA CHANGE TO '3.12'**@@ -70,6 +71,9 @@ class MCPTool(Tool):else:text = response.message.strip()+ # Add a general contextual reminder for multi-step processes+ text += f"\n\n[Contextual Reminder for {self.name}: If this action is part of an ongoing sequence, consider the next step with this tool. If the sequence is complete, analyze the final output and report to the user or proceed accordingly.]"+self.agent.hist_add_tool_result(self.name, text)(PrintStyle(font_color="#1B4F72", background_color="white", padding=True, bold=True)@@ -487,7 +491,9 @@ class MCPClientBase(ABC):PrintStyle(font_color="cyan").print(f"MCPClientBase ({self.server.name} - {operation_name}): Session and transport will be closed by AsyncExitStack.")- # temp_stack.aclose() is called automatically here.+ # This line should ideally be unreachable if the try/except/finally logic within the 'async with' is exhaustive.+ # Adding it to satisfy linters that might not fully trace the raise/return paths through async context managers.+ raise RuntimeError(f"MCPClientBase ({self.server.name} - {operation_name}): _execute_with_session exited 'async with' block unexpectedly.")async def update_tools(self) -> "MCPClientBase":PrintStyle(font_color="cyan").print(f"MCPClientBase ({self.server.name}): Starting 'update_tools' operation...")