fix(channels): keep the compaction outcome visible, gate only the start notice
Rework after review: compaction changes the context of every later turn, so its outcome (compacted / failed / cancelled) is always delivered, whether the user or the scheduler started it. Only the transient "Compressing context…" start notice follows the channel's send_progress setting, so a channel with progress off receives one notice per compaction instead of two. The manual flag is gone.
This commit is contained in:
1 parent
92f151ae67
commit
a068de8068
6 files changed
+25
-31
No files matched your search
@@ -1165,7 +1165,6 @@ class Consolidator:
|
||||
runtime: LLMRuntime,
|
||||
max_suffix: int = 0,
|
||||
events: EventSink = NO_EVENTS,
|
||||
manual: bool = False,
|
||||
) -> str | None:
|
||||
"""Replace archived history with a summary checkpoint.
|
||||
|
||||
@@ -1188,7 +1187,7 @@ class Consolidator:
|
||||
|
||||
compaction_id = uuid4().hex
|
||||
await events.emit(
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="started", manual=manual),
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="started"),
|
||||
)
|
||||
last_active = session.updated_at
|
||||
archive_end = archive_start + len(messages_to_archive)
|
||||
@@ -1208,21 +1207,19 @@ class Consolidator:
|
||||
await events.emit(
|
||||
ContextCompactionEvent(
|
||||
compaction_id=compaction_id,
|
||||
manual=manual,
|
||||
phase="cancelled" if isinstance(exc, asyncio.CancelledError) else "failed",
|
||||
),
|
||||
)
|
||||
raise
|
||||
if not summary:
|
||||
await events.emit(
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="failed", manual=manual),
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="failed"),
|
||||
)
|
||||
return None
|
||||
|
||||
await events.emit(
|
||||
ContextCompactionEvent(
|
||||
compaction_id=compaction_id,
|
||||
manual=manual,
|
||||
phase="succeeded",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -811,14 +811,14 @@ class ChannelManager:
|
||||
):
|
||||
continue
|
||||
|
||||
# Automatic compaction notices are maintenance chatter, so they
|
||||
# follow the channel's progress setting like other progress
|
||||
# text. A user-requested ``/compact`` and a failed compaction
|
||||
# are still reported.
|
||||
# Compaction changes the context of every later turn, so its
|
||||
# outcome (compacted / failed / cancelled) is always delivered.
|
||||
# The "Compressing context…" start notice is transient progress
|
||||
# text and follows the channel's progress setting, so a channel
|
||||
# with progress off gets one notice per compaction, not two.
|
||||
if (
|
||||
isinstance(event, ContextCompactionEvent)
|
||||
and not event.manual
|
||||
and event.phase != "failed"
|
||||
and event.phase == "started"
|
||||
and not self._should_send_progress(msg.channel)
|
||||
):
|
||||
continue
|
||||
|
||||
@@ -357,7 +357,6 @@ async def cmd_compact(ctx: CommandContext) -> None:
|
||||
ctx.key,
|
||||
runtime=runtime,
|
||||
events=delivery.events,
|
||||
manual=True,
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Manual context compaction failed for {}", ctx.key)
|
||||
|
||||
@@ -17,9 +17,6 @@ class AgentEvent:
|
||||
class ContextCompactionEvent(AgentEvent):
|
||||
compaction_id: str
|
||||
phase: Literal["started", "succeeded", "failed", "cancelled"]
|
||||
# True when the user asked for the compaction (``/compact``). Automatic
|
||||
# compaction is routine maintenance and its notices follow ``send_progress``.
|
||||
manual: bool = False
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
Reference in new issue
Block a user