mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-14 14:12:44 +00:00
fix(context): clamp -1 post-compression sentinel in sibling status paths
Whole-bug-class follow-up to the tui_gateway fix: the same -1 last_prompt_tokens sentinel (parked by conversation_compression after a compression) leaked into other status readers, producing a raw -1 or a NEGATIVE usage_percent on the transitional turn: - agent/context_engine.py get_status() (the ABC default every external context engine inherits) — highest blast radius - gateway/slash_commands.py /usage context line - cli.py session usage printout All clamped to >=0, mirroring cli.py _get_status_bar_snapshot and the tui_gateway fix. Adds an ABC get_status sentinel-clamp regression test.
This commit is contained in:
parent
b6d8fc41c8
commit
8db6ed7bd9
5 changed files with 26 additions and 8 deletions
|
|
@ -120,6 +120,16 @@ class TestDefaults:
|
|||
assert status["threshold_tokens"] == 100000
|
||||
assert 0 < status["usage_percent"] <= 100
|
||||
|
||||
def test_default_get_status_clamps_post_compression_sentinel(self):
|
||||
"""After a compression, last_prompt_tokens is the -1 sentinel. get_status
|
||||
must clamp it to 0 rather than export a raw -1 or a negative
|
||||
usage_percent on the transitional turn."""
|
||||
engine = StubEngine()
|
||||
engine.last_prompt_tokens = -1
|
||||
status = engine.get_status()
|
||||
assert status["last_prompt_tokens"] == 0
|
||||
assert status["usage_percent"] >= 0
|
||||
|
||||
def test_on_session_reset(self):
|
||||
engine = StubEngine()
|
||||
engine.last_prompt_tokens = 999
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue