Skip to content

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

chore: files changed src/openhuman/agent/message_convert.rs,src/openhuman/agent/messages.rs,src/open

Steven Enamakel5848c2c47d43
diff --git a/src/openhuman/agent/message_convert.rs b/src/openhuman/agent/message_convert.rs
index b742c6543f..447996929b 100644
--- a/src/openhuman/agent/message_convert.rs
+++ b/src/openhuman/agent/message_convert.rs
@@ -59,7 +59,6 @@ fn reasoning_extra_metadata(content: &[ContentBlock]) -> Option<serde_json::Valu
.map(|reasoning| serde_json::json!({ REASONING_EXT_KEY: reasoning }))
}
-
/// Split `text` at `breakpoints`, interleaving a
/// [`ContentBlock::CacheBreakpoint`] marker after each piece.
///
diff --git a/src/openhuman/agent/messages.rs b/src/openhuman/agent/messages.rs
index b0b7c6fec6..be0e4e07c3 100644
--- a/src/openhuman/agent/messages.rs
+++ b/src/openhuman/agent/messages.rs
@@ -52,9 +52,8 @@ impl ChatMessage {
let breakpoints: Vec<usize> = breakpoints
.into_iter()
.filter(|&offset| {
- let ok = offset > previous
- && offset < content.len()
- && content.is_char_boundary(offset);
+ let ok =
+ offset > previous && offset < content.len() && content.is_char_boundary(offset);
if ok {
previous = offset;
} else {
diff --git a/src/openhuman/agent/prompts/builder.rs b/src/openhuman/agent/prompts/builder.rs
index 68dab202d8..40d9a6b8b2 100644
--- a/src/openhuman/agent/prompts/builder.rs
+++ b/src/openhuman/agent/prompts/builder.rs
@@ -319,7 +319,11 @@ impl SystemPromptBuilder {
let mut output = String::new();
let mut breakpoints: Vec<usize> = Vec::new();
- for tier in [PromptTier::Stable, PromptTier::Context, PromptTier::Volatile] {
+ for tier in [
+ PromptTier::Stable,
+ PromptTier::Context,
+ PromptTier::Volatile,
+ ] {
for section in self.sections.iter().filter(|s| s.tier() == tier) {
let part = section.build(ctx)?;
if part.trim().is_empty() {
diff --git a/src/openhuman/agent/prompts/mod_tests.rs b/src/openhuman/agent/prompts/mod_tests.rs
index 7a5fa29092..8443f3f278 100644
--- a/src/openhuman/agent/prompts/mod_tests.rs
+++ b/src/openhuman/agent/prompts/mod_tests.rs
@@ -2295,7 +2295,11 @@ mod cache_tiers {
.build_tiered(&ctx)
.expect("builds");
- assert_eq!(tiered.breakpoints.len(), 2, "stable and context each end once");
+ assert_eq!(
+ tiered.breakpoints.len(),
+ 2,
+ "stable and context each end once"
+ );
for &offset in &tiered.breakpoints {
assert!(
tiered.text.is_char_boundary(offset),
diff --git a/src/openhuman/agent/prompts/sections.rs b/src/openhuman/agent/prompts/sections.rs
index 16daad9c08..e61d9f1acd 100644
--- a/src/openhuman/agent/prompts/sections.rs
+++ b/src/openhuman/agent/prompts/sections.rs
@@ -219,7 +219,6 @@ impl PromptSection for IdentitySection {
"identity"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut prompt = String::from("## Project Context\n\n");
prompt.push_str(
@@ -347,7 +346,6 @@ impl PromptSection for AgentsInstructionsSection {
"agents_md"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let mut out = String::new();
super::render_helpers::write_agents_md_blocks(
@@ -364,7 +362,6 @@ impl PromptSection for ToolsSection {
"tools"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// Native function-calling: the provider already sends full JSON
// schemas in the API request — no need to repeat the tool catalogue
@@ -539,7 +536,6 @@ impl PromptSection for RuntimeSection {
"runtime"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let host =
hostname::get().map_or_else(|_| "unknown".into(), |h| h.to_string_lossy().to_string());
@@ -561,7 +557,6 @@ impl PromptSection for UserReflectionsSection {
"user_reflections"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
if ctx.learned.reflections.is_empty() {
return Ok(String::new());
@@ -600,7 +595,6 @@ impl PromptSection for UserMemorySection {
"user_memory"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
if ctx.learned.tree_root_summaries.is_empty() {
return Ok(String::new());
@@ -657,7 +651,6 @@ impl PromptSection for DateTimeSection {
"datetime"
}
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
// No concrete timestamp here. The live "now" is injected per turn
// on the user message via `render_helpers::current_datetime_line`
@@ -711,8 +704,6 @@ impl PromptSection for UserIdentitySection {
"user_identity"
}
-
-
fn build(&self, ctx: &PromptContext<'_>) -> Result<String> {
let identity = match ctx.user_identity.as_ref() {
Some(id) if !id.is_empty() => id,
diff --git a/src/openhuman/agent/registry/agents/orchestrator/prompt.rs b/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
index 406008ee62..92b30663de 100644
--- a/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
+++ b/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
@@ -158,7 +158,11 @@ fn render_installed_skills(skills: &[Workflow]) -> String {
};
let _ = writeln!(out, "- **{id}**: {desc}");
}
- if let Some(hidden) = skills.len().checked_sub(MAX_LISTED_SKILLS).filter(|n| *n > 0) {
+ if let Some(hidden) = skills
+ .len()
+ .checked_sub(MAX_LISTED_SKILLS)
+ .filter(|n| *n > 0)
+ {
// The catalogue is a per-turn cost that grows with how many skills the
// user has installed, and it is frozen for the session (see
// `refresh_workflows` — the KV-cache prefix cannot be rewritten
@@ -463,10 +467,7 @@ mod tests {
rendered.contains("7 more installed skill(s)"),
"the reader must be told how many are missing: {rendered}"
);
- assert!(
- rendered.contains("skill_search"),
- "and how to reach them"
- );
+ assert!(rendered.contains("skill_search"), "and how to reach them");
}
#[test]
diff --git a/src/openhuman/agent/tools/todo.rs b/src/openhuman/agent/tools/todo.rs
index aa7bb621cc..d88cb3f8e4 100644
--- a/src/openhuman/agent/tools/todo.rs
+++ b/src/openhuman/agent/tools/todo.rs
@@ -154,9 +154,9 @@ impl Tool for TodoTool {
"list" => ops::list(&location).await,
other => {
return Ok(ToolResult::error(format!(
- "unknown op '{other}' (expected \
+ "unknown op '{other}' (expected \
add|edit|update_status|decide_plan|remove|replace|clear|list)"
- )))
+ )))
}
};
diff --git a/src/openhuman/config/workspace/ops.rs b/src/openhuman/config/workspace/ops.rs
index a45a8c40bd..f59636f728 100644
--- a/src/openhuman/config/workspace/ops.rs
+++ b/src/openhuman/config/workspace/ops.rs
@@ -102,7 +102,6 @@ pub async fn init_workspace(force: bool) -> Result<serde_json::Value, String> {
init_workflows_dir(&workspace_dir)
.map_err(|e| format!("failed to initialize skills dir: {e}"))?;
-
// Report what the call actually did, not what it was expected to do.
//
// These two were previously classified from the pre-check alone, which
diff --git a/src/openhuman/cron/tools/add.rs b/src/openhuman/cron/tools/add.rs
index a66178445a..14b41272c9 100644
--- a/src/openhuman/cron/tools/add.rs
+++ b/src/openhuman/cron/tools/add.rs
@@ -1,7 +1,9 @@
use crate::openhuman::config::Config;
use crate::openhuman::cron::{self, DeliveryConfig, JobType, Schedule, SessionTarget};
use crate::openhuman::security::SecurityPolicy;
-use crate::openhuman::tools::traits::{PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult};
+use crate::openhuman::tools::traits::{
+ PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult,
+};
use async_trait::async_trait;
use serde_json::json;
use std::sync::Arc;
diff --git a/src/openhuman/cron/tools/collapsed.rs b/src/openhuman/cron/tools/collapsed.rs
index ea0a04d471..87006a9ddf 100644
--- a/src/openhuman/cron/tools/collapsed.rs
+++ b/src/openhuman/cron/tools/collapsed.rs
@@ -76,12 +76,30 @@ impl CronTool {
/// of a self-referential field.
fn actions(&self) -> Vec<CollapsedAction<'_>> {
vec![
- CollapsedAction { action: "list", tool: &self.list },
- CollapsedAction { action: "add", tool: &self.add },
- CollapsedAction { action: "update", tool: &self.update },
- CollapsedAction { action: "remove", tool: &self.remove },
- CollapsedAction { action: "run", tool: &self.run },
- CollapsedAction { action: "runs", tool: &self.runs },
+ CollapsedAction {
+ action: "list",
+ tool: &self.list,
+ },
+ CollapsedAction {
+ action: "add",
+ tool: &self.add,
+ },
+ CollapsedAction {
+ action: "update",
+ tool: &self.update,
+ },
+ CollapsedAction {
+ action: "remove",
+ tool: &self.remove,
+ },
+ CollapsedAction {
+ action: "run",
+ tool: &self.run,
+ },
+ CollapsedAction {
+ action: "runs",
+ tool: &self.runs,
+ },
]
}
}
diff --git a/src/openhuman/cron/tools/run.rs b/src/openhuman/cron/tools/run.rs
index a42f2ee56c..075d566174 100644
--- a/src/openhuman/cron/tools/run.rs
+++ b/src/openhuman/cron/tools/run.rs
@@ -1,6 +1,8 @@
use crate::openhuman::config::Config;
use crate::openhuman::cron;
-use crate::openhuman::tools::traits::{PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult};
+use crate::openhuman::tools::traits::{
+ PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult,
+};
use async_trait::async_trait;
use chrono::Utc;
use serde_json::json;
diff --git a/src/openhuman/cron/tools/update.rs b/src/openhuman/cron/tools/update.rs
index e3710a1f5b..fcd2c5bf1a 100644
--- a/src/openhuman/cron/tools/update.rs
+++ b/src/openhuman/cron/tools/update.rs
@@ -1,7 +1,9 @@
use crate::openhuman::config::Config;
use crate::openhuman::cron::{self, CronJobPatch};
use crate::openhuman::security::SecurityPolicy;
-use crate::openhuman::tools::traits::{PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult};
+use crate::openhuman::tools::traits::{
+ PermissionLevel, Tool, ToolCallOptions, ToolExposure, ToolResult,
+};
use async_trait::async_trait;
use serde_json::json;
use std::sync::Arc;
diff --git a/src/openhuman/flows/mod.rs b/src/openhuman/flows/mod.rs
index d54b14a700..25f3325fdf 100644
--- a/src/openhuman/flows/mod.rs
+++ b/src/openhuman/flows/mod.rs
@@ -37,14 +37,14 @@ mod draft_store;
pub mod medulla_bridge;
pub mod memory_tools;
mod n8n_import;
-/// Skills this domain ships inside the binary. Needs BOTH gates: the pages
-/// teach flows authoring, and `BundledSkill` is part of the skills subsystem.
-#[cfg(feature = "skills")]
-pub mod skills;
pub mod node_contracts;
pub mod ops;
mod run_registry;
mod schemas;
+/// Skills this domain ships inside the binary. Needs BOTH gates: the pages
+/// teach flows authoring, and `BundledSkill` is part of the skills subsystem.
+#[cfg(feature = "skills")]
+pub mod skills;
mod store;
/// The tinyflows engine seam (formerly `openhuman::tinyflows`).
pub mod tinyflows;
@@ -66,8 +66,7 @@ pub use schemas::{
// the `flow_runs` row through this function as the run executes.
pub use node_contracts::{
all_node_kind_contracts, node_kind_contract, render_node_kinds_line,
- render_node_kinds_required, ConfigField,
- NodeKindContract, PortSpec, NODE_KINDS,
+ render_node_kinds_required, ConfigField, NodeKindContract, PortSpec, NODE_KINDS,
};
pub use store::{kv_get, kv_set, upsert_flow_run_step};
pub use types::{
diff --git a/src/openhuman/flows/tools.rs b/src/openhuman/flows/tools.rs
index 237424cfdb..e52f51455c 100644
--- a/src/openhuman/flows/tools.rs
+++ b/src/openhuman/flows/tools.rs
@@ -68,9 +68,10 @@ impl Tool for ProposeWorkflowTool {
// it now passes by construction, and stays as the regression guard for
// anyone tempted to hand-write this again.
static DESCRIPTION: std::sync::OnceLock<String> = std::sync::OnceLock::new();
- DESCRIPTION.get_or_init(|| {
- format!(
- "Propose a candidate automation workflow for the user to review and save. \
+ DESCRIPTION
+ .get_or_init(|| {
+ format!(
+ "Propose a candidate automation workflow for the user to review and save. \
This tool ONLY VALIDATES the graph and returns a summary — it NEVER creates \
or enables the flow; the user must click \"Save & enable\" in the UI before \
anything is persisted or can run. If validation fails, fix the graph and call \
@@ -92,10 +93,10 @@ impl Tool for ProposeWorkflowTool {
Call `get_node_kind_contract {{ kind }}` for a kind's optional fields, ports, \
a worked example, and its gotchas — it is generated from the catalog the \
validator enforces, so it is always current.",
- kinds = crate::openhuman::flows::render_node_kinds_required()
- )
- })
- .as_str()
+ kinds = crate::openhuman::flows::render_node_kinds_required()
+ )
+ })
+ .as_str()
}
fn parameters_schema(&self) -> Value {
diff --git a/src/openhuman/memory/tools/collapsed.rs b/src/openhuman/memory/tools/collapsed.rs
index b7f0989418..83cd00debc 100644
--- a/src/openhuman/memory/tools/collapsed.rs
+++ b/src/openhuman/memory/tools/collapsed.rs
@@ -109,9 +109,9 @@ impl MemoryTool {
self.all_actions()
.into_iter()
.filter(|entry| {
- crate::core::all::capability_allowed(
- crate::openhuman::tools::ops::tool_capability(entry.tool.name()),
- )
+ crate::core::all::capability_allowed(crate::openhuman::tools::ops::tool_capability(
+ entry.tool.name(),
+ ))
})
.collect()
}
@@ -119,17 +119,50 @@ impl MemoryTool {
/// Every action this tool can serve, before capability filtering.
fn all_actions(&self) -> Vec<CollapsedAction<'_>> {
vec![
- CollapsedAction { action: "recall", tool: &self.recall },
- CollapsedAction { action: "store", tool: &self.store },
- CollapsedAction { action: "forget", tool: &self.forget },
- CollapsedAction { action: "hybrid_search", tool: &self.hybrid_search },
- CollapsedAction { action: "vector_search", tool: &self.vector_search },
- CollapsedAction { action: "chunk_context", tool: &self.chunk_context },
- CollapsedAction { action: "raw_search", tool: &self.raw_search },
- CollapsedAction { action: "raw_chunks", tool: &self.raw_chunks },
- CollapsedAction { action: "kinds", tool: &self.kinds },
- CollapsedAction { action: "flavour", tool: &self.flavour },
- CollapsedAction { action: "doctor", tool: &self.doctor },
+ CollapsedAction {
+ action: "recall",
+ tool: &self.recall,
+ },
+ CollapsedAction {
+ action: "store",
+ tool: &self.store,
+ },
+ CollapsedAction {
+ action: "forget",
+ tool: &self.forget,
+ },
+ CollapsedAction {
+ action: "hybrid_search",
+ tool: &self.hybrid_search,
+ },
+ CollapsedAction {
+ action: "vector_search",
+ tool: &self.vector_search,
+ },
+ CollapsedAction {
+ action: "chunk_context",
+ tool: &self.chunk_context,
+ },
+ CollapsedAction {
+ action: "raw_search",
+ tool: &self.raw_search,
+ },
+ CollapsedAction {
+ action: "raw_chunks",
+ tool: &self.raw_chunks,
+ },
+ CollapsedAction {
+ action: "kinds",
+ tool: &self.kinds,
+ },
+ CollapsedAction {
+ action: "flavour",
+ tool: &self.flavour,
+ },
+ CollapsedAction {
+ action: "doctor",
+ tool: &self.doctor,
+ },
]
}
}
@@ -308,7 +341,10 @@ mod tests {
// Pinning the decision in the module docs: `memory_tree` dispatches on
// its own `mode`, and folding it in would make this two-level.
assert!(
- !tool().all_actions().iter().any(|e| e.tool.name() == "memory_tree"),
+ !tool()
+ .all_actions()
+ .iter()
+ .any(|e| e.tool.name() == "memory_tree"),
"memory_tree stays a separate tool"
);
}
diff --git a/src/openhuman/skills/bundled/mod.rs b/src/openhuman/skills/bundled/mod.rs
index 9d7ecbe12d..8a88a81943 100644
--- a/src/openhuman/skills/bundled/mod.rs
+++ b/src/openhuman/skills/bundled/mod.rs
@@ -89,15 +89,17 @@ impl BundledSkill {
|| self.dir_name.contains('/')
|| self.dir_name.contains('\\')
{
- return Err(format!("invalid bundled skill dir_name `{}`", self.dir_name));
+ return Err(format!(
+ "invalid bundled skill dir_name `{}`",
+ self.dir_name
+ ));
}
if self.files.is_empty() {
return Err(format!("bundled skill `{}` has no files", self.dir_name));
}
- let has_manifest = self
- .files
- .iter()
- .any(|f| f.path == super::ops_types::WORKFLOW_MD || f.path == super::ops_types::SKILL_MD);
+ let has_manifest = self.files.iter().any(|f| {
+ f.path == super::ops_types::WORKFLOW_MD || f.path == super::ops_types::SKILL_MD
+ });
if !has_manifest {
return Err(format!(
"bundled skill `{}` has no WORKFLOW.md or SKILL.md; discovery would skip it",
diff --git a/src/openhuman/skills/bundled/mod_tests.rs b/src/openhuman/skills/bundled/mod_tests.rs
index 11d40cfbb1..9c495a673f 100644
--- a/src/openhuman/skills/bundled/mod_tests.rs
+++ b/src/openhuman/skills/bundled/mod_tests.rs
@@ -50,13 +50,25 @@ fn the_digest_covers_paths_as_well_as_contents() {
let moved = BundledSkill {
dir_name: "sample",
files: &[
- BundledFile { path: "WORKFLOW.md", contents: A.contents },
- BundledFile { path: "references/detail.md", contents: "detai" },
+ BundledFile {
+ path: "WORKFLOW.md",
+ contents: A.contents,
+ },
+ BundledFile {
+ path: "references/detail.md",
+ contents: "detai",
+ },
],
};
let renamed = BundledSkill {
dir_name: "sample",
- files: &[A, BundledFile { path: "references/other.md", contents: B.contents }],
+ files: &[
+ A,
+ BundledFile {
+ path: "references/other.md",
+ contents: B.contents,
+ },
+ ],
};
assert_ne!(SAMPLE.digest(), moved.digest());
assert_ne!(SAMPLE.digest(), renamed.digest());
@@ -93,8 +105,14 @@ fn a_traversal_path_is_rejected() {
#[test]
fn a_bad_dir_name_is_rejected() {
for bad in ["", ".hidden", "a/b", "a\\b"] {
- let skill = BundledSkill { dir_name: bad, files: &[A] };
- assert!(skill.validate().is_err(), "`{bad}` must be rejected as a dir_name");
+ let skill = BundledSkill {
+ dir_name: bad,
+ files: &[A],
+ };
+ assert!(
+ skill.validate().is_err(),
+ "`{bad}` must be rejected as a dir_name"
+ );
}
}
@@ -105,7 +123,10 @@ fn a_bundle_with_no_manifest_is_rejected() {
// never appear — the worst failure mode available, because nothing errors.
let skill = BundledSkill {
dir_name: "sample",
- files: &[BundledFile { path: "references/detail.md", contents: "x" }],
+ files: &[BundledFile {
+ path: "references/detail.md",
+ contents: "x",
+ }],
};
assert!(skill.validate().is_err());
}
@@ -135,7 +156,10 @@ fn a_version_bump_removes_a_file_the_new_version_dropped() {
let root = builtin_root(tmp.path());
assert!(install_one(&root, &SAMPLE).expect("install v1"));
- let v2 = BundledSkill { dir_name: "sample", files: &[A] };
+ let v2 = BundledSkill {
+ dir_name: "sample",
+ files: &[A],
+ };
assert!(install_one(&root, &v2).expect("install v2"));
assert!(
!root.join("sample").join("references/detail.md").exists(),
@@ -164,7 +188,10 @@ fn install_reports_rather_than_fails_the_boot() {
// must not stop the core from starting.
let tmp = tempfile::tempdir().expect("tempdir");
let report = install(tmp.path());
- assert!(report.failed.is_empty(), "clean workspace must install: {report:?}");
+ assert!(
+ report.failed.is_empty(),
+ "clean workspace must install: {report:?}"
+ );
assert_eq!(
report.written.len() + report.unchanged.len(),
BUNDLED.len(),
@@ -222,7 +249,10 @@ fn a_materialised_bundle_is_discoverable_and_readable_end_to_end() {
std::path::Path::new(file.path),
)
.unwrap_or_else(|e| {
- panic!("reading `{}` of `{}` failed: {e}", file.path, skill.dir_name)
+ panic!(
+ "reading `{}` of `{}` failed: {e}",
+ file.path, skill.dir_name
+ )
});
assert_eq!(
body, file.contents,
diff --git a/src/openhuman/skills/mod.rs b/src/openhuman/skills/mod.rs
index 2d1c16bf6d..b0d07cf011 100644
--- a/src/openhuman/skills/mod.rs
+++ b/src/openhuman/skills/mod.rs
@@ -68,10 +68,10 @@ pub mod registry;
#[cfg(feature = "skills")]
pub mod run_log;
#[cfg(feature = "skills")]
-pub mod search;
-#[cfg(feature = "skills")]
pub mod schemas;
#[cfg(feature = "skills")]
+pub mod search;
+#[cfg(feature = "skills")]
pub mod tools;
#[cfg(all(test, feature = "skills"))]
diff --git a/src/openhuman/skills/search.rs b/src/openhuman/skills/search.rs
index 6ed098b14e..30029a79a4 100644
--- a/src/openhuman/skills/search.rs
+++ b/src/openhuman/skills/search.rs
@@ -213,7 +213,10 @@ impl Tool for SkillSearchTool {
}
async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {
- let query = args.get("query").and_then(Value::as_str).unwrap_or_default();
+ let query = args
+ .get("query")
+ .and_then(Value::as_str)
+ .unwrap_or_default();
if query.trim().is_empty() {
return Ok(ToolResult::error(
"skill_search needs a `query` describing what you want done.".to_string(),
diff --git a/src/openhuman/skills/search_tests.rs b/src/openhuman/skills/search_tests.rs
index 37edaf9860..ed376fe4b0 100644
--- a/src/openhuman/skills/search_tests.rs
+++ b/src/openhuman/skills/search_tests.rs
@@ -76,7 +76,11 @@ fn nothing_relevant_returns_nothing() {
fn the_limit_caps_the_result_set() {
let all = corpus();
let query = "changelog ascii tinyflows";
- assert_eq!(rank(&all, query, 10).len(), 3, "all three must match unlimited");
+ assert_eq!(
+ rank(&all, query, 10).len(),
+ 3,
+ "all three must match unlimited"
+ );
assert_eq!(rank(&all, query, 1).len(), 1);
}
diff --git a/src/openhuman/tools/impl/meta/collapse.rs b/src/openhuman/tools/impl/meta/collapse.rs
index e1f87f7946..7bb1d5d128 100644
--- a/src/openhuman/tools/impl/meta/collapse.rs
+++ b/src/openhuman/tools/impl/meta/collapse.rs
@@ -72,11 +72,10 @@ pub fn merge_action_schemas(actions: &[CollapsedAction<'_>]) -> Value {
continue;
};
for (name, spec) in props {
- owners
+ owners.entry(name.clone()).or_default().push(entry.action);
+ properties
.entry(name.clone())
- .or_default()
- .push(entry.action);
- properties.entry(name.clone()).or_insert_with(|| spec.clone());
+ .or_insert_with(|| spec.clone());
}
}
@@ -241,7 +240,12 @@ mod tests {
}
}
- fn stub(name: &'static str, schema: Value, permission: PermissionLevel, external: bool) -> Stub {
+ fn stub(
+ name: &'static str,
+ schema: Value,
+ permission: PermissionLevel,
+ external: bool,
+ ) -> Stub {
Stub {
name,
schema,
@@ -252,7 +256,12 @@ mod tests {
#[test]
fn the_union_carries_every_members_properties() {
- let list = stub("list", json!({"type": "object", "properties": {}}), PermissionLevel::ReadOnly, false);
+ let list = stub(
+ "list",
+ json!({"type": "object", "properties": {}}),
+ PermissionLevel::ReadOnly,
+ false,
+ );
let runs = stub(
"runs",
json!({"type": "object", "properties": {
@@ -263,8 +272,14 @@ mod tests {
false,
);
let actions = vec![
- CollapsedAction { action: "list", tool: &list },
- CollapsedAction { action: "runs", tool: &runs },
+ CollapsedAction {
+ action: "list",
+ tool: &list,
+ },
+ CollapsedAction {
+ action: "runs",
+ tool: &runs,
+ },
];
let merged = merge_action_schemas(&actions);
let props = merged["properties"].as_object().expect("properties");
@@ -278,7 +293,12 @@ mod tests {
fn only_action_is_required_because_a_union_cannot_say_otherwise() {
// `job_id` is required for `runs` and meaningless for `list`. Marking
// it required here would make every `list` call invalid.
- let list = stub("list", json!({"type": "object", "properties": {}}), PermissionLevel::ReadOnly, false);
+ let list = stub(
+ "list",
+ json!({"type": "object", "properties": {}}),
+ PermissionLevel::ReadOnly,
+ false,
+ );
let runs = stub(
"runs",
json!({"type": "object", "properties": {"job_id": {"type": "string"}}, "required": ["job_id"]}),
@@ -286,15 +306,29 @@ mod tests {
false,
);
let actions = vec![
- CollapsedAction { action: "list", tool: &list },
- CollapsedAction { action: "runs", tool: &runs },
+ CollapsedAction {
+ action: "list",
+ tool: &list,
+ },
+ CollapsedAction {
+ action: "runs",
+ tool: &runs,
+ },
];
- assert_eq!(merge_action_schemas(&actions)["required"], json!(["action"]));
+ assert_eq!(
+ merge_action_schemas(&actions)["required"],
+ json!(["action"])
+ );
}
#[test]
fn a_property_only_some_actions_take_is_labelled_with_them() {
- let a = stub("a", json!({"type": "object", "properties": {"shared": {"type": "string"}}}), PermissionLevel::ReadOnly, false);
+ let a = stub(
+ "a",
+ json!({"type": "object", "properties": {"shared": {"type": "string"}}}),
+ PermissionLevel::ReadOnly,
+ false,
+ );
let b = stub(
"b",
json!({"type": "object", "properties": {
@@ -305,8 +339,14 @@ mod tests {
false,
);
let actions = vec![
- CollapsedAction { action: "a", tool: &a },
- CollapsedAction { action: "b", tool: &b },
+ CollapsedAction {
+ action: "a",
+ tool: &a,
+ },
+ CollapsedAction {
+ action: "b",
+ tool: &b,
+ },
];
let merged = merge_action_schemas(&actions);
let props = &merged["properties"];
@@ -321,9 +361,18 @@ mod tests {
let execute = stub("x", json!({}), PermissionLevel::Execute, false);
let write = stub("w", json!({}), PermissionLevel::Write, false);
let actions = vec![
- CollapsedAction { action: "r", tool: &read },
- CollapsedAction { action: "x", tool: &execute },
- CollapsedAction { action: "w", tool: &write },
+ CollapsedAction {
+ action: "r",
+ tool: &read,
+ },
+ CollapsedAction {
+ action: "x",
+ tool: &execute,
+ },
+ CollapsedAction {
+ action: "w",
+ tool: &write,
+ },
];
assert_eq!(strictest_permission(&actions), PermissionLevel::Execute);
}
@@ -332,10 +381,19 @@ mod tests {
fn external_effect_is_true_when_any_member_has_one() {
let clean = stub("c", json!({}), PermissionLevel::ReadOnly, false);
let dirty = stub("d", json!({}), PermissionLevel::ReadOnly, true);
- assert!(!any_external_effect(&[CollapsedAction { action: "c", tool: &clean }]));
+ assert!(!any_external_effect(&[CollapsedAction {
+ action: "c",
+ tool: &clean
+ }]));
assert!(any_external_effect(&[
- CollapsedAction { action: "c", tool: &clean },
- CollapsedAction { action: "d", tool: &dirty },
+ CollapsedAction {
+ action: "c",
+ tool: &clean
+ },
+ CollapsedAction {
+ action: "d",
+ tool: &dirty
+ },
]));
}
@@ -349,7 +407,10 @@ mod tests {
#[test]
fn an_unknown_action_names_the_valid_ones() {
let a = stub("a", json!({}), PermissionLevel::ReadOnly, false);
- let actions = vec![CollapsedAction { action: "add", tool: &a }];
+ let actions = vec![CollapsedAction {
+ action: "add",
+ tool: &a,
+ }];
assert_eq!(
unknown_action_message(&actions, Some("addd")),
"unknown action 'addd' (expected add)"
diff --git a/src/openhuman/tools/impl/meta/mod.rs b/src/openhuman/tools/impl/meta/mod.rs
index b178a93cd2..282404f620 100644
--- a/src/openhuman/tools/impl/meta/mod.rs
+++ b/src/openhuman/tools/impl/meta/mod.rs
@@ -9,11 +9,10 @@ pub mod collapse;
pub mod tool_search;
pub use collapse::{
- any_external_effect, args_without_action, merge_action_schemas, resolve,
- strictest_permission, unknown_action_message, CollapsedAction,
+ any_external_effect, args_without_action, merge_action_schemas, resolve, strictest_permission,
+ unknown_action_message, CollapsedAction,
};
pub use tool_search::{
bind_tool_search_index, strip_deferred_from_visible, ToolSearchHandle, ToolSearchIndex,
- ToolSearchTool,
- TOOL_SEARCH_NAME,
+ ToolSearchTool, TOOL_SEARCH_NAME,
};
diff --git a/src/openhuman/tools/impl/meta/tool_search.rs b/src/openhuman/tools/impl/meta/tool_search.rs
index f8a64f8c79..86e020b07f 100644
--- a/src/openhuman/tools/impl/meta/tool_search.rs
+++ b/src/openhuman/tools/impl/meta/tool_search.rs
@@ -264,13 +264,17 @@ mod tests {
ToolSearchIndex::build(&[
spec("stock_quote", "Get the latest price for a stock ticker"),
spec("cron_add", "Schedule a recurring job to run later"),
- spec("memory_hybrid_search", "Search stored memories semantically"),
- spec("generate_presentation", "Build a pptx slide deck from an outline"),
+ spec(
+ "memory_hybrid_search",
+ "Search stored memories semantically",
+ ),
+ spec(
+ "generate_presentation",
+ "Build a pptx slide deck from an outline",
+ ),
])
}
-
-
#[test]
fn a_plain_language_query_finds_the_right_tool() {
let index = index();
@@ -318,8 +322,16 @@ mod tests {
#[test]
fn ranking_is_stable_across_identical_queries() {
let index = index();
- let first: Vec<&str> = index.search("search", 4).iter().map(|t| t.name.as_str()).collect();
- let second: Vec<&str> = index.search("search", 4).iter().map(|t| t.name.as_str()).collect();
+ let first: Vec<&str> = index
+ .search("search", 4)
+ .iter()
+ .map(|t| t.name.as_str())
+ .collect();
+ let second: Vec<&str> = index
+ .search("search", 4)
+ .iter()
+ .map(|t| t.name.as_str())
+ .collect();
assert_eq!(first, second);
}
}
diff --git a/src/openhuman/tools/ops.rs b/src/openhuman/tools/ops.rs
index 6810cb4bbc..034aed2d75 100644
--- a/src/openhuman/tools/ops.rs
+++ b/src/openhuman/tools/ops.rs
@@ -1538,11 +1538,9 @@ pub(crate) fn tool_capability(name: &str) -> Option<tinymemory_api::capabilities
// are: it must stay registered whenever the mandatory family is, and
// it filters its own action list by capability so an unavailable
// action is never advertised. See `memory::tools::collapsed`.
- "memory"
- | "memory_store"
- | "memory_forget"
- | "remember_preference"
- | "save_preference" => Capability::Core,
+ "memory" | "memory_store" | "memory_forget" | "remember_preference" | "save_preference" => {
+ Capability::Core
+ }
// Chunk/recall retrieval surface. NOT `Tree` — these read chunk
// embeddings and chunk rows, never the summary tree.
"memory_recall"
diff --git a/src/openhuman/util/bm25.rs b/src/openhuman/util/bm25.rs
index 89aa25acce..fa7a78e949 100644
--- a/src/openhuman/util/bm25.rs
+++ b/src/openhuman/util/bm25.rs
@@ -165,7 +165,11 @@ impl Bm25Index {
scored.sort_by(|a, b| {
b.0.partial_cmp(&a.0)
.unwrap_or(std::cmp::Ordering::Equal)
- .then_with(|| self.documents[a.1].sort_key.cmp(&self.documents[b.1].sort_key))
+ .then_with(|| {
+ self.documents[a.1]
+ .sort_key
+ .cmp(&self.documents[b.1].sort_key)
+ })
});
scored.into_iter().take(limit).map(|(_, i)| i).collect()
}
@@ -240,8 +244,14 @@ mod tests {
#[test]
fn snake_case_and_camel_case_both_split() {
- assert_eq!(tokenize("memory_hybrid_search"), ["memory", "hybrid", "search"]);
- assert_eq!(tokenize("readWorkflowResource"), ["read", "workflow", "resource"]);
+ assert_eq!(
+ tokenize("memory_hybrid_search"),
+ ["memory", "hybrid", "search"]
+ );
+ assert_eq!(
+ tokenize("readWorkflowResource"),
+ ["read", "workflow", "resource"]
+ );
assert_eq!(tokenize("HTTPServer2"), ["httpserver2"]);
}
@@ -274,9 +284,13 @@ mod tests {
// the most distinguishing term in the query — the df threshold cannot
// catch it, and the first fix that only had the threshold still ranked
// a changelog skill as the match for provisioning a cluster.
- assert!(corpus().search("provision a kubernetes cluster", 3).is_empty());
+ assert!(corpus()
+ .search("provision a kubernetes cluster", 3)
+ .is_empty());
assert!(corpus().search("a", 3).is_empty());
- assert!(corpus().search("what is it that you will do for me", 3).is_empty());
+ assert!(corpus()
+ .search("what is it that you will do for me", 3)
+ .is_empty());
}
#[test]