Skip to content

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

style(memory): apply rustfmt formatting across memory and agent modules

Steven Enamakelf83d929ced54
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index fffff877b9..ba97ebedf4 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -74,7 +74,11 @@ struct OpenHumanTurnPrelude {
/// Host prompt/utilisation state, shared by the runtime hooks. It is not
/// generic conversation state and the runtime never persists it.
context: Arc<std::sync::Mutex<crate::agent::context::ContextManager>>,
- tool_policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>,
+ tool_policy: Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
tool_dispatcher: Arc<dyn tinytools_agent::dialect::ToolDialect>,
workspace_dir: std::path::PathBuf,
action_dir: std::path::PathBuf,
@@ -278,9 +282,7 @@ impl OpenHumanTurnPrelude {
.filter(|spec| !withheld.contains(&spec.name))
.filter(|spec| {
self.thread_id.is_some()
- || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(
- &spec.name,
- )
+ || !crate::agent::tinyagents::tool_registration::is_thread_goal_tool(&spec.name)
})
.map(|spec| spec.as_ref().clone())
.collect::<Vec<_>>();
@@ -861,8 +863,7 @@ impl OpenHumanSessionHost {
.unwrap_or_else(|poisoned| poisoned.into_inner())
.take_turn_inputs();
let origin = options.run_context.data.origin.clone();
- let memory_identity =
- options.run_context.data.memory_identity.clone();
+ let memory_identity = options.run_context.data.memory_identity.clone();
let (enriched, memory_turn) = futures::join!(
prelude.enrich_request(
&original_user_message,
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
index 1925bac406..01782c21f2 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/operation_context.rs
@@ -104,7 +104,9 @@ pub(crate) fn tool_context_with_memory_identity(
) -> tinyagents_harness::tool::ToolExecutionContext {
let mut host = super::OpenHumanRunContext::new();
host.memory_identity = Some(identity);
- let run = host.into_tinyagents(tinyagents_harness::context::RunConfig::new("memory-identity-test"));
+ let run = host.into_tinyagents(tinyagents_harness::context::RunConfig::new(
+ "memory-identity-test",
+ ));
tinyagents_harness::tool::ToolExecutionContext::from_run_context(
&run,
tinyagents_harness::ids::CallId::new("memory-identity-test-call"),
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index 719ca0a854..a2829b82b0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -415,7 +415,8 @@ pub(crate) struct HarnessHostPolicy {
}
pub(crate) use super::operation_context::{
- approval_for_tool, memory_identity_for_tool, parent_agent_id_for_tool, sandbox_mode_for_tool, HostOperationContext,
+ approval_for_tool, memory_identity_for_tool, parent_agent_id_for_tool, sandbox_mode_for_tool,
+ HostOperationContext,
};
#[cfg(test)]
pub(crate) use super::operation_context::{
diff --git a/crates/openhuman-core/src/memory/brain.rs b/crates/openhuman-core/src/memory/brain.rs
index 7464dd1803..2a47cc0451 100644
--- a/crates/openhuman-core/src/memory/brain.rs
+++ b/crates/openhuman-core/src/memory/brain.rs
@@ -92,10 +92,7 @@ pub struct BrainSourcesView {
}
/// `memory_brain_sources`: the brain's sources and their sizes.
-pub async fn sources(
- config: &Config,
- identity: &MemoryIdentity,
-) -> MemoryResult<BrainSourcesView> {
+pub async fn sources(config: &Config, identity: &MemoryIdentity) -> MemoryResult<BrainSourcesView> {
let bound = engine::resolve(config).engine()?;
let layout = layout(config, identity);
let page = bound
@@ -166,7 +163,9 @@ pub async fn search(
}
let source = params.source.as_deref().map(parse_source).transpose()?;
let limit = super::types::clamp_limit(params.limit);
- let hits = brain(config, identity)?.search(query, source.as_ref(), limit).await?;
+ let hits = brain(config, identity)?
+ .search(query, source.as_ref(), limit)
+ .await?;
tracing::debug!(hits = hits.len(), "[memory:brain] search");
Ok(BrainSearchView { hits })
}
diff --git a/crates/openhuman-core/src/memory/brain_tests.rs b/crates/openhuman-core/src/memory/brain_tests.rs
index eb8229ae45..ea7391bfa3 100644
--- a/crates/openhuman-core/src/memory/brain_tests.rs
+++ b/crates/openhuman-core/src/memory/brain_tests.rs
@@ -188,7 +188,7 @@ async fn ingest_refuses_bad_input() {
},
] {
assert!(matches!(
- ingest(&config,&MemoryIdentity::root(), params).await,
+ ingest(&config, &MemoryIdentity::root(), params).await,
Err(MemoryError::InvalidRequest(_))
));
}
@@ -289,7 +289,7 @@ async fn ingest_refuses_a_credential_store_a_system_root_traversal_and_null_byte
format!("{}/../guide.md", notes.display()),
format!("{}\0.md", tmp.path().join("guide").display()),
] {
- let result = ingest(&config,&MemoryIdentity::root(), path_params(path.clone())).await;
+ let result = ingest(&config, &MemoryIdentity::root(), path_params(path.clone())).await;
assert!(
matches!(result, Err(MemoryError::InvalidRequest(_))),
"{path:?}: {result:?}"
@@ -310,7 +310,12 @@ async fn ingest_refuses_a_symlink_into_a_credential_store() {
let link = tmp.path().join("innocent.md");
std::os::unix::fs::symlink(aws.join("credentials"), &link).unwrap();
- let result = ingest(&config,&MemoryIdentity::root(), path_params(link.display().to_string())).await;
+ let result = ingest(
+ &config,
+ &MemoryIdentity::root(),
+ path_params(link.display().to_string()),
+ )
+ .await;
assert!(
matches!(result, Err(MemoryError::InvalidRequest(_))),
"{result:?}"
diff --git a/crates/openhuman-core/src/memory/confine.rs b/crates/openhuman-core/src/memory/confine.rs
index 676ff6923e..1ffcb18c81 100644
--- a/crates/openhuman-core/src/memory/confine.rs
+++ b/crates/openhuman-core/src/memory/confine.rs
@@ -116,7 +116,10 @@ pub async fn recall(
identity: &MemoryIdentity,
mut params: RecallParams,
) -> MemoryResult<RecallView> {
- params.filter = Some(confine_filter(params.filter, &allowed_reach(config, identity))?);
+ params.filter = Some(confine_filter(
+ params.filter,
+ &allowed_reach(config, identity),
+ )?);
ops::recall(config, params).await
}
@@ -130,7 +133,10 @@ pub async fn fetch(
identity: &MemoryIdentity,
mut params: FetchParams,
) -> MemoryResult<FetchView> {
- params.filter = Some(confine_filter(params.filter, &allowed_reach(config, identity))?);
+ params.filter = Some(confine_filter(
+ params.filter,
+ &allowed_reach(config, identity),
+ )?);
ops::fetch(config, params).await
}
@@ -159,7 +165,10 @@ pub async fn forget(
identity: &MemoryIdentity,
mut params: ForgetParams,
) -> MemoryResult<ForgetView> {
- params.reach = Some(confine_reach(params.reach, &allowed_reach(config, identity))?);
+ params.reach = Some(confine_reach(
+ params.reach,
+ &allowed_reach(config, identity),
+ )?);
ops::forget(config, params).await
}
@@ -176,7 +185,10 @@ pub async fn items_list(
mut params: ItemsListParams,
) -> MemoryResult<ItemsListView> {
let narrowed = explore::narrowed(params.filter.take(), &params.path)?;
- params.filter = Some(confine_filter(Some(narrowed), &allowed_reach(config, identity))?);
+ params.filter = Some(confine_filter(
+ Some(narrowed),
+ &allowed_reach(config, identity),
+ )?);
params.path = Vec::new();
ops::items_list(config, params).await
}
@@ -193,7 +205,10 @@ pub async fn explore(
mut params: ExploreParams,
) -> MemoryResult<ExplorePage> {
let narrowed = explore::narrowed(params.filter.take(), &params.path)?;
- params.filter = Some(confine_filter(Some(narrowed), &allowed_reach(config, identity))?);
+ params.filter = Some(confine_filter(
+ Some(narrowed),
+ &allowed_reach(config, identity),
+ )?);
params.path = Vec::new();
explore::explore(config, params).await
}
@@ -210,7 +225,10 @@ pub async fn items_get(
identity: &MemoryIdentity,
mut params: ItemsGetParams,
) -> MemoryResult<ItemsGetView> {
- params.reach = Some(confine_reach(params.reach, &allowed_reach(config, identity))?);
+ params.reach = Some(confine_reach(
+ params.reach,
+ &allowed_reach(config, identity),
+ )?);
explore::items_get(config, params).await
}
diff --git a/crates/openhuman-core/src/memory/confine_tests.rs b/crates/openhuman-core/src/memory/confine_tests.rs
index e08ec9fd81..a85544aa04 100644
--- a/crates/openhuman-core/src/memory/confine_tests.rs
+++ b/crates/openhuman-core/src/memory/confine_tests.rs
@@ -75,11 +75,15 @@ fn an_unset_reach_becomes_the_allowed_one_and_a_wider_one_is_refused() {
fn the_allowed_reach_is_the_identity_roots_subtree() {
let tmp = tempfile::tempdir().unwrap();
let mut config = config_in(&tmp);
- assert_eq!(allowed_reach(&config, &MemoryIdentity::root()),
- Reach::subtree(Namespace::ROOT));
+ assert_eq!(
+ allowed_reach(&config, &MemoryIdentity::root()),
+ Reach::subtree(Namespace::ROOT)
+ );
config.memory.root = Some("project:q4".to_string());
- assert_eq!(allowed_reach(&config, &MemoryIdentity::root()),
- Reach::subtree(ns("project:q4")));
+ assert_eq!(
+ allowed_reach(&config, &MemoryIdentity::root()),
+ Reach::subtree(ns("project:q4"))
+ );
}
#[test]
@@ -95,7 +99,7 @@ async fn list_fetch_and_recall_never_read_another_root() {
let tmp = tempfile::tempdir().unwrap();
let (config, mine, theirs) = two_roots(&tmp).await;
- let listed = items_list(&config,&MemoryIdentity::root(), ItemsListParams::default())
+ let listed = items_list(&config, &MemoryIdentity::root(), ItemsListParams::default())
.await
.unwrap();
assert_eq!(ids(&listed.items), std::slice::from_ref(&mine));
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
index 0b0f8ca5d3..6de2935101 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
@@ -348,28 +348,25 @@ async fn queued_work_keeps_the_callers_core_context() {
crate::core::runtime::DomainSet::full(),
Some(config.workspace_dir.clone()),
);
- crate::core::runtime::CoreContext::scope(
- ctx.clone(),
- async {
- let identity = MemoryIdentity::agent("scoped-agent").resolve(&config);
- let key = Key::new(&config, &identity, "t", false);
- let cache = cache();
- let expected = ctx.clone();
- enqueue(
- cache.clone(),
- key.clone(),
- Box::pin(crate::core::runtime::spawn::scoped(async move {
- assert!(Arc::ptr_eq(
- &crate::core::runtime::CoreContext::scoped().unwrap(),
- &expected
- ));
- Some(pack("scoped"))
- })),
- );
- drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "scoped");
- },
- )
+ crate::core::runtime::CoreContext::scope(ctx.clone(), async {
+ let identity = MemoryIdentity::agent("scoped-agent").resolve(&config);
+ let key = Key::new(&config, &identity, "t", false);
+ let cache = cache();
+ let expected = ctx.clone();
+ enqueue(
+ cache.clone(),
+ key.clone(),
+ Box::pin(crate::core::runtime::spawn::scoped(async move {
+ assert!(Arc::ptr_eq(
+ &crate::core::runtime::CoreContext::scoped().unwrap(),
+ &expected
+ ));
+ Some(pack("scoped"))
+ })),
+ );
+ drain(&cache, &key).await;
+ assert_eq!(completed(&cache, &key).unwrap().markdown, "scoped");
+ })
.await;
}
diff --git a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
index 68eb89c6d5..78f2ff5c4f 100644
--- a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
@@ -103,9 +103,13 @@ async fn the_preview_reads_without_logging_and_agents_are_listed() {
assert_eq!(turn.agent_id, "writer");
assert!(turn.pack.markdown.contains("1st"));
- let session = pack_preview(&config,&MemoryIdentity::root(), PackPreviewParams::default())
- .await
- .unwrap();
+ let session = pack_preview(
+ &config,
+ &MemoryIdentity::root(),
+ PackPreviewParams::default(),
+ )
+ .await
+ .unwrap();
assert_eq!(session.mode, "session");
let agents = agents_list(&config, &MemoryIdentity::root()).await.unwrap();
diff --git a/crates/openhuman-core/src/memory/schemas/handlers.rs b/crates/openhuman-core/src/memory/schemas/handlers.rs
index 52c67ade06..41b81b45c8 100644
--- a/crates/openhuman-core/src/memory/schemas/handlers.rs
+++ b/crates/openhuman-core/src/memory/schemas/handlers.rs
@@ -11,13 +11,13 @@ use crate::core::Outcome;
use crate::memory::error::{MemoryError, MemoryResult};
use crate::memory::explore::{ExploreParams, ItemsGetParams};
use crate::memory::lifecycle::views::{self, JobsRunParams, PackPreviewParams, PolicySetParams};
+use crate::memory::scope::MemoryIdentity;
use crate::memory::types::{
EmptyParams, EngineSetParams, EraseAllParams, FetchParams, ForgetParams, ImportStartParams,
ImportStateView, ItemsListParams, LearnParams, RecallParams, SourceAddedView,
SourceRemovedView, SourcesAddParams, SourcesListView, SourcesRemoveParams, SourcesSyncParams,
SourcesSyncView,
};
-use crate::memory::scope::MemoryIdentity;
use crate::memory::{backfill, brain, confine, engine, import, layout_migration, ops, sources};
fn parse<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rs
index 6f0844d978..3892356a45 100644
--- a/crates/openhuman-core/src/memory/tools.rs
+++ b/crates/openhuman-core/src/memory/tools.rs
@@ -149,15 +149,14 @@ impl CallFacts {
.unwrap_or_else(|| config.action_dir.clone());
// The acting identity is the run's own; direct dispatch (CLI, tests)
// has no run, and falls back to the spawning agent, else the root.
- let identity = crate::agent::tinyagents::host::run_context::memory_identity_for_tool(
- context,
- )
- .unwrap_or_else(|| {
- crate::agent::tinyagents::host::run_context::parent_agent_id_for_tool(context)
- .map_or_else(super::scope::MemoryIdentity::root, |parent_agent_id| {
- super::scope::MemoryIdentity::agent(&parent_agent_id)
- })
- });
+ let identity =
+ crate::agent::tinyagents::host::run_context::memory_identity_for_tool(context)
+ .unwrap_or_else(|| {
+ crate::agent::tinyagents::host::run_context::parent_agent_id_for_tool(context)
+ .map_or_else(super::scope::MemoryIdentity::root, |parent_agent_id| {
+ super::scope::MemoryIdentity::agent(&parent_agent_id)
+ })
+ });
Self {
workspace: Some(workspace.display().to_string()),
thread_id: context
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index d5d7927729..83fddae041 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -749,6 +749,9 @@ fn gather_acts_as_the_identity_the_run_carries() {
// A run that carries none, and direct dispatch, act as the root.
let bare = CallFacts::gather(&config, None);
- assert_eq!(bare.agent_id.as_deref(), Some(super::super::scope::DEFAULT_AGENT_ID));
+ assert_eq!(
+ bare.agent_id.as_deref(),
+ Some(super::super::scope::DEFAULT_AGENT_ID)
+ );
assert!(bare.reach.at.is_root());
}