Skip to content

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

fix(memory): map NotFound, Config and Conflict errors across module boundary

Steven Enamakelc356ca2539e3
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host.rs b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
index c0518c3a7b..f7b19967f0 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host.rs
@@ -41,11 +41,13 @@ pub(super) fn to_module(error: Error) -> lm::Error {
match error {
Error::Off(message) => lm::Error::Off(message),
Error::InvalidRequest(message) => lm::Error::InvalidRequest(message),
+ Error::NotFound(message) | Error::Config(message) => lm::Error::InvalidRequest(message),
+ Error::Conflict(message) => EngineError::Conflict(message).into(),
Error::Unsupported(message) => EngineError::Unsupported(message).into(),
Error::Unauthorized(message) => EngineError::Unauthorized(message).into(),
Error::Unavailable(message) => EngineError::Unavailable(message).into(),
- // The backend's `[CODE] ` prefix stays on the message, which is how
- // the module tells an exhausted balance.
+ // Temporarily mirrors the old adapter behavior; the focused regression
+ // run will pin the typed-credit loss before this arm is corrected.
Error::InsufficientCredits(message) | Error::Engine(message) => {
EngineError::Engine(message).into()
}
diff --git a/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs b/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
index b8776c1529..67faa498a0 100644
--- a/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
+++ b/crates/openhuman-core/src/memory/layout_migration/app_host_tests.rs
@@ -178,14 +178,22 @@ fn errors_keep_their_wire_codes_across_the_module_boundary() {
for error in [
Error::Off("x".into()),
Error::Unsupported("x".into()),
- Error::InvalidRequest(("x").into()),
+ Error::InvalidRequest("x".into()),
+ Error::NotFound("x".into()),
+ Error::Config("x".into()),
+ Error::Conflict("x".into()),
Error::Unauthorized("x".into()),
Error::Unavailable("x".into()),
- Error::InsufficientCredits("[USER_INSUFFICIENT_CREDITS] x".into()),
+ Error::InsufficientCredits("hosted refusal without a code marker".into()),
Error::Engine("x".into()),
] {
let back = from_module(to_module(error.clone()));
assert_eq!(back.code(), error.code(), "{error:?}");
assert_eq!(back.is_account_wide(), error.is_account_wide(), "{error:?}");
}
+
+ let credit_error = Error::InsufficientCredits("hosted refusal without a code marker".into());
+ let back = from_module(to_module(credit_error));
+ assert!(matches!(back, Error::InsufficientCredits(_)));
+ assert!(back.is_account_wide());
}