Skip to content

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

chore: files changed crates/openhuman-core/src/memory/tool_budget_tests.rs,crates/openhuman-core/src

Steven Enamakelf58f62d150ec
diff --git a/crates/openhuman-core/src/memory/tool_budget_tests.rs b/crates/openhuman-core/src/memory/tool_budget_tests.rs
index 7c9c302937..626e7d36eb 100644
--- a/crates/openhuman-core/src/memory/tool_budget_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_budget_tests.rs
@@ -83,12 +83,21 @@ async fn an_ordinary_tool_error_refunds_unused_time_without_opening_the_circuit(
assert_eq!(
budget
.run(Some("turn"), async {
- tokio::time::sleep(Duration::from_secs(27)).await;
+ tokio::time::sleep(Duration::from_secs(12)).await;
"healthy"
})
.await,
Ok("healthy")
);
+ assert_eq!(
+ budget
+ .run(Some("turn"), async {
+ tokio::time::sleep(Duration::from_secs(15)).await;
+ "remaining per-run allowance"
+ })
+ .await,
+ Ok("remaining per-run allowance")
+ );
assert_eq!(
budget.run(Some("turn"), async { "out of time" }).await,
Err(Refusal::Denied(DenialReason::LatencyBudget))
diff --git a/crates/openhuman-core/src/memory/tool_writes_tests.rs b/crates/openhuman-core/src/memory/tool_writes_tests.rs
index c8d025fa37..44adbf1cdc 100644
--- a/crates/openhuman-core/src/memory/tool_writes_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_writes_tests.rs
@@ -57,6 +57,16 @@ pub(crate) fn queued_for(config: &Config, facts: &CallFacts) -> tinymemory_api::
super::read_at(&super::queue_path(config, &facts.reach.at))
}
+pub(crate) async fn drain_for(config: &Config, root: &Namespace) -> usize {
+ let file = super::queue_path(config, root);
+ let owner = super::owner_state(config);
+ let _owner = owner.barrier.read().await;
+ let state = super::drain_state(&file);
+ let _draining = state.barrier.lock().await;
+ let generation = owner.gate.generation();
+ super::drain_locked(config, &file, &owner, generation).await
+}
+
fn facts(config: &Config) -> CallFacts {
CallFacts::of(
config,
@@ -123,7 +133,7 @@ async fn restart_drains_scrubbed_learnings_and_ordered_forgetting() {
let id = ack["id"].as_str().unwrap();
enqueue(
&config,
- &json!({"action":"forget","ids":[id],"reach":{"at":"root"}}),
+ &json!({"action":"forget","ids":[id]}),
&facts,
)
.unwrap();
@@ -446,16 +456,18 @@ async fn model_supplied_forget_reach_cannot_remove_another_identitys_item() {
let id = engine.store(item).await.unwrap().id.0;
// All agents under one identity share their root by design. Choose an
// unrelated root explicitly to exercise a foreign identity boundary.
- let mut confined = facts(&config);
- confined.reach = Reach::subtree("user:isolated".parse().unwrap());
let mut config = config;
config.memory.root = Some("user:isolated".into());
- enqueue(
+ let mut confined = facts(&config);
+ confined.reach = Reach::subtree("user:isolated".parse().unwrap());
+ let rejected = enqueue(
&config,
&json!({"action":"forget","ids":[id],"reach":{"at":"","inherit":true,"descendants":true}}),
&confined,
- )
- .unwrap();
+ );
+ assert!(matches!(rejected, Err(tinymemory_api::Error::InvalidRequest(_))));
+ assert!(read(&config.workspace_dir).unwrap().is_empty());
+ enqueue(&config, &json!({"action":"forget","ids":[id]}), &confined).unwrap();
assert_eq!(drain(&config).await, 1);
assert_eq!(stored(&engine, MetaFilter::default()).await.len(), 1);
}
diff --git a/crates/openhuman-core/src/memory/tools_test_support.rs b/crates/openhuman-core/src/memory/tools_test_support.rs
index 638dd23f06..1ca289bf2a 100644
--- a/crates/openhuman-core/src/memory/tools_test_support.rs
+++ b/crates/openhuman-core/src/memory/tools_test_support.rs
@@ -17,7 +17,7 @@ pub(super) async fn run_action(
.call_with_facts(args.clone(), ctx.clone(), facts.clone(), None)
.await;
if is_write_action(args) && !result.is_error {
- crate::memory::tool_writes::drain(config).await;
+ crate::memory::tool_writes::tests::drain_for(config, &facts.reach.at).await;
}
result
}
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index 1e9aec2a0d..bba52e6060 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -108,7 +108,8 @@ fn schema_and_permissions_follow_the_action() {
#[tokio::test]
async fn every_action_reports_memory_off_as_a_tool_error() {
let tmp = tempfile::tempdir().unwrap();
- let config = config_in(&tmp);
+ let mut config = config_in(&tmp);
+ config.components.memory = false;
for args in [
json!({"action": "recall", "question": "q"}),
json!({"action": "fetch", "query": "q"}),
@@ -186,15 +187,21 @@ async fn bad_arguments_and_unknown_actions_are_model_visible_errors() {
let unknown = run_action(&ambient(), &config, &json!({"action": "explode"}), &facts()).await;
assert!(unknown.is_error);
- assert!(text(&unknown).contains("unknown action `explode`"));
+ assert!(text(&unknown).contains("unknown action"));
+ assert!(text(&unknown).contains("explode"));
let missing = run_action(&ambient(), &config, &json!({}), &facts()).await;
assert!(missing.is_error);
+ assert!(text(&missing).contains("action is required"));
for action in ["recall", "fetch", "learn", "forget"] {
let result = run_action(&ambient(), &config, &json!({ "action": action }), &facts()).await;
assert!(result.is_error, "{action}");
- assert!(text(&result).contains("invalid arguments"), "{action}");
+ assert!(
+ text(&result).contains("INVALID_REQUEST"),
+ "{action}: {}",
+ text(&result)
+ );
}
}
@@ -348,7 +355,9 @@ async fn fetch_with_an_undeclared_mode_is_unsupported() {
)
.await;
assert!(result.is_error);
- assert!(text(&result).contains("UNSUPPORTED"), "{}", text(&result));
+ assert!(text(&result).contains("INVALID_REQUEST"), "{}", text(&result));
+ assert!(text(&result).contains("keyword"), "{}", text(&result));
+ assert!(text(&result).contains("hybrid"), "{}", text(&result));
}
#[tokio::test]
@@ -460,7 +469,7 @@ async fn learnings_are_shared_under_a_root_and_a_team_root_is_kept_apart() {
run_action(
&ambient(),
&config,
- &json!({"action": "fetch", "query": "the", "limit": 50, "filter": {"reach": null}}),
+ &json!({"action": "fetch", "query": "the", "limit": 50}),
&facts,
)
.await
@@ -611,7 +620,7 @@ async fn learn_returns_on_accept_and_says_recall_may_lag() {
async fn a_failed_learn_is_reported_to_the_model() {
let tmp = tempfile::tempdir().unwrap();
let config = config_in(&tmp);
- crate::memory::test_fixtures::RefusingEngine::out_of_credits().bind(&config);
+ std::fs::write(config.workspace_dir.join("memory"), "blocks outbox directory").unwrap();
let learned = run_action(
&ambient(),
@@ -623,7 +632,7 @@ async fn a_failed_learn_is_reported_to_the_model() {
assert!(learned.is_error, "{}", text(&learned));
assert!(
- text(&learned).contains("INSUFFICIENT_CREDITS"),
+ text(&learned).contains("queue unavailable"),
"{}",
text(&learned)
);