fix: stop sending context compaction notifications
This commit is contained in:
1 parent
fbe9b4fd72
commit
0b402d0414
31 files changed
+157
-38
No files matched your search
@@ -261,6 +261,8 @@ if DISCORD_AVAILABLE:
|
||||
async def send_outbound(self, msg: OutboundMessage) -> None:
|
||||
"""Send a nanobot outbound message using Discord transport rules."""
|
||||
compaction = msg.event if isinstance(msg.event, ContextCompactionEvent) else None
|
||||
if compaction is not None and not compaction.notify:
|
||||
return
|
||||
# A compaction's outcome replaces its own start notice in place, so
|
||||
# the lifecycle stays visible as one message instead of two (#5719).
|
||||
# Without a stored notice (restart, edit refused) it is sent as usual.
|
||||
|
||||
@@ -1787,7 +1787,9 @@ def _compaction_message(
|
||||
channel="discord",
|
||||
chat_id=chat_id,
|
||||
content=content,
|
||||
event=ContextCompactionEvent(compaction_id=compaction_id, phase=phase), # type: ignore[arg-type]
|
||||
event=ContextCompactionEvent(
|
||||
compaction_id=compaction_id, phase=phase, notify=True,
|
||||
), # type: ignore[arg-type]
|
||||
)
|
||||
|
||||
|
||||
@@ -1822,6 +1824,19 @@ async def test_compaction_outcome_edits_the_start_notice_in_place() -> None:
|
||||
assert owner._compaction_notices == {}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_automatic_compaction_is_received_but_not_sent() -> None:
|
||||
target = _FakeChannel(channel_id=123)
|
||||
_owner, client = _client_with_channel(target)
|
||||
|
||||
await client.send_outbound(OutboundMessage(
|
||||
channel="discord", chat_id="123", content="Compressing context…",
|
||||
event=ContextCompactionEvent(compaction_id="c1", phase="started"),
|
||||
))
|
||||
|
||||
assert target.sent_payloads == []
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_compaction_outcome_without_a_start_notice_is_sent() -> None:
|
||||
# After a restart (or when the edit is refused) the outcome still arrives.
|
||||
|
||||
Reference in new issue
Block a user