refactor(events): unify scoped runtime notifications across clients (#5670)
* refactor(events): unify scoped runtime notifications across clients * style(tests): sort auto-compaction event imports * refactor(events): scope connections and remove retry callback plumbing * docs: remove runtime notification design write-up * refactor(bus): route operation events through the message bus * fix(channels): isolate outbound sends by destination * style(events): group shared notification imports * refactor(events): converge runtime and hook delivery on MessageBus * test(events): migrate fixtures to unified message bus
This commit is contained in:
1 parent
3495281282
commit
192e2e90dc
78 files changed
+1620
-1194
No files matched your search
+6
-14
@@ -21,11 +21,7 @@ from uuid import uuid4
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from nanobot.bus.outbound_events import (
|
||||
ContextCompactionCallback,
|
||||
ContextCompactionEvent,
|
||||
emit_context_compaction,
|
||||
)
|
||||
from nanobot.events import NO_EVENTS, ContextCompactionEvent, EventSink
|
||||
from nanobot.llm_usage.context import llm_usage_source
|
||||
from nanobot.providers.base import ProviderCallContext, ProviderConversationState
|
||||
from nanobot.runtime_context import public_history_messages
|
||||
@@ -1192,7 +1188,7 @@ class Consolidator:
|
||||
*,
|
||||
runtime: LLMRuntime,
|
||||
max_suffix: int = MIN_COMPACTED_REPLAY_MESSAGES,
|
||||
on_compaction: ContextCompactionCallback | None = None,
|
||||
events: EventSink = NO_EVENTS,
|
||||
) -> str | None:
|
||||
"""Archive the full idle tail while keeping recent messages replayable.
|
||||
|
||||
@@ -1218,8 +1214,7 @@ class Consolidator:
|
||||
return ""
|
||||
|
||||
compaction_id = uuid4().hex
|
||||
await emit_context_compaction(
|
||||
on_compaction,
|
||||
await events.emit(
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="started"),
|
||||
)
|
||||
last_active = session.updated_at
|
||||
@@ -1242,8 +1237,7 @@ class Consolidator:
|
||||
session.last_archived = archive_end
|
||||
self.sessions.save(session)
|
||||
except (Exception, asyncio.CancelledError) as exc:
|
||||
await emit_context_compaction(
|
||||
on_compaction,
|
||||
await events.emit(
|
||||
ContextCompactionEvent(
|
||||
compaction_id=compaction_id,
|
||||
phase="cancelled" if isinstance(exc, asyncio.CancelledError) else "failed",
|
||||
@@ -1251,14 +1245,12 @@ class Consolidator:
|
||||
)
|
||||
raise
|
||||
if summary is None:
|
||||
await emit_context_compaction(
|
||||
on_compaction,
|
||||
await events.emit(
|
||||
ContextCompactionEvent(compaction_id=compaction_id, phase="failed"),
|
||||
)
|
||||
return None
|
||||
|
||||
await emit_context_compaction(
|
||||
on_compaction,
|
||||
await events.emit(
|
||||
ContextCompactionEvent(
|
||||
compaction_id=compaction_id,
|
||||
phase="succeeded",
|
||||
|
||||
Reference in new issue
Block a user