mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
19128108ac
- aux_config: drop session_search from _AUX_TASKS and remove stale test
(PR #27590 removed auxiliary.session_search from DEFAULT_CONFIG)
- compression_boundary_hook: set compressor._last_compress_aborted=False
on MagicMock so the post-compress abort branch (PR #28117) doesn't
short-circuit before the session-id rotation under test
- kanban_dashboard_plugin: use consecutive_failures=3 so severity stays
'error' (failure_threshold default dropped from 3 to 2 in d9fef0c8a,
so failures=5 now crosses the critical floor of 2*2=4)
- cli_manual_compress: accept force kwarg on DummyAgent._compress_context
(cli._manual_compress now passes force=True)
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
from contextlib import nullcontext
|
|
|
|
from cli import HermesCLI
|
|
|
|
|
|
class DummyAgent:
|
|
def __init__(self):
|
|
self.compression_enabled = True
|
|
self._cached_system_prompt = "FULL CACHED SYSTEM PROMPT SHOULD NOT BE NESTED"
|
|
self.session_id = "new-session"
|
|
self.calls = []
|
|
|
|
def _compress_context(self, messages, system_message, *, approx_tokens=None, focus_topic=None, force=False):
|
|
self.calls.append(
|
|
{
|
|
"messages": messages,
|
|
"system_message": system_message,
|
|
"approx_tokens": approx_tokens,
|
|
"focus_topic": focus_topic,
|
|
"force": force,
|
|
}
|
|
)
|
|
return ([{"role": "user", "content": "[CONTEXT SUMMARY]: compacted"}], "new system prompt")
|
|
|
|
|
|
def test_manual_compress_does_not_pass_cached_system_prompt(monkeypatch):
|
|
"""Manual /compress should rebuild the next prompt without nesting the old one."""
|
|
cli = HermesCLI.__new__(HermesCLI)
|
|
cli.conversation_history = [
|
|
{"role": "user", "content": "one"},
|
|
{"role": "assistant", "content": "two"},
|
|
{"role": "user", "content": "three"},
|
|
{"role": "assistant", "content": "four"},
|
|
]
|
|
cli.agent = DummyAgent()
|
|
cli.session_id = "old-session"
|
|
cli._pending_title = "old title"
|
|
cli._busy_command = lambda _message: nullcontext()
|
|
|
|
monkeypatch.setattr(
|
|
"agent.manual_compression_feedback.summarize_manual_compression",
|
|
lambda *args, **kwargs: {
|
|
"noop": False,
|
|
"headline": "compressed",
|
|
"token_line": "tokens reduced",
|
|
"note": "",
|
|
},
|
|
)
|
|
|
|
cli._manual_compress("/compress database schema")
|
|
|
|
assert len(cli.agent.calls) == 1
|
|
call = cli.agent.calls[0]
|
|
assert call["system_message"] is None
|
|
assert call["system_message"] != cli.agent._cached_system_prompt
|
|
assert call["focus_topic"] == "database schema"
|
|
assert cli.session_id == "new-session"
|
|
assert cli._pending_title is None
|