Skip to content

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

refactor(goals): improve goal store initialization logic

Steven Enamakela62af381b7e2
diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rs
index 80c4e54b5c..9b3403b66f 100644
--- a/crates/openhuman-core/src/agent/goals/mod.rs
+++ b/crates/openhuman-core/src/agent/goals/mod.rs
@@ -30,6 +30,18 @@ pub fn goal_store(
workspace_dir: &Path,
context: &crate::core::runtime::DispatchCtx,
) -> Arc<GoalStore> {
+ let tenant = match context.tenant() {
+ Ok(tenant) => tenant,
+ Err(no_tenant) => {
+ log::warn!("[thread_goals] {no_tenant}; using throwaway in-memory store");
+ return Arc::new(GoalStore::with_observer(
+ tinyagents_session::port::InMemorySessionStores::new()
+ .for_agent("ephemeral")
+ .kv,
+ Arc::new(OpenHumanGoalObserver),
+ ));
+ }
+ };
let stores = crate::core::runtime::slot_for::<ScopedGoalStores>(context);
let mut stores = stores
.0
@@ -39,14 +51,8 @@ pub fn goal_store(
return Arc::clone(store);
}
- let owner_stores = match context.tenant() {
- Ok(tenant) => crate::storage::sessions::provider_for_workspace_in(workspace_dir, context)
- .for_agent(&crate::core::runtime::session_key(&tenant)),
- Err(no_tenant) => {
- log::warn!("[thread_goals] {no_tenant}; using throwaway in-memory store");
- tinyagents_session::port::InMemorySessionStores::new().for_agent("ephemeral")
- }
- };
+ let owner_stores = crate::storage::sessions::provider_for_workspace_in(workspace_dir, context)
+ .for_agent(&crate::core::runtime::session_key(&tenant));
let kv = owner_stores.kv;
let store = Arc::new(GoalStore::with_observer(
kv,
diff --git a/crates/openhuman-core/src/agent/goals/mod_tests.rs b/crates/openhuman-core/src/agent/goals/mod_tests.rs
index 560fb791d3..79e36c9ca5 100644
--- a/crates/openhuman-core/src/agent/goals/mod_tests.rs
+++ b/crates/openhuman-core/src/agent/goals/mod_tests.rs
@@ -131,13 +131,19 @@ async fn goal_store_uses_the_explicit_dispatch_context_provider() {
let stored_a = provider_a
.for_agent(&agent_a_key)
.kv
- .get("thread_goals", "same-thread")
+ .get(
+ tinyagents_harness_tools::goals::store::GOALS_NAMESPACE,
+ "same-thread",
+ )
.await
.expect("read A provider");
let stored_b = provider_b
.for_agent("agent-b")
.kv
- .get("thread_goals", "same-thread")
+ .get(
+ tinyagents_harness_tools::goals::store::GOALS_NAMESPACE,
+ "same-thread",
+ )
.await
.expect("read B provider");
assert!(stored_a.is_some(), "goal belongs to explicit agent A");
diff --git a/crates/openhuman-core/src/web_chat/event_bus_tests.rs b/crates/openhuman-core/src/web_chat/event_bus_tests.rs
index 87712f26e0..b8fb3bff18 100644
--- a/crates/openhuman-core/src/web_chat/event_bus_tests.rs
+++ b/crates/openhuman-core/src/web_chat/event_bus_tests.rs
@@ -347,8 +347,7 @@ async fn goal_resume_and_account_updates_reach_the_web_channel() {
0,
std::time::Duration::from_secs(1),
)
- .await
- ;
+ .await;
drop(store);
crate::agent::goals::account_turn(
workspace.path(),