Skip to content

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

docs(goals): add module documentation and runtime tests

Steven Enamakel32e373d9a329
diff --git a/crates/openhuman-core/src/agent/goals/README.md b/crates/openhuman-core/src/agent/goals/README.md
index fe53fab8a4..a7361b8b4c 100644
--- a/crates/openhuman-core/src/agent/goals/README.md
+++ b/crates/openhuman-core/src/agent/goals/README.md
@@ -2,7 +2,7 @@
TinyAgents owns goal types, lifecycle, persistence, budgets, and prompt
rendering. This directory contains OpenHuman runtime adapters for explicit
-thread selection, tool registration, turn accounting, and idle continuation.
+thread selection, tool registration, and turn accounting.
Goals are controlled by the agent tools and runtime. There is no thread-goal
frontend or `openhuman.thread_goals_*` JSON-RPC API.
diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rs
index 062bfe3a65..e7f311ecb9 100644
--- a/crates/openhuman-core/src/agent/goals/mod.rs
+++ b/crates/openhuman-core/src/agent/goals/mod.rs
@@ -3,10 +3,9 @@
//! Tinyagents owns the goal types, lifecycle, persistence, prompt rendering,
//! graph continuation, and native harness tools. This module contains the
//! remaining OpenHuman-specific adapters: workspace-store resolution, domain
-//! events, heartbeat dispatch, and bridges for
+//! events, and bridges for
//! OpenHuman's `Tool` and `StopHook` traits.
-pub mod continuation;
pub mod runtime;
pub mod store;
pub mod tools;
diff --git a/crates/openhuman-core/src/agent/goals/runtime.rs b/crates/openhuman-core/src/agent/goals/runtime.rs
index 2fd0b76275..974705c44c 100644
--- a/crates/openhuman-core/src/agent/goals/runtime.rs
+++ b/crates/openhuman-core/src/agent/goals/runtime.rs
@@ -151,32 +151,15 @@ fn turn_tokens(input: u64, output: u64) -> u64 {
crate_budget::turn_tokens(input, output)
}
-/// Whether the current turn is an autonomous goal-continuation (vs. a
-/// user-initiated turn). Used so a continuation doesn't clear its own one-shot
-/// suppression flag.
-fn is_goal_continuation_turn() -> bool {
- matches!(
- crate::agent::turn_origin::current(),
- Some(
- crate::agent::turn_origin::AgentTurnOrigin::TrustedAutomation {
- source: crate::agent::turn_origin::TrustedAutomationSource::GoalContinuation,
- ..
- }
- )
- )
-}
-
/// Account a finished turn's usage against an explicit thread's goal.
///
/// The accounting rules are the crate's
/// ([`crate_budget::account_turn`](tinyagents_graph::goals::account_turn)):
/// only **active** goals are charged, so a paused/complete/budget-limited goal
-/// doesn't accrue usage from incidental chat, and a user-initiated turn clears
-/// the one-shot continuation suppression (a continuation turn must not clear
-/// its own, see [`super::continuation`]).
+/// doesn't accrue usage from incidental chat. OpenHuman runs no autonomous
+/// goal continuation, so every accounted turn is user-initiated.
///
-/// What is OpenHuman's here: receiving the owned thread from the turn,
-/// classifying the turn as user-initiated vs. continuation from its origin, and
+/// What is OpenHuman's here: receiving the owned thread from the turn and
/// emitting `ThreadGoalUpdated` when the status changes (e.g. →
/// `budget_limited`) so the UI chip refreshes. Best-effort throughout: a
/// failure is logged and swallowed so accounting never fails a user turn.
@@ -202,8 +185,7 @@ pub async fn account_turn_against_goal(
let prev_tokens_used = prev.tokens_used;
let store = goals_store(workspace_dir);
- let user_initiated = !is_goal_continuation_turn();
- match crate_budget::account_turn(&store, &thread_id, input, output, secs, user_initiated).await
+ match crate_budget::account_turn(&store, &thread_id, input, output, secs, true).await
{
Ok(Some(updated)) => {
tracing::debug!(
diff --git a/crates/openhuman-core/src/agent/goals/runtime_tests.rs b/crates/openhuman-core/src/agent/goals/runtime_tests.rs
index 47419a8325..0d079ab67f 100644
--- a/crates/openhuman-core/src/agent/goals/runtime_tests.rs
+++ b/crates/openhuman-core/src/agent/goals/runtime_tests.rs
@@ -99,9 +99,14 @@ async fn account_turn_clears_suppression_without_losing_usage() {
let goal = store::set(&dir, "t-suppressed", "obj", Some(1000))
.await
.unwrap();
- store::set_continuation_suppressed_if(&dir, "t-suppressed", &goal.goal_id, true)
- .await
- .unwrap();
+ tinyagents_graph::goals::store::set_continuation_suppressed_if(
+ &goals_store(&dir),
+ "t-suppressed",
+ &goal.goal_id,
+ true,
+ )
+ .await
+ .unwrap();
account_turn_against_goal(&dir, Some("t-suppressed"), 80, 40, 3).await;
diff --git a/crates/openhuman-core/src/agent/goals/store.rs b/crates/openhuman-core/src/agent/goals/store.rs
index 4a5095fa23..0bca501bf2 100644
--- a/crates/openhuman-core/src/agent/goals/store.rs
+++ b/crates/openhuman-core/src/agent/goals/store.rs
@@ -4,8 +4,7 @@
//! crate's `graph::goals` KV store
//! (`<workspace>/tinyagents_store/kv/graph.goals/<hex(thread_id)>.json`), not
//! the legacy `<workspace>/thread_goals/` file-JSON tree. This module is a thin
-//! adapter for the harness turn loop, heartbeat continuation runtime, agent
-//! tools, and post-turn accounting. It forwards each operation to the crate
+//! adapter for the harness turn loop, agent tools, and post-turn accounting. It forwards each operation to the crate
//! store, converting the crate
//! [`CrateThreadGoal`](tinyagents_graph::goals::types::ThreadGoal) back to the
//! local [`ThreadGoal`] and its `TinyAgentsError` to a `String`.
@@ -73,15 +72,6 @@ pub async fn get(workspace_dir: &Path, thread_id: &str) -> Result<Option<ThreadG
Ok(goal)
}
-/// Every stored thread goal (used by the heartbeat continuation sweep).
-pub async fn list_all(workspace_dir: &Path) -> Result<Vec<ThreadGoal>, String> {
- let store = goals_store(workspace_dir);
- let goals = crate_store::list_all(&store)
- .await
- .map_err(|e| e.to_string())?;
- Ok(goals)
-}
-
/// Delete the thread's goal. Returns whether a goal was present.
pub async fn clear(workspace_dir: &Path, thread_id: &str) -> Result<bool, String> {
let store = goals_store(workspace_dir);
@@ -120,28 +110,6 @@ pub async fn resume(workspace_dir: &Path, thread_id: &str) -> Result<ThreadGoal,
Ok(goal)
}
-/// Set `continuation_suppressed` only when the thread's current goal still
-/// matches `expected_goal_id`, is active, and isn't already in the requested
-/// state (compare-and-set). Returns the goal after the (possibly skipped)
-/// write, or `None` when the thread has no goal.
-pub async fn set_continuation_suppressed_if(
- workspace_dir: &Path,
- thread_id: &str,
- expected_goal_id: &str,
- suppressed: bool,
-) -> Result<Option<ThreadGoal>, String> {
- let store = goals_store(workspace_dir);
- let goal = crate_store::set_continuation_suppressed_if(
- &store,
- thread_id,
- expected_goal_id,
- suppressed,
- )
- .await
- .map_err(|e| e.to_string())?;
- Ok(goal)
-}
-
/// Account token + time usage against the goal, applying the budget constraint.
/// The delta is ignored when `expected_goal_id` no longer matches the current
/// goal (stale-write guard). Returns the goal after the (possibly skipped)