mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
"""Regression tests for the SUMMARY_PREFIX tool-use clause (#65848 class).
|
|
|
|
The REFERENCE ONLY framing must keep its anti-resumption protections while
|
|
explicitly NOT restricting tool use — the strong wording was observed bleeding
|
|
into general tool-use suppression (narration-only turns after compression).
|
|
"""
|
|
|
|
from agent.context_compressor import (
|
|
_HISTORICAL_SUMMARY_PREFIXES,
|
|
LEGACY_SUMMARY_PREFIX,
|
|
SUMMARY_PREFIX,
|
|
)
|
|
|
|
|
|
class TestSummaryPrefixToolUseClause:
|
|
|
|
|
|
def test_previous_generation_frozen_in_historical_prefixes(self):
|
|
"""Per the module contract: whenever SUMMARY_PREFIX changes, the prior
|
|
generation must be frozen into _HISTORICAL_SUMMARY_PREFIXES so old
|
|
persisted summaries still get the directive-strip on re-compaction."""
|
|
assert len(_HISTORICAL_SUMMARY_PREFIXES) >= 3
|
|
# The pre-clause generation (#65848 incident era): same framing, no
|
|
# tools-active clause. Newer generations are prepended ahead of it as
|
|
# the prefix evolves (tuple is newest-first), so match by content,
|
|
# not position. "topic overlap" distinguishes it from the older
|
|
# carveout-era entry.
|
|
pre_clause = [
|
|
p for p in _HISTORICAL_SUMMARY_PREFIXES
|
|
if "tools remain fully active" not in p
|
|
and "topic overlap" in p.lower()
|
|
and "Do NOT answer questions or fulfill requests" in p
|
|
]
|
|
assert pre_clause, "pre-clause generation missing from frozen tuple"
|
|
assert all(p != SUMMARY_PREFIX for p in pre_clause)
|
|
|
|
|
|
def test_strip_recognizes_current_and_frozen_prefixes(self):
|
|
"""Re-compaction normalization must strip both the live prefix and the
|
|
newly frozen one (the incident generation)."""
|
|
from agent.context_compressor import ContextCompressor
|
|
|
|
for prefix in (SUMMARY_PREFIX, _HISTORICAL_SUMMARY_PREFIXES[0]):
|
|
text = f"{prefix}\nsummary body here"
|
|
stripped = ContextCompressor._strip_summary_prefix(text)
|
|
assert "summary body here" in stripped
|
|
assert "REFERENCE ONLY" not in stripped
|