mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-15 14:22:43 +00:00
fix(codex): evaluate native compaction usage
This commit is contained in:
parent
b8d467bad9
commit
ec6982fbcf
2 changed files with 16 additions and 3 deletions
|
|
@ -279,6 +279,11 @@ def _record_codex_app_server_compaction(
|
|||
compressor, "compression_count", 0
|
||||
) + 1
|
||||
compressor.last_compression_rough_tokens = approx_tokens or 0
|
||||
# The app server has already completed a real compaction boundary. Its
|
||||
# usage update (when supplied) is therefore the same real-vs-real
|
||||
# effectiveness verdict used by the normal compression path.
|
||||
if hasattr(compressor, "_verify_compaction_cleared_threshold"):
|
||||
compressor._verify_compaction_cleared_threshold = True
|
||||
if not getattr(turn, "token_usage_last", None):
|
||||
compressor.last_prompt_tokens = -1
|
||||
compressor.last_completion_tokens = 0
|
||||
|
|
|
|||
|
|
@ -143,6 +143,13 @@ class TestRunConversationCodexPath:
|
|||
turn_id="turn-compact-1",
|
||||
thread_id="thread-compact-1",
|
||||
compacted=True,
|
||||
token_usage_last={
|
||||
"totalTokens": 300_000,
|
||||
"inputTokens": 300_000,
|
||||
"cachedInputTokens": 0,
|
||||
"outputTokens": 0,
|
||||
"reasoningOutputTokens": 0,
|
||||
},
|
||||
)
|
||||
|
||||
monkeypatch.setattr(CodexAppServerSession, "run_turn", fake_run_turn)
|
||||
|
|
@ -157,10 +164,11 @@ class TestRunConversationCodexPath:
|
|||
|
||||
assert result["completed"] is True
|
||||
assert agent.context_compressor.compression_count == 1
|
||||
# The app-server omitted usage, so the runtime consumes the pending
|
||||
# post-compaction verdict instead of deferring preflight indefinitely.
|
||||
assert agent.context_compressor.last_prompt_tokens == 0
|
||||
# A compacted turn with real usage is judged against that same real
|
||||
# prompt count, exactly like a normal completed compression boundary.
|
||||
assert agent.context_compressor.last_prompt_tokens == 300_000
|
||||
assert agent.context_compressor.awaiting_real_usage_after_compression is False
|
||||
assert agent.context_compressor._ineffective_compression_count == 1
|
||||
assert events == [
|
||||
(
|
||||
"session:compress",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue