diff --git a/multi-agent-supervisor/agents/logs_analyzer.py b/multi-agent-supervisor/agents/logs_analyzer.py index 8125cfe..97bbff5 100644 --- a/multi-agent-supervisor/agents/logs_analyzer.py +++ b/multi-agent-supervisor/agents/logs_analyzer.py @@ -3,14 +3,14 @@ from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent from langchain_community.tools.shell.tool import ShellTool -from custom_tools import print_poem, configured_ssh_tool +from custom_tools import print_poem, configured_remote_server def create_logs_analyzer_worker(): """Create a logs analyzer agent that investigates system and application logs.""" - - tools = [ShellTool(), configured_ssh_tool, print_poem] - + + tools = [configured_remote_server, print_poem] + return create_react_agent( model=ChatOpenAI(model="gpt-4o-mini", temperature=0), tools=tools, diff --git a/multi-agent-supervisor/agents/os_detector.py b/multi-agent-supervisor/agents/os_detector.py index 35e8691..f1fe87a 100644 --- a/multi-agent-supervisor/agents/os_detector.py +++ b/multi-agent-supervisor/agents/os_detector.py @@ -3,13 +3,13 @@ from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent from langchain_community.tools.shell.tool import ShellTool -from custom_tools import print_poem, configured_ssh_tool +from custom_tools import print_poem, configured_remote_server def create_os_detector_worker(): """Create an OS detector agent that identifies system information and environment.""" - tools = [ShellTool(), configured_ssh_tool, print_poem] + tools = [configured_remote_server, print_poem] return create_react_agent( model=ChatOpenAI(model="gpt-4o-mini", temperature=0), diff --git a/multi-agent-supervisor/agents/performance_analyzer.py b/multi-agent-supervisor/agents/performance_analyzer.py index 9027101..3c38836 100644 --- a/multi-agent-supervisor/agents/performance_analyzer.py +++ b/multi-agent-supervisor/agents/performance_analyzer.py @@ -3,13 +3,13 @@ from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent from langchain_community.tools.shell.tool import ShellTool -from custom_tools import print_poem, configured_ssh_tool +from custom_tools import print_poem, configured_remote_server def create_performance_analyzer_worker(): """Create a performance analyzer agent that monitors and diagnoses performance issues.""" - tools = [ShellTool(), configured_ssh_tool, print_poem] + tools = [configured_remote_server, print_poem] return create_react_agent( model=ChatOpenAI(model="gpt-4o-mini", temperature=0), diff --git a/multi-agent-supervisor/custom_tools/__init__.py b/multi-agent-supervisor/custom_tools/__init__.py index 998129c..74c93b0 100644 --- a/multi-agent-supervisor/custom_tools/__init__.py +++ b/multi-agent-supervisor/custom_tools/__init__.py @@ -6,7 +6,7 @@ from langchain_community.tools.shell.tool import ShellTool # Pre-configured SSH tool for your server - only connects when actually used # TODO: Update these connection details for your actual server -configured_ssh_tool = SSHTool( +configured_remote_server = SSHTool( host="157.90.211.119", # Replace with your server port=8081, username="g", # Replace with your username @@ -15,4 +15,4 @@ configured_ssh_tool = SSHTool( ) -__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_ssh_tool"] +__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_remote_server"] diff --git a/multi-agent-supervisor/custom_tools/ssh_tool.py b/multi-agent-supervisor/custom_tools/ssh_tool.py index 17cc5b9..b4602a3 100644 --- a/multi-agent-supervisor/custom_tools/ssh_tool.py +++ b/multi-agent-supervisor/custom_tools/ssh_tool.py @@ -77,6 +77,8 @@ class SSHSession: def execute(self, command: str) -> str: """Execute a single command, handling sudo automatically.""" + print(f"🔧 Executing command: {command}") + if not self.client: self.connect() diff --git a/multi-agent-supervisor/main-multi-agent.py b/multi-agent-supervisor/main-multi-agent.py index 4ae411a..b3f3bd6 100644 --- a/multi-agent-supervisor/main-multi-agent.py +++ b/multi-agent-supervisor/main-multi-agent.py @@ -6,6 +6,7 @@ A supervisor-based system that coordinates specialized agents for system adminis import sys import warnings +import readline # Enable arrow key support and command history in input() from langchain_openai import ChatOpenAI from langchain_core.messages import HumanMessage from langgraph_supervisor import create_supervisor @@ -14,7 +15,7 @@ from agents import ( create_logs_analyzer_worker, create_performance_analyzer_worker ) -from custom_tools import print_poem +from custom_tools import print_poem, configured_remote_server # Suppress the shell tool warning since worker agents use it intentionally for sysadmin tasks warnings.filterwarnings("ignore", message="The shell tool has no safeguards by default. Use at your own risk.") @@ -93,7 +94,7 @@ Communication style: Remember: Your goal is to solve system problems efficiently by leveraging your team's specialized skills while maintaining a positive debugging experience! -IMPORTANT: You do NOT have direct access to shell commands or SSH. You must delegate all system tasks to your specialized agents.""", +IMPORTANT: You do NOT have direct access to shell commands or SSH. You must delegate all system tasks to your specialized agents. If you don't know which OS is running, use the OS Detector agent first.""", tools=[print_poem] # Supervisor only has poem tool - no shell/SSH access ) diff --git a/simple-react-agent/custom_tools/__init__.py b/simple-react-agent/custom_tools/__init__.py index 86e0107..077bb81 100644 --- a/simple-react-agent/custom_tools/__init__.py +++ b/simple-react-agent/custom_tools/__init__.py @@ -6,7 +6,7 @@ from langchain_community.tools.shell.tool import ShellTool # Pre-configured SSH tool for your server - only connects when actually used # TODO: Update these connection details for your actual server -configured_ssh_tool = SSHTool( +configured_remote_server = SSHTool( host="157.90.211.119", # Replace with your server port=8081, username="g", # Replace with your username @@ -14,4 +14,4 @@ configured_ssh_tool = SSHTool( ask_human_input=True # Safety confirmation ) -__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_ssh_tool"] +__all__ = ["print_poem", "SSHTool", "ShellTool", "configured_remote_server"] diff --git a/simple-react-agent/custom_tools/ssh_tool.py b/simple-react-agent/custom_tools/ssh_tool.py index 17cc5b9..b4602a3 100644 --- a/simple-react-agent/custom_tools/ssh_tool.py +++ b/simple-react-agent/custom_tools/ssh_tool.py @@ -77,6 +77,8 @@ class SSHSession: def execute(self, command: str) -> str: """Execute a single command, handling sudo automatically.""" + print(f"🔧 Executing command: {command}") + if not self.client: self.connect() diff --git a/simple-react-agent/main.py b/simple-react-agent/main.py index ed6863c..17c317a 100644 --- a/simple-react-agent/main.py +++ b/simple-react-agent/main.py @@ -1,10 +1,11 @@ import os import warnings +import readline # Enable arrow key support and command history in input() from langchain.chat_models import init_chat_model from langchain_community.tools.shell.tool import ShellTool from langgraph.prebuilt import create_react_agent from langchain_core.messages import HumanMessage -from custom_tools import print_poem, configured_ssh_tool +from custom_tools import print_poem, configured_remote_server # Suppress the shell tool warning since we're using it intentionally for sysadmin tasks warnings.filterwarnings("ignore", message="The shell tool has no safeguards by default. Use at your own risk.") @@ -20,7 +21,7 @@ def create_agent(): # Define the tools available to the agent shell_tool = ShellTool() - tools = [shell_tool, configured_ssh_tool, print_poem] + tools = [shell_tool, configured_remote_server, print_poem] # Create a ReAct agent with system administration debugging focus @@ -31,7 +32,7 @@ def create_agent(): ## CORE CAPABILITIES 1. **Local System Analysis**: Execute shell commands on the local machine (terminal tool) - 2. **Remote System Analysis**: Execute commands on remote servers via SSH (configured_ssh_tool) + 2. **Remote System Analysis**: Execute commands on remote servers via SSH (configured_remote_server) 3. **OS Detection**: Automatically detect the operating system and adapt commands accordingly 4. **Issue Diagnosis**: Analyze symptoms and systematically investigate root causes 5. **Problem Resolution**: Provide solutions and execute fixes when safe to do so @@ -39,7 +40,7 @@ def create_agent(): ## AVAILABLE TOOLS - **terminal**: Execute commands on the local machine - - **configured_ssh_tool**: Execute commands on the pre-configured remote server + - **configured_remote_server**: Execute commands on the pre-configured remote server - **print_poem**: Generate motivational poems for debugging sessions ## OPERATING SYSTEM AWARENESS