The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: reorder imports and add goal observer event test
Steven Enamakele11316be6565
diff --git a/crates/openhuman-core/src/agent/goals/mod.rs b/crates/openhuman-core/src/agent/goals/mod.rsindex 99c70663d6..a9a018fe51 100644--- a/crates/openhuman-core/src/agent/goals/mod.rs+++ b/crates/openhuman-core/src/agent/goals/mod.rs@@ -38,7 +38,10 @@ pub fn goal_store(}let kv = crate::storage::sessions::stores_or_ephemeral(workspace_dir).kv;- let store = Arc::new(GoalStore::with_observer(kv, Arc::new(OpenHumanGoalObserver)));+ let store = Arc::new(GoalStore::with_observer(+ kv,+ Arc::new(OpenHumanGoalObserver),+ ));stores.insert(workspace_dir.to_path_buf(), Arc::downgrade(&store));store}diff --git a/crates/openhuman-core/src/agent/goals/mod_tests.rs b/crates/openhuman-core/src/agent/goals/mod_tests.rsnew file mode 100644index 0000000000..2114608918--- /dev/null+++ b/crates/openhuman-core/src/agent/goals/mod_tests.rs@@ -0,0 +1,26 @@+use super::*;++#[test]+fn goal_store_is_reused_within_a_context_and_isolated_between_contexts() {+ let first_workspace = tempfile::tempdir().expect("first workspace");+ let second_workspace = tempfile::tempdir().expect("second workspace");+ let first_context = crate::core::runtime::CoreContext::for_test(+ crate::core::runtime::DomainSet::full(),+ Some(first_workspace.path().to_path_buf()),+ );+ let second_context = crate::core::runtime::CoreContext::for_test(+ crate::core::runtime::DomainSet::full(),+ Some(first_workspace.path().to_path_buf()),+ );+ let first_dispatch = crate::core::runtime::DispatchCtx::new(first_context);+ let second_dispatch = crate::core::runtime::DispatchCtx::new(second_context);++ let first = goal_store(first_workspace.path(), &first_dispatch);+ let repeated = goal_store(first_workspace.path(), &first_dispatch);+ let isolated = goal_store(first_workspace.path(), &second_dispatch);+ let other_workspace = goal_store(second_workspace.path(), &first_dispatch);++ assert!(Arc::ptr_eq(&first, &repeated));+ assert!(!Arc::ptr_eq(&first, &isolated));+ assert!(!Arc::ptr_eq(&first, &other_workspace));+}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rsindex a3f4e7301a..547096f46c 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs@@ -1,15 +1,15 @@use std::sync::{Arc, Mutex};use async_trait::async_trait;+use tinyagents_harness::tool::ToolSnapshot;use tinyagents_runtime::{DriverFailure, DriverOutcome, DriverRequest, PrefixSnapshot, ResumeMode, SessionBuilder,- SessionDriver, SessionTerminal, SessionTurnRequest, TranscriptCodec,- TranscriptTurnOptions, TurnOptions,+ SessionDriver, SessionTerminal, SessionTurnRequest, TranscriptCodec, TranscriptTurnOptions,+ TurnOptions,};use tinyagents_session::port::{InMemorySessionStores, SessionStoreProvider};use tinyagents_session::transcript::TranscriptMeta;use tinyinference_llm::message::Message;-use tinyagents_harness::tool::ToolSnapshot;use super::runtime_session::{account_committed_turn_against_goal, holistic_last_turn_usage};use super::{OpenHumanSessionHooks, OpenHumanTranscriptCodec};diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rsindex 38d7aa3873..186e46dd66 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs@@ -28,11 +28,11 @@ use std::sync::Arc;use anyhow::Result;use tinyagents_harness::multimodal::markers::extract_image_placeholders_in_text;+use tinyagents_harness::tool::ToolSnapshot;use tinyagents_runtime::{- CommitReceipt, ResumePreparation, SessionBuilder, SessionTerminal,- TranscriptTarget, TurnPreparation,+ CommitReceipt, ResumePreparation, SessionBuilder, SessionTerminal, TranscriptTarget,+ TurnPreparation,};-use tinyagents_harness::tool::ToolSnapshot;use tinyinference_llm::message::Message;use super::types::OpenHumanSessionHost;diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex 80ddb19208..41a99a0371 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -10,6 +10,7 @@ use std::{sync::{Arc, Mutex},};use tinyagents_harness::context::{RunConfig, RunContext};+use tinyagents_harness::tool::ToolSnapshot;use tinyagents_orchestration::subagent::{ArtifactReference, PreparedSubagent, SubagentCapabilities, SubagentDriver, SubagentError,SubagentExecution, SubagentExecutor, SubagentIncomplete, SubagentOutcome, SubagentOutcomeKind,@@ -17,7 +18,6 @@ use tinyagents_orchestration::subagent::{SubagentPersistenceDisposition, SubagentPlanner, SubagentRequest, SubagentResume,SubagentRunResult, SubagentTaskKey, SubagentTerminalPersistenceDisposition,};-use tinyagents_harness::tool::ToolSnapshot;use tinyinference_llm::{message::Message,usage::{ChargedAmount, Usage, UsageTotals},diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rsindex 4dcb8a4830..07b28d26d8 100644--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs@@ -8,8 +8,8 @@ use super::types::SubagentRunError;use crate::agent::prompts::PromptContext;use crate::agent_registry::host_definition::AgentDefinition;use tinyagents_definition::{PromptSource, ToolScope};-use tinyagents_orchestration::subagent::{restrict_tools_with_scope, SubagentRole};use tinyagents_harness::tool::ToolSnapshot;+use tinyagents_orchestration::subagent::{restrict_tools_with_scope, SubagentRole};use tinytools::Tool;// ── Prompt dialect selection ────────────────────────────────────────────diff --git a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rsindex 51381688fb..37993a885a 100644--- a/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs+++ b/crates/openhuman-core/src/agent/tinyagents/tool_registration.rs@@ -7,11 +7,11 @@ use std::collections::HashSet;use std::sync::Arc;use async_trait::async_trait;-use tinyagents_harness_tools::goals::GoalToolKind;use tinyagents_harness::tool::packs::{PackSelection, UseSkillDispatch, USE_SKILL};use tinyagents_harness::tool::{CanonicalSharedToolAdapter, ToolDispatch, ToolExecScope, ToolExecution, ToolExecutionContext,};+use tinyagents_harness_tools::goals::GoalToolKind;use tinyagents_registry::{CapabilityRegistry, ComponentKind, RegistryDiagnostic};use tinyagents_runtime::turn_driver::{SharedToolSet, ToolSetBuilder};use tinyagents_runtime::{project_descriptors, ToolAdmission};diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rsindex d366eae9f0..b0ba4f884c 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs@@ -14,12 +14,12 @@ use anyhow::Result;use tinyagents_harness::runtime::AgentHarness;use tinyagents_harness::runtime::{AgentInvocation, AgentTurnRequest, InvocationRuntime};use tinyagents_harness::store::{InMemoryStore as ToolResultArtifactIndexStore, StoreRegistry};+use tinyagents_harness::tool::ToolSnapshot;use tinyagents_harness::turn_policy::effective_max_iterations;use tinyagents_runtime::turn_driver::{SubagentScope as DriverSubagentScope, TurnControls, TurnDriver, TurnScope,};use tinyagents_runtime::DriverRequest;-use tinyagents_harness::tool::ToolSnapshot;use crate::agent::harness::tool_result_artifacts::TINYAGENTS_TOOL_RESULT_ARTIFACT_STORE;use crate::agent::tinyagents::host::OpenHumanRunContext;diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rsindex 49bd137086..b345e26c8a 100644--- a/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/turn_plan_tests.rs@@ -5,12 +5,12 @@ use super::*;use crate::agent::tinyagents::TurnModelSource;use crate::inference::turn_models::TurnModels;use async_trait::async_trait;+use tinyagents_harness::tool::ToolSnapshot;use tinyagents_harness::turn_policy::{DEFAULT_MODEL_CALL_TIMEOUT_SECS, LOCAL_MODEL_CALL_TIMEOUT_SECS,};use tinyagents_runtime::turn_driver::{SharedToolSet, TurnControls, TurnDriver};use tinyagents_runtime::DriverRequest;-use tinyagents_harness::tool::ToolSnapshot;use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};use tinytools::{Tool, ToolResult};diff --git a/crates/openhuman-core/src/agent/tools/plan_exit.rs b/crates/openhuman-core/src/agent/tools/plan_exit.rsindex a1400a8945..81df1197bc 100644--- a/crates/openhuman-core/src/agent/tools/plan_exit.rs+++ b/crates/openhuman-core/src/agent/tools/plan_exit.rs@@ -61,7 +61,11 @@ impl RunModeStore<PlanExitScope> for OpenHumanRunModes {crate::threads::run_mode::handle_for_thread(&scope.context, thread_id)}- fn get_mode(&self, scope: &PlanExitScope, thread_id: &str) -> tinyagents_harness::middleware::RunMode {+ fn get_mode(+ &self,+ scope: &PlanExitScope,+ thread_id: &str,+ ) -> tinyagents_harness::middleware::RunMode {crate::threads::run_mode::get_mode(&scope.context, thread_id)}diff --git a/crates/openhuman-core/src/agent/tools/todo.rs b/crates/openhuman-core/src/agent/tools/todo.rsindex a96b9d9665..5c4211df68 100644--- a/crates/openhuman-core/src/agent/tools/todo.rs+++ b/crates/openhuman-core/src/agent/tools/todo.rs@@ -21,9 +21,9 @@ use crate::agent::harness::fork_context::ParentExecutionContext;use async_trait::async_trait;use std::path::PathBuf;use std::sync::Arc;-use tinyagents_harness_tools::todos::{self as harness_todos, store as todos_store};use tinyagents_harness::context::RunContext;use tinyagents_harness::tool::{ToolDispatch, ToolExecutionContext};+use tinyagents_harness_tools::todos::{self as harness_todos, store as todos_store};use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolResult, ToolRunContext};pub struct TodoTool {diff --git a/crates/openhuman-core/src/agent/tools/todo_tests.rs b/crates/openhuman-core/src/agent/tools/todo_tests.rsindex b1dbf45ca2..4523b1199a 100644--- a/crates/openhuman-core/src/agent/tools/todo_tests.rs+++ b/crates/openhuman-core/src/agent/tools/todo_tests.rs@@ -254,10 +254,12 @@ async fn a_legacy_session_keyed_list_is_migrated_forward_once() {let thread_scope = TodoScope::Session {id: "thread-legacy".into(),};- let migrated =- tinyagents_harness_tools::todos::store::list(&todo_store(&workspace_dir), thread_scope.key())- .await- .unwrap();+ let migrated = tinyagents_harness_tools::todos::store::list(+ &todo_store(&workspace_dir),+ thread_scope.key(),+ )+ .await+ .unwrap();assert_eq!(migrated.items.len(), 1);}@@ -278,13 +280,18 @@ async fn sessions_do_not_see_each_other_and_a_list_survives_across_turns() {.unwrap();let item = TodoItem::with_status("only in a", TodoStatus::InProgress);- tinyagents_harness_tools::todos::store::replace(&todo_store(&workspace_dir), a.key(), vec![item])- .await- .unwrap();+ tinyagents_harness_tools::todos::store::replace(+ &todo_store(&workspace_dir),+ a.key(),+ vec![item],+ )+ .await+ .unwrap();- let a_again = tinyagents_harness_tools::todos::store::list(&todo_store(&workspace_dir), a.key())- .await- .unwrap();+ let a_again =+ tinyagents_harness_tools::todos::store::list(&todo_store(&workspace_dir), a.key())+ .await+ .unwrap();assert_eq!(a_again.items.len(),1,diff --git a/crates/openhuman-core/src/web_chat/event_bus_tests.rs b/crates/openhuman-core/src/web_chat/event_bus_tests.rsindex 8599c08517..dc47516d65 100644--- a/crates/openhuman-core/src/web_chat/event_bus_tests.rs+++ b/crates/openhuman-core/src/web_chat/event_bus_tests.rs@@ -301,6 +301,60 @@ async fn agent_surface_bridges_thread_goal_updated() {assert_eq!(ev.goal, Some(goal));}+/// Goal resume and committed-turn accounting use the same observed owner store+/// as model-facing goal tools, so both lifecycle paths reach the existing+/// thread-scoped socket event.+#[tokio::test]+async fn goal_resume_and_account_updates_reach_the_web_channel() {+ crate::core::bus::init().await.expect("bus init");+ register_agent_surface_subscriber();+ let mut web_rx = subscribe_web_channel_events();++ let workspace = tempfile::tempdir().expect("workspace");+ let context = crate::core::runtime::CoreContext::for_test(+ crate::core::runtime::DomainSet::full(),+ Some(workspace.path().to_path_buf()),+ );+ crate::core::runtime::CoreContext::scope(context, async {+ let dispatch = crate::core::runtime::DispatchCtx::ambient();+ let store = crate::agent::goals::goal_store(workspace.path(), &dispatch);+ let thread_id = "goal-observer-resume-account";++ store+ .set(thread_id, "resume this goal", None)+ .await+ .expect("set goal");+ let _ = find_agent_web_event(&mut web_rx, "thread_goal_updated", thread_id).await;+ store.pause(thread_id).await.expect("pause goal");+ let _ = find_agent_web_event(&mut web_rx, "thread_goal_updated", thread_id).await;++ let prepared = store.prepare_turn(thread_id).await.expect("prepare turn");+ assert_eq!(+ prepared.goal.as_ref().map(|goal| goal.status),+ Some(tinyagents_harness_tools::goals::ThreadGoalStatus::Active)+ );+ let resumed = find_agent_web_event(&mut web_rx, "thread_goal_updated", thread_id).await;+ assert_eq!(+ resumed.goal.as_ref().and_then(|goal| goal.get("status")),+ Some(&serde_json::json!("active"))+ );++ store+ .account_turn(thread_id, 2, 1, std::time::Duration::from_secs(1))+ .await+ .expect("account turn");+ let accounted = find_agent_web_event(&mut web_rx, "thread_goal_updated", thread_id).await;+ assert_eq!(+ accounted+ .goal+ .as_ref()+ .and_then(|goal| goal.get("tokensUsed")),+ Some(&serde_json::json!(3))+ );+ })+ .await;+}+/// `ThreadGoalCleared` bridges to `thread_goal_cleared`.#[tokio::test]async fn agent_surface_bridges_thread_goal_cleared() {diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex d2f474bf3d..59ae408371 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -237,10 +237,10 @@ pub mod seams {/// is held to. The persisted record types are the harness's own serde codecs,/// so hosts can encode and decode stored state without duplicating wire shapes.pub mod session_store {- pub use tinyagents_harness_tools::todos::TodoList;pub use tinyagents_harness::events::{AgentEvent, HarnessRunStatus};pub use tinyagents_harness::ids::ExecutionStatus;pub use tinyagents_harness::observability::AgentObservation;+ pub use tinyagents_harness_tools::todos::TodoList;pub use tinyagents_session::port::{AgentStores, SessionStoreProvider};pub use tinyagents_session::port::{AppendStore, InMemorySessionStores, InMemoryTranscriptLocator, InMemoryTurnStates, Store,