The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): capture terminating restored imports
fangliquanflq68f9681acb91
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex cf64673d9e4..d4a6cb41be2 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -708,11 +708,15 @@ def _critical_module_import_failures(" except Exception as exc:\n"" if %r:\n"" failures.append((name, str(exc)))\n"+ " except BaseException as exc:\n"+ " if %r:\n"+ " failures.append((name, str(exc)))\n""sys.stdout.write('\\n%s' + json.dumps(failures))\n"% (_UPDATE_CRITICAL_MODULES,tuple(sorted(FIRST_PARTY_MODULE_ROOTS)),report_runtime_errors,+ report_runtime_errors,marker,))diff --git a/tests/hermes_cli/test_update_autostash.py b/tests/hermes_cli/test_update_autostash.pyindex b189151fc77..8735c7b0855 100644--- a/tests/hermes_cli/test_update_autostash.py+++ b/tests/hermes_cli/test_update_autostash.py@@ -610,6 +610,53 @@ def test_restore_rejects_later_failure_masked_by_preexisting_failure(assert "gateway was not restarted" in output+def test_restore_rejects_system_exit_masked_by_preexisting_failure(+ monkeypatch, tmp_path, capsys+):+ """A terminating import must be compared instead of hiding the marker."""+ import subprocess+ from hermes_cli import update_cmd++ def git(*args, check=True):+ return subprocess.run(+ ["git", *args],+ cwd=tmp_path,+ capture_output=True,+ text=True,+ check=check,+ )++ git("init", "-q", "-b", "main")+ git("config", "user.email", "[email protected]")+ git("config", "user.name", "t")+ (tmp_path / "first.py").write_text(+ "raise RuntimeError('missing local config')\n", encoding="utf-8"+ )+ second = tmp_path / "second.py"+ second.write_text("VALUE = 1\n", encoding="utf-8")+ git("add", "-A")+ git("commit", "-qm", "init")++ second.write_text("raise SystemExit('restored exit')\n", encoding="utf-8")+ stash_ref = hermes_main._stash_local_changes_if_needed(["git"], tmp_path)+ assert stash_ref+ monkeypatch.setattr(update_cmd, "_UPDATE_CRITICAL_MODULES", ("first", "second"))++ with pytest.raises(SystemExit) as exc_info:+ hermes_main._restore_stashed_changes(+ ["git"], tmp_path, stash_ref, prompt_user=False+ )++ assert exc_info.value.code == 1+ assert second.read_text(encoding="utf-8") == "VALUE = 1\n"+ assert git("status", "--porcelain").stdout == ""+ assert git("stash", "list").stdout.strip()+ output = capsys.readouterr().out+ assert "agent import second" in output+ assert "restored exit" in output+ assert "gateway was not restarted" in output++def test_gateway_restore_prompt_defaults_to_keep_stash(tmp_path, capsys):prompts = []