Skip to content

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

test(agent): seed thread goals through the session store

Steven Enamakela8b3f741ab88
diff --git a/tests/in_process/agent_turn_overrides_e2e.rs b/tests/in_process/agent_turn_overrides_e2e.rs
index e590c34d18..a30b481ce0 100644
--- a/tests/in_process/agent_turn_overrides_e2e.rs
+++ b/tests/in_process/agent_turn_overrides_e2e.rs
@@ -33,7 +33,7 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use tempfile::TempDir;
-use openhuman_core::agent::goals::{runtime as goal_runtime, store as goal_store};
+use openhuman_core::agent::goals::runtime as goal_runtime;
use openhuman_core::agent_registry::host_definition::{AgentDefinition, AgentDefinitionRegistry};
use openhuman_core::agent::session_host::TurnOverrides;
use openhuman_core::agent::OpenHumanSessionHost;
@@ -217,6 +217,18 @@ fn workspace(label: &str) -> (TempDir, PathBuf) {
(temp, path)
}
+async fn seed_goal(
+ workspace: &std::path::Path,
+ thread_id: &str,
+ objective: &str,
+) -> Result<(), String> {
+ let store = openhuman_core::storage::sessions::stores_or_ephemeral(workspace).kv;
+ tinyagents_graph::goals::store::set(&store, thread_id, objective, None)
+ .await
+ .map(|_| ())
+ .map_err(|error| error.to_string())
+}
+
/// The session's own root authority.
///
/// Every session turn is a hosted root invocation: it resolves its agent id
@@ -316,7 +328,7 @@ async fn suppress_active_goal_keeps_the_thread_goal_out_of_the_prompt_inner() {
{
// CONTROL — without the override the goal reaches the prompt.
let control_guard = EnvVarGuard::set_path("OPENHUMAN_WORKSPACE", &control_workspace);
- goal_store::set(&control_workspace, THREAD, OBJECTIVE, None)
+ seed_goal(&control_workspace, THREAD, OBJECTIVE)
.await
.expect("seed an active thread goal for the control");
let control_model = ScriptedModel::new(vec![text("control final")]);
@@ -341,7 +353,7 @@ async fn suppress_active_goal_keeps_the_thread_goal_out_of_the_prompt_inner() {
// SUPPRESSED — a goal seeded identically, in a workspace no other agent
// has ever written a transcript into, must not appear.
let _workspace_guard = EnvVarGuard::set_path("OPENHUMAN_WORKSPACE", &workspace_path);
- goal_store::set(&workspace_path, THREAD, OBJECTIVE, None)
+ seed_goal(&workspace_path, THREAD, OBJECTIVE)
.await
.expect("seed an active thread goal for the measured agent");
let model = ScriptedModel::new(vec![text("chat final")]);
@@ -584,7 +596,7 @@ async fn thread_goal_complete_and_clear_stop_the_goal_reaching_later_turns_inner
{
// CONTROL — an Active goal reaches a turn.
let control_guard = EnvVarGuard::set_path("OPENHUMAN_WORKSPACE", &control_workspace);
- goal_store::set(&control_workspace, THREAD, OBJECTIVE, None)
+ seed_goal(&control_workspace, THREAD, OBJECTIVE)
.await
.expect("seed an active thread goal for the control");
let control_model = ScriptedModel::new(vec![text("pre-completion reply")]);
@@ -606,7 +618,7 @@ async fn thread_goal_complete_and_clear_stop_the_goal_reaching_later_turns_inner
// MEASURED — seed the same goal in a pristine workspace, settle it via
// the API under test, then run the only turn that workspace ever sees.
let _workspace_guard = EnvVarGuard::set_path("OPENHUMAN_WORKSPACE", &workspace_path);
- goal_store::set(&workspace_path, THREAD, OBJECTIVE, None)
+ seed_goal(&workspace_path, THREAD, OBJECTIVE)
.await
.expect("seed an active thread goal for the measured agent");
let seeded = goal_runtime::load_for_thread(&workspace_path, Some(THREAD))
@@ -654,7 +666,7 @@ async fn thread_goal_complete_and_clear_stop_the_goal_reaching_later_turns_inner
// ACTIVE goal would pass everything above it. Seed a fresh active goal
// and clear that one too.
const ACTIVE_OBJECTIVE: &str = "turn-overrides-active-goal-to-be-cleared";
- goal_store::set(&workspace_path, THREAD, ACTIVE_OBJECTIVE, None)
+ seed_goal(&workspace_path, THREAD, ACTIVE_OBJECTIVE)
.await
.expect("seed a second, still-active thread goal");
let active = goal_runtime::load_for_thread(&workspace_path, Some(THREAD))