feat: make context compaction visible in channels (#5656)

* feat: surface context compaction lifecycle

* fix: complete and simplify context compaction notifications
This commit is contained in:
chengyongru authored and GitHub committed 2026-09-05 20:21:54 +08:00
1 parent 455533169d
commit 5229989f28
52 files changed
+1849 -140

No files matched your search

+27 -2
View File
@@ -1,9 +1,34 @@
from __future__ import annotations
from nanobot.bus.outbound_events import RecoveryStateEvent, TurnEndEvent
from nanobot.bus.outbound_events import (
ContextCompactionEvent,
RecoveryStateEvent,
TurnEndEvent,
)
from nanobot.providers.base import LLMUsage
from nanobot.webui.metadata import WEBUI_TURN_METADATA_KEY
from nanobot.webui.outbound_wire import encode_recovery_state, encode_turn_end
from nanobot.webui.outbound_wire import (
encode_context_compaction,
encode_recovery_state,
encode_turn_end,
)
def test_encode_context_compaction_projects_the_lifecycle() -> None:
payload = encode_context_compaction(
"chat-1",
ContextCompactionEvent(
compaction_id="compact-1",
phase="succeeded",
),
)
assert payload == {
"event": "context_compaction",
"chat_id": "chat-1",
"compaction_id": "compact-1",
"phase": "succeeded",
}
def test_encode_recovery_state_omits_absent_optional_fields() -> None: