Agent Zero AI framework
fix: release Paramiko import traceback
Alessandro0ddb5fb31d2a
diff --git a/plugins/_code_execution/helpers/shell_ssh.py b/plugins/_code_execution/helpers/shell_ssh.pyindex fd035d233..9092b9bad 100644--- a/plugins/_code_execution/helpers/shell_ssh.py+++ b/plugins/_code_execution/helpers/shell_ssh.py@@ -7,6 +7,10 @@ from helpers.log import Logfrom helpers.print_style import PrintStyle# from helpers.strings import calculate_valid_match_lengths+# Paramiko caches this optional import error; its traceback retains our tool-loading stack.+if paramiko.config.invoke_import_error:+ paramiko.config.invoke_import_error.__traceback__ = None+# Injected into every new SSH shell to keep it safe for non-interactive use.# Pagers (more/less) would otherwise block forever waiting for input thatdiff --git a/tests/test_code_execution_pager.py b/tests/test_code_execution_pager.pyindex 19d51758e..e9576f5a9 100644--- a/tests/test_code_execution_pager.py+++ b/tests/test_code_execution_pager.py@@ -5,6 +5,7 @@ code execution tool: without user input they block forever and spin at 100% CPU."""import asyncio+import importlibfrom types import SimpleNamespacefrom plugins._code_execution.helpers import shell_local, shell_ssh@@ -43,6 +44,19 @@ def test_ssh_command_disables_pagers():assert "PAGER=cat" in shell_ssh.PAGER_DISABLE_COMMAND+def test_paramiko_import_error_does_not_retain_tool_loading_stack(monkeypatch):+ try:+ raise ImportError("invoke")+ except ImportError as error:+ saved_error = error+ monkeypatch.setattr(shell_ssh.paramiko.config, "invoke_import_error", error)++ importlib.reload(shell_ssh)++ assert shell_ssh.paramiko.config.invoke_import_error is saved_error+ assert saved_error.__traceback__ is None++def test_multiline_terminal_commands_are_one_current_shell_compound():assert _group_multiline_command("pwd") == "pwd"assert _group_multiline_command("cd /tmp\npwd") == "{\ncd /tmp\npwd\n}"