Skip to content

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

fix(orchestration): drop cached recovery log when nothing is pending

Steven Enamakel95978a85649a
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
index 3e048ef00c..efe77deb34 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
@@ -317,7 +317,13 @@ pub(crate) fn recover_on_boot(workspace_dir: &Path) -> usize {
/// lease-claimed.
pub(crate) fn recover_on_open(workspace_dir: &Path) -> usize {
background_completions::forget_recovery(workspace_dir);
- recover_on_boot(workspace_dir)
+ let scheduled = recover_on_boot(workspace_dir);
+ if scheduled == 0 {
+ // Nothing pending: do not keep this profile's log handle cached for a
+ // workspace that may never complete anything on this node.
+ background_completions::forget_recovery(workspace_dir);
+ }
+ scheduled
}
/// Claim everything ready for a thread **right now** (sync, testable): `None`
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs
index 7d095c420c..c7bf099b0b 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery_slots_tests.rs
@@ -181,7 +181,9 @@ async fn desktop_keys_are_the_bare_ids() {
let ws = TestWorkspace::new();
let thread = unique("t-desk");
let session = unique("desk-session");
- background_completions::note_session_thread(&session, &thread);
+ in_scope(&desktop, || {
+ background_completions::note_session_thread(&session, &thread)
+ });
let turn = in_scope(&desktop, || TurnBusy::start(&session));
assert_eq!(turn.key, session);
diff --git a/crates/openhuman-core/src/channels/bus/subscriber.rs b/crates/openhuman-core/src/channels/bus/subscriber.rs
index 1fafdf6f0d..307e15bf19 100644
--- a/crates/openhuman-core/src/channels/bus/subscriber.rs
+++ b/crates/openhuman-core/src/channels/bus/subscriber.rs
@@ -67,7 +67,9 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
// If that contract is broken, the legacy channel-only key would let
// different users share one chat session and its prepared wallet quote.
if channel.split(':').next() == Some("discord")
- && sender.as_deref().is_none_or(|value| value.trim().is_empty())
+ && sender
+ .as_deref()
+ .is_none_or(|value| value.trim().is_empty())
{
tracing::warn!("[channel-inbound] dropping Discord message without sender id");
return;