mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:04:08 +03:00
782e0b42c9
Removed. A search for callers by name, attribute and string (Python, TypeScript, docs, the plugin API list and the frozen old-updater list) finds no supported path that reaches any of them: - tools/code_execution_tool.py::SANDBOX_AVAILABLE (constant True) and its two `if not SANDBOX_AVAILABLE` branches; the duplicated gateway-lifecycle comment in execute_code - tests: test_windows_returns_error (only flipped the constant) and the constant's monkeypatch in test_execute_code_lifecycle_guard_deadline - tools/checkpoint_manager.py: the no-op `store = _store_path(base)` / `_ = store` pair in _migrate_legacy_store; unused imports clear_stale_tmp_packs, rmtree_readonly, Dict, List, Set, Tuple; _list_project_refs (test-only) and its one assertion - hermes_cli/cli_auto_maintenance.py::_run_checkpoint_auto_maintenance (imported by cli.py, never called), its cli.py import, its orphaned `threading` import and its no-op test monkeypatch - tools/file_operations.py::ShellFileOperations._run_python_snippet - tools/file_operations_lint.py: the '.py' entry in LINTERS (the in-process LINTERS_INPROC['.py'] always answers first) - test_profile_rename_checkpoints: assert the migrate-identity retry deletes the leftover old checkpoint ref (via _ref_tip), replacing the deleted _list_project_refs check. - docs(checkpoints-and-rollback): auto-prune runs only on the gateway housekeeping tick; the CLI never runs it.
45 lines
2.1 KiB
Python
45 lines
2.1 KiB
Python
"""execute_code's gateway-lifecycle identity probe shares the cell deadline (#111922).
|
|
|
|
The same ``_is_supervised_gateway_process`` probe that wedged ``terminal_tool`` runs
|
|
ahead of every ``execute_code`` cell; a probe that renders no verdict must fail closed
|
|
within the deadline instead of holding the tool call (and its cron slot) forever.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import time
|
|
|
|
import tools.code_execution_tool as cet
|
|
import tools.terminal_tool as terminal_module
|
|
|
|
|
|
def test_wedged_lifecycle_probe_returns_bounded_error_without_running(monkeypatch):
|
|
from tools import process_registry
|
|
|
|
monkeypatch.setattr(cet, "_load_config", lambda: {"timeout": 0.05})
|
|
monkeypatch.setattr(terminal_module, "_PRE_EXEC_GUARD_MIN_TIMEOUT_S", 0)
|
|
monkeypatch.setattr(process_registry, "_is_supervised_gateway_process", lambda: time.sleep(1))
|
|
ran: list[str] = []
|
|
monkeypatch.setattr(cet, "_get_env_config", lambda: ran.append("env") or {"env_type": "local"}, raising=False)
|
|
|
|
start = time.monotonic()
|
|
result = json.loads(cet.execute_code("print('hi')"))
|
|
elapsed = time.monotonic() - start
|
|
|
|
assert elapsed < 0.5, f"lifecycle probe wedged execute_code for {elapsed:.2f}s"
|
|
assert "did not finish" in result["error"]
|
|
assert ran == [], "a probe with no verdict must not fail open into execution"
|
|
|
|
|
|
def test_interpreter_kill_in_execute_code_names_the_owned_process_route(monkeypatch):
|
|
"""Sibling surface of the terminal guard (#113667): an image-name kill inside a cell gets the same
|
|
proc_* / explicit-PID rejection, not the generic lifecycle text."""
|
|
from tools import process_registry
|
|
|
|
monkeypatch.setattr(process_registry, "_is_supervised_gateway_process", lambda: True)
|
|
result = json.loads(cet.execute_code('import subprocess; subprocess.run(["pkill", "-9", "python3"])'))
|
|
assert "proc_" in result["error"] and "explicit PID" in result["error"]
|
|
generic = json.loads(cet.execute_code('import os; os.system("hermes gateway restart")'))
|
|
assert "proc_" not in generic["error"] and "cannot restart or stop the gateway" in generic["error"]
|