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

+13
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
from nanobot.bus.events import OutboundMessage
from nanobot.bus.outbound_events import (
ContextCompactionEvent,
GoalStateSyncEvent,
GoalStatusEvent,
ProgressEvent,
@@ -18,6 +19,18 @@ from nanobot.bus.outbound_events import (
)
def test_compaction_events_have_readable_channel_fallbacks() -> None:
for event, expected in [
(ContextCompactionEvent("1", "started"), "Compressing context…"),
(ContextCompactionEvent("1", "succeeded"), "Context compacted."),
(ContextCompactionEvent("1", "failed"), "Unable to compact context."),
(ContextCompactionEvent("1", "cancelled"), "Context compaction cancelled."),
]:
msg = outbound_message_for_event(channel="cli", chat_id="direct", event=event)
assert msg.content == expected
assert msg.event is event
def test_progress_event_lives_on_outbound_message_event_field() -> None:
tool_events = [{"phase": "start", "name": "read_file"}]
file_edit_events = [{"phase": "end", "path": "app.py"}]