Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(core): prevent duplicate event handler registrations

Steven Enamakel336b6d318645
diff --git a/crates/openhuman-core/src/core/bus.rs b/crates/openhuman-core/src/core/bus.rs
index 33908f1a9c..b306a48903 100644
--- a/crates/openhuman-core/src/core/bus.rs
+++ b/crates/openhuman-core/src/core/bus.rs
@@ -72,7 +72,7 @@ pub const EVENTS_INTERFACE: &str = "ai.tinyhumans.openhuman.Events";
/// (`request_id`), the new `ThreadTodosChanged` and `ThreadRunModeChanged`
/// variants. All additions are optional/defaulted, so an older subscriber
/// keeps parsing what a newer publisher emits.
-pub const EVENTS_VERSION: Version = Version::new(1, 5, 0);
+pub const EVENTS_VERSION: Version = Version::new(1, 6, 0);
/// The bus. Initialised once by [`init`]; safe to touch before that.
pub static BUS: OnceBus<DomainEvent> = OnceBus::new();
diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rs
index 03435bf32d..de2dc72a9a 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -285,6 +285,17 @@ pub enum DomainEvent {
/// Why the configured driver was refused.
reason: String,
},
+ /// The user switched the memory engine (`memory.engine_set` /
+ /// `memory.engine_migrate`) and the binding was rebound in process.
+ ///
+ /// Carries driver ids only — never an endpoint, credential or reference,
+ /// same rule as [`Self::MemoryDriverBindFailed`].
+ MemoryDriverChanged {
+ /// The driver id that was active before the switch.
+ from: String,
+ /// The driver id that is configured now.
+ to: String,
+ },
/// The memory policy guard refused a call before it reached the bound
/// driver (`docs/specs/kernel.md` §3.4).
///
@@ -1545,6 +1556,7 @@ impl DomainEvent {
| Self::MemoryStored { .. }
| Self::MemoryRecalled { .. }
| Self::MemoryDriverBindFailed { .. }
+ | Self::MemoryDriverChanged { .. }
| Self::MemoryGuardDenied { .. }
| Self::MemorySyncRequested { .. }
| Self::MemorySyncStageChanged { .. }
@@ -1700,6 +1712,7 @@ impl DomainEvent {
Self::MemoryStored { .. } => "MemoryStored",
Self::MemoryRecalled { .. } => "MemoryRecalled",
Self::MemoryDriverBindFailed { .. } => "MemoryDriverBindFailed",
+ Self::MemoryDriverChanged { .. } => "MemoryDriverChanged",
Self::MemoryGuardDenied { .. } => "MemoryGuardDenied",
Self::MemorySyncRequested { .. } => "MemorySyncRequested",
Self::MemorySyncStageChanged { .. } => "MemorySyncStageChanged",