From a58089cf48659195ddf7151e90d53628dbed68da Mon Sep 17 00:00:00 2001 From: YueGuobin Date: Sat, 14 Mar 2026 00:34:06 +0800 Subject: [PATCH] fix(copilot): add exit command warning to prevent session disconnection Add warnings about 'exit' command in three locations to prevent AI from disconnecting Telnet/SSH sessions during command execution: - Prompt system rules (lab_automation_assistant_prompt.py) - Display tool description (display_tools_nornir.py) - Config tool description (config_tools_nornir.py) The 'exit' command disconnects the session and causes all subsequent commands in the batch to fail. This prevents users from viewing command outputs properly. --- .../gns3_copilot/prompts/lab_automation_assistant_prompt.py | 1 + gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py | 1 + gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py | 1 + 3 files changed, 3 insertions(+) diff --git a/gns3server/agent/gns3_copilot/prompts/lab_automation_assistant_prompt.py b/gns3server/agent/gns3_copilot/prompts/lab_automation_assistant_prompt.py index 93e606a6c..ae8e9d1a4 100644 --- a/gns3server/agent/gns3_copilot/prompts/lab_automation_assistant_prompt.py +++ b/gns3server/agent/gns3_copilot/prompts/lab_automation_assistant_prompt.py @@ -69,6 +69,7 @@ You have access to the following tools to help users: 2. **Topology Awareness**: If topology is in context, DO NOT call reader again 3. **Efficient Operations**: Batch commands for multiple devices when possible 4. **Safety First**: Be cautious with destructive operations (reload, erase, format) +5. **CRITICAL - NEVER use 'exit' command**: This disconnects the Telnet/SSH session and causes all subsequent commands to fail. Never include 'exit' in command lists. --- diff --git a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py index 7dfcc3a02..13a2927fe 100644 --- a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py +++ b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py @@ -162,6 +162,7 @@ class ExecuteMultipleDeviceConfigCommands(BaseTool): - boot system commands - factory-reset commands - any commands that require user confirmation prompts + - NEVER use 'exit' command - this disconnects the session and breaks subsequent commands """ def _run( diff --git a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py index f30a79dee..abe7eae47 100644 --- a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py +++ b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py @@ -146,6 +146,7 @@ class ExecuteMultipleDeviceCommands(BaseTool): **STRICTLY FORBIDDEN:** - NO configuration commands (configure terminal, interface, router, etc.) - NO commands that modify device state + - NEVER use 'exit' command - this disconnects the session and breaks subsequent commands - If you need to configure, provide guidance to the student instead **Input Format:**