fix: stop sending context compaction notifications

This commit is contained in:
Arthur K. authored and Xubin Ren committed 2026-09-30 13:44:42 +08:00
1 parent fbe9b4fd72
commit 0b402d0414
31 files changed
+157 -38

No files matched your search

@@ -3267,7 +3267,7 @@ def _compaction_message(phase: str, compaction_id: str = "c1") -> OutboundMessag
"failed": "Unable to compact context.",
"cancelled": "Context compaction cancelled.",
}[phase],
event=ContextCompactionEvent(compaction_id=compaction_id, phase=phase),
event=ContextCompactionEvent(compaction_id=compaction_id, phase=phase, notify=True),
)
@@ -3297,6 +3297,23 @@ async def test_compaction_terminal_phase_edits_started_notice_in_place() -> None
assert ("999", "c1") not in channel._compaction_notices
@pytest.mark.asyncio
async def test_automatic_compaction_is_received_but_not_sent() -> None:
channel = TelegramChannel(
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),
MessageBus(),
)
_install_ready_app(channel)
channel._app.bot.send_message = AsyncMock()
await channel.send(OutboundMessage(
channel="telegram", chat_id="999", content="Compressing context…",
event=ContextCompactionEvent(compaction_id="c1", phase="started"),
))
channel._app.bot.send_message.assert_not_awaited()
@pytest.mark.asyncio
async def test_compaction_edit_failure_falls_back_to_new_message() -> None:
from telegram.error import BadRequest