mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(curator): make manual runs synchronous
This commit is contained in:
parent
bda7b240b4
commit
6b9f7140bb
3 changed files with 134 additions and 8 deletions
87
tests/hermes_cli/test_curator_run.py
Normal file
87
tests/hermes_cli/test_curator_run.py
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
"""Tests for `hermes curator run` CLI behavior."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
|
||||
def _args(**kwargs):
|
||||
values = {
|
||||
"dry_run": False,
|
||||
"synchronous": False,
|
||||
"background": False,
|
||||
}
|
||||
values.update(kwargs)
|
||||
return SimpleNamespace(**values)
|
||||
|
||||
|
||||
def test_run_defaults_to_synchronous(monkeypatch, capsys):
|
||||
import agent.curator as curator_state
|
||||
import hermes_cli.curator as curator_cli
|
||||
|
||||
calls = []
|
||||
monkeypatch.setattr(curator_state, "is_enabled", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
curator_state,
|
||||
"run_curator_review",
|
||||
lambda **kwargs: calls.append(kwargs) or {"auto_transitions": {}},
|
||||
)
|
||||
|
||||
assert curator_cli._cmd_run(_args()) == 0
|
||||
|
||||
assert calls[0]["synchronous"] is True
|
||||
assert calls[0]["dry_run"] is False
|
||||
assert "background" not in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_run_background_opts_into_async(monkeypatch, capsys):
|
||||
import agent.curator as curator_state
|
||||
import hermes_cli.curator as curator_cli
|
||||
|
||||
calls = []
|
||||
monkeypatch.setattr(curator_state, "is_enabled", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
curator_state,
|
||||
"run_curator_review",
|
||||
lambda **kwargs: calls.append(kwargs) or {"auto_transitions": {}},
|
||||
)
|
||||
|
||||
assert curator_cli._cmd_run(_args(background=True)) == 0
|
||||
|
||||
assert calls[0]["synchronous"] is False
|
||||
assert "llm pass running in background" in capsys.readouterr().out
|
||||
|
||||
|
||||
def test_run_sync_wins_over_background(monkeypatch):
|
||||
import agent.curator as curator_state
|
||||
import hermes_cli.curator as curator_cli
|
||||
|
||||
calls = []
|
||||
monkeypatch.setattr(curator_state, "is_enabled", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
curator_state,
|
||||
"run_curator_review",
|
||||
lambda **kwargs: calls.append(kwargs) or {"auto_transitions": {}},
|
||||
)
|
||||
|
||||
assert curator_cli._cmd_run(_args(synchronous=True, background=True)) == 0
|
||||
|
||||
assert calls[0]["synchronous"] is True
|
||||
|
||||
|
||||
def test_dry_run_default_reports_synchronous_wording(monkeypatch, capsys):
|
||||
import agent.curator as curator_state
|
||||
import hermes_cli.curator as curator_cli
|
||||
|
||||
monkeypatch.setattr(curator_state, "is_enabled", lambda: True)
|
||||
monkeypatch.setattr(
|
||||
curator_state,
|
||||
"run_curator_review",
|
||||
lambda **kwargs: {"auto_transitions": {}},
|
||||
)
|
||||
|
||||
assert curator_cli._cmd_run(_args(dry_run=True)) == 0
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert "When the report lands" not in out
|
||||
assert "Read the report with `hermes curator status`" in out
|
||||
|
|
@ -175,3 +175,28 @@ def test_status_no_skills_produces_clean_empty_output(curator_status_env):
|
|||
# None of the ranking sections render
|
||||
assert "most active" not in out
|
||||
assert "least active" not in out
|
||||
|
||||
|
||||
def test_status_marks_missing_last_report_path(monkeypatch, capsys, tmp_path):
|
||||
import agent.curator as curator_state
|
||||
import hermes_cli.curator as curator_cli
|
||||
import tools.skill_usage as skill_usage
|
||||
|
||||
missing_report = tmp_path / "stale-report"
|
||||
monkeypatch.setattr(curator_state, "load_state", lambda: {
|
||||
"paused": False,
|
||||
"last_run_at": None,
|
||||
"last_run_summary": "auto: no changes",
|
||||
"run_count": 1,
|
||||
"last_report_path": str(missing_report),
|
||||
})
|
||||
monkeypatch.setattr(curator_state, "is_enabled", lambda: True)
|
||||
monkeypatch.setattr(curator_state, "get_interval_hours", lambda: 168)
|
||||
monkeypatch.setattr(curator_state, "get_stale_after_days", lambda: 30)
|
||||
monkeypatch.setattr(curator_state, "get_archive_after_days", lambda: 90)
|
||||
monkeypatch.setattr(skill_usage, "agent_created_report", lambda: [])
|
||||
|
||||
assert curator_cli._cmd_status(SimpleNamespace()) == 0
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert f"last report: {missing_report} (missing)" in out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue