mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
fix(context-engine): adapt quiet compaction status to turn-context refactor
This commit is contained in:
parent
28dced2440
commit
d81a3dbfbb
2 changed files with 14 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ from agent.conversation_compression import (
|
|||
PREFLIGHT_COMPRESSION_STATUS_TEMPLATE,
|
||||
conversation_history_after_compression,
|
||||
)
|
||||
from agent.context_engine import automatic_compaction_status_message
|
||||
from agent.iteration_budget import IterationBudget
|
||||
from agent.memory_manager import build_memory_context_block
|
||||
from agent.model_metadata import (
|
||||
|
|
@ -772,12 +773,20 @@ def build_turn_context(
|
|||
agent.model,
|
||||
f"{_compressor.context_length:,}",
|
||||
)
|
||||
agent._emit_status(
|
||||
PREFLIGHT_COMPRESSION_STATUS_TEMPLATE.format(
|
||||
_preflight_status = automatic_compaction_status_message(
|
||||
_compressor,
|
||||
phase="preflight",
|
||||
default_message=PREFLIGHT_COMPRESSION_STATUS_TEMPLATE.format(
|
||||
tokens=_preflight_tokens,
|
||||
threshold=_compressor.threshold_tokens,
|
||||
)
|
||||
),
|
||||
approx_tokens=_preflight_tokens,
|
||||
threshold_tokens=_compressor.threshold_tokens,
|
||||
context_length=_compressor.context_length,
|
||||
model=agent.model,
|
||||
)
|
||||
if _preflight_status:
|
||||
agent._emit_status(_preflight_status)
|
||||
# Preflight passes honor the same configured per-turn cap
|
||||
# (compression.max_attempts) as the loop's compression sites;
|
||||
# default 3 preserves the prior hardcoded behavior.
|
||||
|
|
|
|||
|
|
@ -907,6 +907,7 @@ class TestPreflightCompression:
|
|||
return 114_000 if _rough_calls["n"] == 1 else 40_000
|
||||
|
||||
with (
|
||||
patch("agent.turn_context.estimate_request_tokens_rough", side_effect=_rough_estimate),
|
||||
patch("agent.conversation_loop.estimate_request_tokens_rough", side_effect=_rough_estimate),
|
||||
patch.object(agent, "_compress_context") as mock_compress,
|
||||
patch.object(agent, "_persist_session"),
|
||||
|
|
@ -957,6 +958,7 @@ class TestPreflightCompression:
|
|||
return 114_000 if _rough_calls["n"] == 1 else 40_000
|
||||
|
||||
with (
|
||||
patch("agent.turn_context.estimate_request_tokens_rough", side_effect=_rough_estimate),
|
||||
patch("agent.conversation_loop.estimate_request_tokens_rough", side_effect=_rough_estimate),
|
||||
patch.object(agent, "_compress_context") as mock_compress,
|
||||
patch.object(agent, "_persist_session"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue