Skip to content

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

feat(events): add inbound turn completed and failed events

Steven Enamakel0b90f18d1d07
diff --git a/crates/openhuman-core/src/core/bus.rs b/crates/openhuman-core/src/core/bus.rs
index 76c939a4a0..7ff1eacc2f 100644
--- a/crates/openhuman-core/src/core/bus.rs
+++ b/crates/openhuman-core/src/core/bus.rs
@@ -100,7 +100,9 @@ pub const EVENTS_INTERFACE: &str = "ai.tinyhumans.openhuman.Events";
/// `3.0.0` removes `CronDeliveryRequested` (announce delivery now sends
/// synchronously through the cron channel bridge) and includes optional
/// `CronJobCompleted` tenant ownership.
-pub const EVENTS_VERSION: Version = Version::new(3, 0, 0);
+/// `3.1.0` adds `InboundTurnCompleted` and `InboundTurnFailed` (additive): a
+/// pinned inbound source's batch ran on its agent.
+pub const EVENTS_VERSION: Version = Version::new(3, 1, 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 2639488bd6..10116479be 100644
--- a/crates/openhuman-core/src/core/events.rs
+++ b/crates/openhuman-core/src/core/events.rs
@@ -998,6 +998,30 @@ pub enum DomainEvent {
/// Already scrubbed; safe to log.
detail: String,
},
+ /// A pinned source's batch ran on its agent and the agent's final text is
+ /// stored. Carries no text: a subscriber is woken by this and reads the
+ /// result over `inbound.results` (keyed by `turn_id`).
+ InboundTurnCompleted {
+ /// The configured source (`x:mentions`).
+ source: String,
+ /// The key the batch was debounced by.
+ key: String,
+ /// The queues' turn id, the result's key.
+ turn_id: String,
+ /// The source's ids of the events the batch carried.
+ event_ids: Vec<String>,
+ /// The pinned agent that ran.
+ agent_id: String,
+ },
+ /// A pinned source's batch failed for good (its last attempt failed, or
+ /// it failed after its delivery was acknowledged); stored as `failed`.
+ InboundTurnFailed {
+ source: String,
+ key: String,
+ turn_id: String,
+ /// Already scrubbed; safe to log.
+ detail: String,
+ },
// ── Device pairing ──────────────────────────────────────────────────
/// A mobile device completed the X25519 handshake and is now paired.
@@ -1435,7 +1459,9 @@ impl DomainEvent {
Self::InboundEventDropped { .. }
| Self::InboundDeferred { .. }
- | Self::InboundDeadLettered { .. } => "inbound",
+ | Self::InboundDeadLettered { .. }
+ | Self::InboundTurnCompleted { .. }
+ | Self::InboundTurnFailed { .. } => "inbound",
Self::DevicePaired { .. }
| Self::DeviceRevoked { .. }
@@ -1612,6 +1638,22 @@ impl DomainEvent {
Self::McpServerParked { error, .. } => {
Some(format!("parked, not retrying — {}", clip(error)))
}
+ Self::InboundTurnCompleted {
+ source,
+ key,
+ turn_id,
+ event_ids,
+ ..
+ } => Some(format!(
+ "{source}/{key} turn {turn_id}: {} event(s)",
+ event_ids.len()
+ )),
+ Self::InboundTurnFailed {
+ source,
+ key,
+ turn_id,
+ detail,
+ } => Some(format!("{source}/{key} turn {turn_id}: {}", clip(detail))),
_ => None,
}
}
diff --git a/crates/openhuman-core/src/core/events/variant_names.rs b/crates/openhuman-core/src/core/events/variant_names.rs
index 0404bcbb1f..49ac479e2b 100644
--- a/crates/openhuman-core/src/core/events/variant_names.rs
+++ b/crates/openhuman-core/src/core/events/variant_names.rs
@@ -71,6 +71,8 @@ impl DomainEvent {
Self::InboundEventDropped { .. } => "InboundEventDropped",
Self::InboundDeferred { .. } => "InboundDeferred",
Self::InboundDeadLettered { .. } => "InboundDeadLettered",
+ Self::InboundTurnCompleted { .. } => "InboundTurnCompleted",
+ Self::InboundTurnFailed { .. } => "InboundTurnFailed",
Self::DevicePaired { .. } => "DevicePaired",
Self::DeviceRevoked { .. } => "DeviceRevoked",
Self::DevicePeerOnline { .. } => "DevicePeerOnline",