Skip to content

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

test(memory): cover typed skip reasons and rpc error round-trips

Steven Enamakelf778a2d90e3c
diff --git a/crates/openhuman-core/src/memory/error_tests.rs b/crates/openhuman-core/src/memory/error_tests.rs
index b6b44a76a4..8318b7bc8d 100644
--- a/crates/openhuman-core/src/memory/error_tests.rs
+++ b/crates/openhuman-core/src/memory/error_tests.rs
@@ -1,4 +1,3 @@
-use super::*;
use tinymemory_api::Error as MemoryApiError;
#[test]
@@ -67,6 +66,10 @@ fn upstream_errors_keep_the_memory_rpc_wire_codes_and_messages() {
assert_eq!(structured.data.as_ref().unwrap()["kind"], code);
assert_eq!(structured.message, message);
assert_eq!(structured.expected_user_state, expected_user_state);
+ assert_eq!(
+ crate::core::StructuredRpcError::decode(&structured.encode()),
+ Some(structured)
+ );
}
}
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
index eb4c70be64..fa7373f52b 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs
@@ -80,17 +80,31 @@ fn turn_indices_follow_the_committed_transcript() {
#[test]
fn typed_skip_reasons_expose_only_account_wide_errors() {
- let unavailable = MemoryApiError::Unavailable("connection refused".into());
- let invalid = MemoryApiError::InvalidRequest("bad scope".into());
+ let account_wide = [
+ MemoryApiError::Off("disabled".into()),
+ MemoryApiError::Unauthorized("bad key".into()),
+ MemoryApiError::InsufficientCredits("top up".into()),
+ MemoryApiError::Unavailable("connection refused".into()),
+ ];
+ for error in &account_wide {
+ assert_eq!(
+ account_wide_skip_reason(&SkipReason::Engine(error.clone())),
+ Some(error)
+ );
+ }
- assert_eq!(
- account_wide_skip_reason(&SkipReason::Engine(unavailable.clone())),
- Some(&unavailable)
- );
- assert_eq!(
- account_wide_skip_reason(&SkipReason::Engine(invalid)),
- None
- );
+ let local = [
+ MemoryApiError::InvalidRequest("bad scope".into()),
+ MemoryApiError::NotFound("item".into()),
+ MemoryApiError::Conflict("duplicate".into()),
+ MemoryApiError::Engine("corrupt index".into()),
+ ];
+ for error in local {
+ assert_eq!(
+ account_wide_skip_reason(&SkipReason::Engine(error)),
+ None
+ );
+ }
assert_eq!(account_wide_skip_reason(&SkipReason::Empty), None);
}
@@ -391,11 +405,13 @@ fn a_refusal_is_read_back_from_a_skipped_section() {
skipped: vec![
tinymemory_tools::recall::SkippedSection {
heading: "Learnings".into(),
- reason: "empty".into(),
+ reason: SkipReason::Empty,
},
tinymemory_tools::recall::SkippedSection {
heading: "History".into(),
- reason: "unauthorized: ["UNAUTHORIZED"] memory API fetch (HTTP 401)".into(),
+ reason: SkipReason::Engine(MemoryApiError::Unauthorized(
+ "memory API fetch (HTTP 401)".into(),
+ )),
},
],
engine: "tinyhumans".into(),