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: remove unused modules and dead code
Steven Enamakel5b7b41d535f5
diff --git a/crates/openhuman-core/src/agent/session_host/builder/helpers.rs b/crates/openhuman-core/src/agent/session_host/builder/helpers.rsdeleted file mode 100644index dbac09ff14..0000000000--- a/crates/openhuman-core/src/agent/session_host/builder/helpers.rs+++ /dev/null@@ -1,209 +0,0 @@-//! Utility helpers used during agent construction.-//!-//! # A note on the store this reaches (#5560)-//!-//! [`tool_memory_store`] is host-side now — see-//! [`memory::tool_memory::store`](crate::memory::tool_memory::store)-//! — where it used to be `tinycortex`'s. No call site changed, because the-//! convention it applies (the `tool-<name>` namespace, the `rule/<id>` key, the-//! record's serde) comes from the contract that both ends read.-//!-//! **Do not "modernise" this onto `active_memory_guard().as_tool_memory()`.**-//! `memory` is the session's canonical workspace store. The binding below is-//! shared with the session's `DriverMemory`, so recall and tool-memory rules-//! always address the same durable data.--use crate::memory::api::provider::MemoryProvider;-use crate::memory::auto_recall::AutoRecall;-use crate::memory::tool_memory::{tool_memory_store, ToolMemoryRule};-use crate::memory::Memory;-use std::sync::Arc;--use crate::agent::prompts::SystemPromptBuilder;-use std::collections::HashSet;-use tinytools::Tool;--/// Binds this session's memory subtree once and hands back the two handles-/// the factory takes from it: the raw provider the archivist writes through,-/// and Lane C (#6040) over the same binding's guard, so the auto-recall reads-/// exactly the subtree the session chats against — a dedicated profile recalls-/// its own facts, never the shared tree's.-pub(super) fn bind_session_memory(- config: &crate::config::Config,-) -> anyhow::Result<(Arc<dyn MemoryProvider>, Arc<AutoRecall>)> {- let binding = crate::memory::binding::for_config(config)- .map_err(|e| anyhow::anyhow!("archivist memory binding: {e}"))?;- let auto_recall = Arc::new(AutoRecall::from_guard(binding.guard()));- Ok((binding.provider().clone(), auto_recall))-}--/// (#1400) Best-effort synchronous prefetch of eager tool-scoped rules.-///-/// `from_config_*` is sync but typically runs inside a multi-threaded-/// Tokio runtime (the agent harness path from the channels runtime).-/// We use `block_in_place` + the current runtime handle to call the-/// async store API without restructuring the whole session builder.-///-/// Returns an empty `Vec` (rather than erroring) when:-/// - no Tokio runtime is active (e.g. a sync CLI bootstrap),-/// - the runtime is single-threaded (`block_in_place` would panic),-/// - or the underlying `rules_for_prompt` call returns an error-/// (e.g. the memory backend isn't ready yet).-///-/// Critical / High rules captured later in the session are still-/// available via the `memory_tool_rules_for_prompt` RPC; this prefetch-/// merely seeds the rules that exist at session start.-pub(super) fn prefetch_tool_memory_rules_blocking(- memory: Arc<dyn Memory>,- tool_names: &[String],-) -> Vec<ToolMemoryRule> {- let Ok(handle) = tokio::runtime::Handle::try_current() else {- return Vec::new();- };- if handle.runtime_flavor() != tokio::runtime::RuntimeFlavor::MultiThread {- return Vec::new();- }- let tool_names = tool_names.to_vec();- tokio::task::block_in_place(|| {- handle.block_on(async move {- let store = tool_memory_store(memory);- match store.rules_for_prompt(&tool_names).await {- Ok(grouped) => {- let mut flat: Vec<_> = grouped.into_values().flatten().collect();- flat.sort_by(|a, b| {- b.priority- .cmp(&a.priority)- .then_with(|| a.tool_name.cmp(&b.tool_name))- .then_with(|| a.rule.cmp(&b.rule))- });- flat- }- Err(err) => {- log::warn!("[memory::tool_memory] prefetch failed: {err}");- Vec::new()- }- }- })- })-}--/// Register the memory prompt sections a session should carry.-///-/// One gate per direction, and neither consults `learning.enabled`: the-/// instructions are about the memory *tools*, which exist whether or not the-/// learning subsystem runs (#6040 untied the read side, #6048 the write side).-/// A model holding those tools with no rule on when to use them is what-/// produced both bugs — claiming absence unsearched, and "got it, saved" with-/// zero tool calls.-///-/// - `MemoryAccessSection` (read side, #566/#6040): a retrieval tool is offered.-/// - `MemoryWriteSection` (write side, #6048): a writing tool is offered, and it-/// names only the write tools this session actually holds.-///-/// Each gate needs the tool registered **and** visible after filtering-/// (`any_tool_offered`): a rule about a tool the model cannot see would only-/// teach it to apologise.-pub(super) fn add_memory_prompt_sections(- prompt_builder: SystemPromptBuilder,- tools: &[Box<dyn Tool>],- delegation_tools: &[Box<dyn Tool>],- visible: &HashSet<String>,- agent_id: &str,-) -> SystemPromptBuilder {- use crate::agent::learning::{- any_tool_offered, MemoryAccessSection, MemoryWriteSection, MEMORY_READ_TOOLS,- MEMORY_STORE_TOOL, MEMORY_TOOL, MEMORY_WRITE_DELEGATE_TOOL, SAVE_PREFERENCE_TOOL,- };- let mut prompt_builder = prompt_builder;- // Gate on the set the model will actually see: packs are stripped from- // `visible` later in the build, and gating on the pre-strip set told the- // orchestrator to call `save_preference` while the pack held it off the- // wire.- let visible = &{- let mut after = visible.clone();- crate::tools::toolpacks::strip_packed_from_visible(&mut after, agent_id);- after- };- // The collapsed `memory` tool counts only for the actions it still- // advertises: a driver that cannot store drops `learn`, and one that cannot- // search leaves only writes, so the tool's name alone proves neither.- let memory_actions: Vec<String> = tools- .iter()- .chain(delegation_tools)- .find(|tool| tool.name() == MEMORY_TOOL)- .filter(|_| any_tool_offered(&[MEMORY_TOOL], tools, delegation_tools, visible))- .map(|tool| crate::memory::tools::advertised_actions(tool.as_ref()))- .unwrap_or_default();- let memory_can_read = memory_actions- .iter()- .any(|a| a == "ask" || a == "keyword_search");- let memory_can_learn = memory_actions.iter().any(|a| a == "learn");- let legacy_read: Vec<&str> = MEMORY_READ_TOOLS- .iter()- .copied()- .filter(|name| *name != MEMORY_TOOL)- .collect();- if memory_can_read || any_tool_offered(&legacy_read, tools, delegation_tools, visible) {- prompt_builder = prompt_builder.add_section(Box::new(MemoryAccessSection));- log::debug!("[memory_access] prompt section registered");- } else {- log::debug!(- "[memory_access] skipping MemoryAccessSection — neither memory_recall nor \- memory_search is registered+visible for agent={agent_id}"- );- }- // Asked per tool, not once for the pair: the section names the routes it- // is given, so a profile carrying only one write tool must not be told- // about the other (review finding).- let preferences = any_tool_offered(&[SAVE_PREFERENCE_TOOL], tools, delegation_tools, visible);- let store_offered = any_tool_offered(&[MEMORY_STORE_TOOL], tools, delegation_tools, visible);- // The collapsed `memory` tool writes through its `learn` action; the legacy- // `memory_store` wins the wording only when both are held.- let memory_offered = memory_can_learn;- let facts = store_offered || memory_offered;- // #6200: asked for as well as the pair, not instead of it. An agent whose- // only write path is the delegate held the tool and no rule about using it- // — the write-side twin of the read-side gap #6183 closed.- let delegate = any_tool_offered(- &[MEMORY_WRITE_DELEGATE_TOOL],- tools,- delegation_tools,- visible,- );- if preferences || facts || delegate {- let mut section = MemoryWriteSection::new(preferences, facts, delegate);- if memory_offered && !store_offered {- section = section.via_memory_tool();- }- prompt_builder = prompt_builder.add_section(Box::new(section));- log::debug!(- "[memory_write] prompt section registered for agent={agent_id} \- save_preference={preferences} memory_store={facts} \- manage_profile_memory={delegate}"- );- } else {- log::debug!(- "[memory_write] skipping MemoryWriteSection — none of memory_store, \- save_preference or manage_profile_memory is registered+visible for \- agent={agent_id}"- );- }- prompt_builder-}--pub(super) fn derive_turn_workspace_descriptor() -> Option<tinytools::WorkspaceDescriptor> {- let root = crate::agent::turn_workspace::current()?;- if !root.is_dir() {- tracing::warn!(- root = %root.display(),- "[turn_workspace] scoped root is not an existing directory — \- falling back to the shared action_dir cwd for this turn"- );- return None;- }- tracing::debug!(- root = %root.display(),- "[turn_workspace] turn bound to the embedder's per-turn root as default cwd"- );- Some(tinytools::WorkspaceDescriptor::new(root).with_policy_id("turn-workspace"))-}diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/prompt.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/prompt.rsdeleted file mode 100644index 4d3a6185ba..0000000000--- a/crates/openhuman-core/src/agent/session_host/runtime_session/prompt.rs+++ /dev/null@@ -1,92 +0,0 @@-use super::*;--impl OpenHumanTurnPrelude {- pub(super) fn build_system_prompt_tiered(- &self,- learned: crate::agent::prompts::LearnedContextData,- ) -> Result<crate::agent::prompts::TieredPrompt> {- use crate::agent::prompts::{tool_call_format_from_dialect, PromptContext, PromptTool};- let surface = self- .tool_surface- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner);- let specs = surface- .visible_tool_specs- .iter()- .filter(|spec| {- self.thread_id.is_some()- || !crate::agent::tinyagents::harness_tool_registration::is_thread_goal_tool(- &spec.name,- )- })- .map(|spec| spec.as_ref().clone())- .collect::<Vec<_>>();- let prompt_specs = specs- .iter()- .filter(|spec| !surface.permanent_tool_names.contains(&spec.name))- .cloned()- .collect::<Vec<_>>();- let instructions = self.tool_dispatcher.prompt_instructions(&prompt_specs);- let tool_refs = surface- .tools- .iter()- .chain(surface.synthesized_tools.iter())- .filter(|tool| {- self.thread_id.is_some()- || !crate::agent::tinyagents::harness_tool_registration::is_thread_goal_tool(- tool.name(),- )- })- .map(|tool| tool.as_ref())- .collect::<Vec<_>>();- let mut prompt_tools = PromptTool::from_tool_refs(tool_refs.iter().copied());- prompt_tools.retain(|tool| !surface.permanent_tool_names.contains(tool.name.as_ref()));- let mut visible_tool_names = surface.tool_policy_session.visible_tool_names_for_prompt();- visible_tool_names.retain(|name| !surface.permanent_tool_names.contains(name));- if self.thread_id.is_none() {- visible_tool_names.retain(|name| {- !crate::agent::tinyagents::harness_tool_registration::is_thread_goal_tool(name)- });- }- crate::agent::prompts::swap_deferred_for_discovery_bridge(- &mut prompt_tools,- &mut visible_tool_names,- &surface.deferred_tool_names,- );- let agents_md = if self.config.agents_md_enabled {- crate::agent::prompts::load_agents_md_layers(&self.workspace_dir, &self.action_dir)- } else {- Default::default()- };- let mutable = self- .mutable- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner);- let context = PromptContext {- workspace_dir: &self.workspace_dir,- model_name: &self.model_name,- agent_id: &self.agent_definition_name,- tools: &prompt_tools,- workflows: &mutable.workflows,- dispatcher_instructions: &instructions,- learned,- visible_tool_names: &visible_tool_names,- tool_call_format: tool_call_format_from_dialect(- self.tool_dispatcher.tool_call_format(),- ),- connected_integrations: &mutable.connected_integrations,- connected_identities_md: crate::agent::prompts::render_connected_identities(),- include_profile: !self.omit_profile,- include_memory_md: !self.omit_memory_md,- curated_snapshot: None,- user_identity: crate::security::credentials::identity::peek_credential_user_identity(),- personality_roster: vec![],- agents_md_global: agents_md.global,- agents_md_local: agents_md.local,- };- self.context- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner)- .build_system_prompt_tiered(&context)- }-}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_protocol.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/memory_protocol.rsdeleted file mode 100644index 0bd1476b14..0000000000--- a/crates/openhuman-core/src/agent/tinyagents/middleware/memory_protocol.rs+++ /dev/null@@ -1,71 +0,0 @@-//! OpenHuman's memory-protocol wiring: the tool vocabulary handed to the-//! upstream `MemoryProtocolMiddleware`-//! (`tinyagents_harness::middleware::MemoryProtocolMiddleware`).-//!-//! Agents are told to follow a **read-index → dedupe → write → update-index**-//! cycle around durable memory. The state machine, the corrective notes and the-//! middleware live upstream; which OpenHuman tools play which role is host-//! vocabulary and is defined here.--use std::sync::Arc;--use tinyagents_harness::middleware::{MemoryProtocolMiddleware, MemoryProtocolSpec, ModeTool};--/// Build the OpenHuman tool vocabulary for the memory protocol.-///-/// - `update_memory_md` edits either `MEMORY.md` **or** `SKILL.md`-/// (`tinytools_std::filesystem::UpdateMemoryMdTool`); only a `MEMORY.md` edit-/// reconciles the memory index, so a `SKILL.md` edit must not close the cycle.-/// - The consolidated `memory_tree` tool-/// (`crates/openhuman-core/src/memory/query/mod.rs`) is a read in every `mode`-/// except `ingest_document`, which writes a document into the tree.-/// - `remember_preference` / `save_preference` (#4458) DO persist via-/// `Memory::store`, but into dedicated preference namespaces-/// (`pinned_preferences` / `user_pref_{general,situational}`) surfaced by-/// direct system-prompt injection or per-query recall. They are NOT part of the-/// `MEMORY.md` curated wiki the archivist reconciles, so they are deliberately-/// unlisted (classified `Other`): treating them as writes would resurrect the-/// unsatisfiable "call update_memory_md" nag loop that issue removed.-pub fn memory_protocol_spec() -> Arc<MemoryProtocolSpec> {- Arc::new(MemoryProtocolSpec {- index_update_tool: "update_memory_md".into(),- index_file_arg: "file".into(),- index_file: "MEMORY.md".into(),- // Durable mutations: create an entry, delete an entry, or ingest a- // document into the memory tree (the split-out ingest tool).- write_tools: [- "memory_store",- "memory_forget",- "memory_tree_ingest_document",- ]- .map(String::from)- .to_vec(),- // Dedupe reads: recall/search over stored memory, or a read-only walk of- // the memory tree.- read_tools: [- "memory_recall",- "memory_vector_search",- "memory_chunk_context",- "memory_hybrid_search",- "memory_tree_query_source",- "memory_tree_search_entities",- "memory_tree_fetch_leaves",- "memory_tree_drill_down",- "memory_tree_cover_window",- ]- .map(String::from)- .to_vec(),- mode_tool: Some(ModeTool {- name: "memory_tree".into(),- mode_arg: "mode".into(),- write_mode: "ingest_document".into(),- }),- recall_tool: "memory_recall".into(),- })-}--/// The memory-protocol middleware for an OpenHuman turn. `can_update_index`-/// states whether `update_memory_md` is actually available this turn.-pub fn memory_protocol_middleware(can_update_index: bool) -> MemoryProtocolMiddleware {- MemoryProtocolMiddleware::with_index_update_tool(memory_protocol_spec(), can_update_index)-}diff --git a/crates/openhuman-core/src/config/migration_helpers/mod.rs b/crates/openhuman-core/src/config/migration_helpers/mod.rsdeleted file mode 100644index baf655919b..0000000000--- a/crates/openhuman-core/src/config/migration_helpers/mod.rs+++ /dev/null@@ -1,13 +0,0 @@-//! Data migration helpers for OpenHuman.--mod core;-pub mod ops;-mod schemas;--pub use core::*;-pub use ops as rpc;-pub use ops::*;-pub use schemas::{- all_controller_schemas as all_migration_controller_schemas,- all_registered_controllers as all_migration_registered_controllers,-};