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
fix(flows): correct test assertion for memory tool output
Steven Enamakel4aac231c2d45
diff --git a/crates/openhuman-core/src/flows/memory_tools_tests.rs b/crates/openhuman-core/src/flows/memory_tools_tests.rsindex dc0a964925..71fa8b6006 100644--- a/crates/openhuman-core/src/flows/memory_tools_tests.rs+++ b/crates/openhuman-core/src/flows/memory_tools_tests.rs@@ -1,56 +1,4 @@use super::*;-use crate::security::AutonomyLevel;-use tempfile::TempDir;--// Seeding still goes through the engine handle (`UnifiedMemory` above),-// but the value types are the CONTRACT's: `tinymemory_core` re-exports-// `tinymemory_api::types::{MemoryCategory, MemoryTaint}` verbatim-// (tinymemory#18 §A1 moved them onto the contract so a second engine could-// be bound without translating). Naming them at the contract keeps the-// alias honest and is one fewer reason this file holds the crate (#5560).-use crate::memory::api::types::{MemoryCategory as EngineCategory, MemoryTaint as EngineTaint};--// ── Why `UnifiedMemory` is still here, and what replacing it costs (#5560)-//-// This whole module is `#[cfg(test)]`, so the engine is not linked into a-// production build from this file; the crate survives #5560 as a-// dev-dependency and this is the kind of fixture that keeps it. What the-// fixture cannot do is move to the bound driver in a one-line swap, and-// there are two independent reasons worth recording before someone tries.-//-// 1. **The seam is a different trait.** `test_mem` hands back-// `Arc<dyn memory::Memory>` (= `tinymemory_api::traits::Memory`), and-// `Arc<dyn MemoryProvider>` does not coerce to it: `MemoryProvider`'s-// supertrait is `MemoryCore`, which is a *different* trait with taint as-// an argument rather than a second method (see `provider/mandatory.rs`,-// which says so at the definition). Rebinding the fixture onto-// `memory::test_support::install_memory_driver_for_test` therefore rewrites-// every `mem.store_with_taint(..)` / `mem.get(..)` in this module, not-// just its two lines.-// 2. **The backend choice is load-bearing.** `FLOW_MEMORY_NAMESPACE_PREFIX`'s-// doc above turns on `UnifiedMemory::sanitize_namespace` disagreeing with-// `Memory::forget`'s raw `WHERE namespace = ?1`. A volatile stand-in such-// as `tinycortex::memory::store::InMemoryMemoryStore` implements the same-// `Memory` trait and would compile, but it does not reproduce that-// inconsistency — so it would quietly stop testing the property the-// prefix exists to satisfy.-//-// Every test below that touches `test_mem` is already `#[ignore]`d, and-// their ignore reason is the deeper problem: the tools resolve the *bound-// driver*, so a store seeded here is not the store they read. Making them-// coherent again is a fixture rewrite against the binding — a change worth-// making on its own, with the tests un-ignored so the result is verified,-// not folded into a dependency-shedding pass.--fn test_security() -> Arc<SecurityPolicy> {- Arc::new(SecurityPolicy::default())-}--fn test_mem() -> (TempDir, Arc<dyn crate::memory::Memory>) {- let tmp = TempDir::new().unwrap();- let mem = crate::memory::tool_memory::test_helpers::MockMemory::default();- (tmp, Arc::new(mem))-}// ── flow_namespace / FLOW_MEMORY_NAMESPACE_PREFIX ───────────────// (relocated from `flows::mod` — see that module's re-export comment)@@ -77,17 +25,11 @@ fn recall_name_and_schema() {assert!(schema["properties"]["flow_id"].is_object());assert!(schema["properties"]["scope"].is_object());}-// T-m5: a missing/invalid input param reports via `ToolResult::error`-// (an `Ok(..)` the model can read and react to in-turn), never-// `Err(anyhow!)` (a hard tool-invocation failure) — matching every other-// input-validation problem on this belt (see the scope/empty-value-// tests above, which already used this channel before the fix).// ── FlowMemoryRememberTool ──────────────────────────────────────#[test]fn remember_name_and_schema() {- let (_tmp, _mem) = test_mem();- let tool = FlowMemoryRememberTool::new(test_security());+ let tool = FlowMemoryRememberTool::new(Arc::new(SecurityPolicy::default()));assert_eq!(tool.name(), "flow_memory_remember");let schema = tool.parameters_schema();assert!(schema["properties"]["flow_id"].is_object());@@ -98,18 +40,3 @@ fn remember_name_and_schema() {assert!(schema["properties"]["namespace"].is_null());assert_eq!(tool.permission_level(), PermissionLevel::Write);}--/// Helper: a trusted `TrustedAutomation { Workflow }` origin scoped to-/// `job_id`, the only source `flow_memory_remember` will act on since the-/// T-M2 fix.-fn trusted_workflow_origin(job_id: &str) -> AgentTurnOrigin {- AgentTurnOrigin::TrustedAutomation {- job_id: job_id.to_string(),- source: TrustedAutomationSource::Workflow {- require_approval: false,- },- }-}-// T-m5 (retained through the T-M2 merge): the missing-param checks run-// BEFORE the trusted-origin resolution, so they are still reachable outside-// a run and still assert the `ToolResult::error` channel rather than `Err`.\ No newline at end of filediff --git a/crates/openhuman-core/src/skills/e2e_run_tests.rs b/crates/openhuman-core/src/skills/e2e_run_tests.rsdeleted file mode 100644index ac3a84ce47..0000000000--- a/crates/openhuman-core/src/skills/e2e_run_tests.rs+++ /dev/null@@ -1,202 +0,0 @@-//! Mocked-LLM e2e tests for generic workflow-run plumbing.-//!-//! These ignored, serial tests cover two generic workflow behaviours: an inner-//! workflow reaches a-//! terminal footer and an orchestrator consumes that result via `run_workflow`.--use std::sync::atomic::{AtomicBool, Ordering};-use std::sync::Arc;-use std::time::Duration;--use async_trait::async_trait;--use crate::agent::harness::run_channel_turn_via_graph;-use crate::agent::messages::ChatMessage;-use crate::agent::tools::RunWorkflowTool;-use crate::config::{MultimodalConfig, MultimodalFileConfig};-use crate::inference::provider::factory::test_provider_override;-use crate::skills::runtime::{await_run_outcome, spawn_workflow_run_background};-use tinyinference_llm::message::AssistantMessage;-use tinyinference_llm::model::{ChatModel, ModelProfile, ModelRequest, ModelResponse};-use tinyinference_llm::tool::ToolCall;-use tinytools::Tool;--fn serial() -> &'static tokio::sync::Mutex<()> {- static LOCK: std::sync::OnceLock<tokio::sync::Mutex<()>> = std::sync::OnceLock::new();- LOCK.get_or_init(|| tokio::sync::Mutex::new(()))-}--struct WorkspaceEnv {- previous: Option<String>,-}--impl WorkspaceEnv {- fn set(path: &std::path::Path) -> Self {- let previous = std::env::var("OPENHUMAN_WORKSPACE").ok();- std::env::set_var("OPENHUMAN_WORKSPACE", path);- Self { previous }- }-}--impl Drop for WorkspaceEnv {- fn drop(&mut self) {- match &self.previous {- Some(value) => std::env::set_var("OPENHUMAN_WORKSPACE", value),- None => std::env::remove_var("OPENHUMAN_WORKSPACE"),- }- }-}--struct MockLlm {- workflow_id: Option<String>,- workflow_call_emitted: AtomicBool,-}--impl MockLlm {- fn new(workflow_id: Option<&str>) -> Arc<Self> {- Arc::new(Self {- workflow_id: workflow_id.map(str::to_owned),- workflow_call_emitted: AtomicBool::new(false),- })- }-}--fn final_text(text: &str) -> ModelResponse {- ModelResponse::assistant(text)-}--fn tool_call_response(id: &str, name: &str, arguments: serde_json::Value) -> ModelResponse {- ModelResponse {- message: AssistantMessage {- id: None,- content: Vec::new(),- tool_calls: vec![ToolCall::new(id, name, arguments)],- usage: None,- origin: None,- },- usage: None,- finish_reason: Some("tool_calls".to_string()),- raw: None,- resolved_model: None,- continue_turn: None,- served_from_cache: false,- correlation: None,- resolved_route: None,- }-}--#[async_trait]-impl ChatModel<()> for MockLlm {- async fn invoke(- &self,- _state: &(),- request: ModelRequest,- ) -> tinyinference_llm::Result<ModelResponse> {- let conversation = request- .messages- .iter()- .map(|message| message.text())- .collect::<Vec<_>>()- .join("\n");- if conversation.contains("running a single workflow")- || conversation.contains("Workflow guidelines")- {- return Ok(final_text("WORKFLOW_DONE: inbox triaged"));- }- if conversation.contains("WORKFLOW_DONE") || conversation.contains("\"status\"") {- return Ok(final_text("ORCHESTRATOR_DONE"));- }- match &self.workflow_id {- Some(id) if !self.workflow_call_emitted.swap(true, Ordering::SeqCst) => {- Ok(tool_call_response(- "c1",- "run_workflow",- serde_json::json!({ "workflow_id": id, "wait_seconds": 20 }),- ))- }- Some(_) => Ok(final_text("WORKFLOW_DONE: inbox triaged")),- None => Ok(final_text("TASK_DONE_NO_WORKFLOW")),- }- }-}--fn seed_runnable_workflow(workspace: &std::path::Path, id: &str) {- let directory = workspace.join("skills").join(id);- std::fs::create_dir_all(&directory).unwrap();- std::fs::write(- directory.join("skill.toml"),- format!("id = \"{id}\"\nwhen_to_use = \"triage email\"\n"),- )- .unwrap();- std::fs::write(- directory.join("SKILL.md"),- format!(- "---\nname: {id}\ndescription: Triage the inbox.\n---\n\nSummarise and label the inbox.\n"- ),- )- .unwrap();-}--#[ignore = "process-global model override + OPENHUMAN_WORKSPACE; run serially"]-#[tokio::test]-async fn inner_workflow_run_executes_via_mock_llm_and_reaches_done() {- let _serial = serial().lock().await;- let workspace_root = tempfile::tempdir().unwrap();- let _environment = WorkspaceEnv::set(workspace_root.path());- let workspace = crate::skills::schemas::resolve_workspace_dir().await;- seed_runnable_workflow(&workspace, "triage-inbox");- let _provider = test_provider_override::install_model(MockLlm::new(Some("triage-inbox")));-- let started = spawn_workflow_run_background("triage-inbox".to_string(), None)- .await- .expect("runnable workflow should spawn");- let outcome = await_run_outcome(&started.log_path, Duration::from_secs(20))- .await- .unwrap_or_else(|| panic!("inner workflow did not reach a terminal footer"));-- assert_eq!(outcome.status, "DONE");- assert!(outcome.output.contains("WORKFLOW_DONE"));-}--#[ignore = "process-global model override + OPENHUMAN_WORKSPACE; run serially"]-#[tokio::test]-async fn orchestrator_runs_workflow_tool_and_gets_inner_result() {- let _serial = serial().lock().await;- let workspace_root = tempfile::tempdir().unwrap();- let _environment = WorkspaceEnv::set(workspace_root.path());- let workspace = crate::skills::schemas::resolve_workspace_dir().await;- seed_runnable_workflow(&workspace, "triage-inbox");- let mock = MockLlm::new(Some("triage-inbox"));- let _provider = test_provider_override::install_model(mock.clone());- let model: Arc<dyn ChatModel<()>> = mock;- let mut profile = ModelProfile::default();- profile.tool_calling = true;- profile.parallel_tool_calls = true;- let tools: Arc<Vec<Box<dyn Tool>>> = Arc::new(vec![Box::new(RunWorkflowTool::new())]);- let mut history = vec![ChatMessage::user("Triage my inbox.")];-- let result = run_channel_turn_via_graph(- crate::agent::tinyagents::TurnModelSource::from_model_with_profile(model, profile),- &mut history,- tools,- vec![],- None,- "model",- 0.0,- 5,- MultimodalConfig::default(),- MultimodalFileConfig::default(),- None,- )- .await- .expect("orchestrator loop should complete");-- assert_eq!(result.text, "ORCHESTRATOR_DONE");- let tool_messages = history- .iter()- .filter(|message| message.role == "tool")- .map(|message| message.content.clone())- .collect::<Vec<_>>()- .join("\n");- assert!(tool_messages.contains("DONE") && tool_messages.contains("WORKFLOW_DONE"));-}