b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
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
|