Skip to content

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

fix(memory): refine memory engine logic and error handling

Steven Enamakelae709c7defa4
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index 202053dede..857e528445 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -494,7 +494,9 @@ pub fn clear_cortexdb_key(config: &Config) -> Result<bool> {
#[must_use]
pub fn has_key(config: &Config, id: &str) -> bool {
match id {
- TINYHUMANS_ENGINE => resolve(config).is_on(),
+ TINYHUMANS_ENGINE => {
+ matches!(resolve(config), Binding::On(bound) if bound.id == id)
+ }
CORTEXDB_ENGINE => matches!(read_cortexdb_key(config), Ok(Some(_))),
_ => false,
}
diff --git a/crates/openhuman-core/src/memory/error_tests.rs b/crates/openhuman-core/src/memory/error_tests.rs
index 19bf78d181..2f57b9e9f6 100644
--- a/crates/openhuman-core/src/memory/error_tests.rs
+++ b/crates/openhuman-core/src/memory/error_tests.rs
@@ -171,13 +171,14 @@ fn upstream_errors_keep_the_memory_rpc_wire_codes_and_messages() {
}
#[test]
-fn upstream_account_wide_classification_includes_credits_and_unavailable() {
+fn upstream_account_wide_classification_excludes_transient_unavailability() {
use tinymemory_api::Error as E;
assert!(E::Off("disabled".into()).is_account_wide());
assert!(E::Unauthorized("bad key".into()).is_account_wide());
assert!(E::InsufficientCredits("top up".into()).is_account_wide());
- assert!(E::Unavailable("timeout".into()).is_account_wide());
+ assert!(!E::Unavailable("timeout".into()).is_account_wide());
+ assert!(E::Unavailable("timeout".into()).is_transient());
assert!(!E::InvalidRequest("bad filter".into()).is_account_wide());
assert!(!E::Conflict("duplicate".into()).is_account_wide());
assert!(!E::Engine("corrupt index".into()).is_account_wide());
diff --git a/crates/openhuman-core/src/memory/lifecycle/jobs.rs b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
index 6827688bd0..a799e88471 100644
--- a/crates/openhuman-core/src/memory/lifecycle/jobs.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/jobs.rs
@@ -65,7 +65,7 @@ impl QueueStore for FileQueueStore {
}
fn save(&self, state: &QueueState) -> std::result::Result<(), String> {
- super::super::state_store::save(&self.workspace_dir, STATE, state)
+ super::super::state_store::save_workspace(&self.workspace_dir, STATE, state)
.map_err(|error| error.to_string())
}
}
diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rs
index fcc9a470be..3a05c61d14 100644
--- a/crates/openhuman-core/src/memory/ops.rs
+++ b/crates/openhuman-core/src/memory/ops.rs
@@ -506,7 +506,7 @@ fn legacy_channel_threads(workspace: &Path, channel: &str) -> BTreeSet<String> {
// the old file. If no value is available (including a failed import),
// retain the legacy read path. Malformed JSON is skipped without moving
// or rewriting its source.
- if let Ok(Some(all)) = super::state_store::load::<BTreeMap<String, BTreeSet<String>>>(
+ if let Ok(Some(all)) = super::state_store::load_strict::<BTreeMap<String, BTreeSet<String>>>(
workspace,
"channel_threads",
) {
diff --git a/crates/openhuman-core/src/memory/schemas/defs/sources.rs b/crates/openhuman-core/src/memory/schemas/defs/sources.rs
index 1583634820..f82a39feb8 100644
--- a/crates/openhuman-core/src/memory/schemas/defs/sources.rs
+++ b/crates/openhuman-core/src/memory/schemas/defs/sources.rs
@@ -18,12 +18,12 @@ pub(super) fn schema(function: &str) -> Option<ControllerSchema> {
req(
"kind",
TypeSchema::String,
- "folder | file | link | github | rss | composio.",
+ "folder | file | link | github | rss.",
),
req(
"target",
TypeSchema::String,
- "Path, URL, owner/repo, feed URL or Composio toolkit.",
+ "Path, URL, owner/repo or feed URL.",
),
opt(
"label",