Skip to content

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

chore(flows): apply rustfmt formatting and drop unused decode helper

Steven Enamakelef0398ae64aa
diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rs
index bd3877b896..78b37c93f6 100644
--- a/crates/openhuman-core/src/flows/builder_host.rs
+++ b/crates/openhuman-core/src/flows/builder_host.rs
@@ -256,10 +256,6 @@ fn optional_field<T: DeserializeOwned>(value: &Value, key: &str) -> Result<Optio
}
}
-fn decode<T: DeserializeOwned>(value: Value) -> Result<T, String> {
- serde_json::from_value(value).map_err(|error| error.to_string())
-}
-
fn bus_error(member: &str, error: impl std::fmt::Display) -> tinybus::Error {
tracing::debug!(callback = member, %error, "[flows:copilot] host callback failed");
tinybus::Error::failed(error)
diff --git a/crates/openhuman-core/src/flows/copilot_bus_tests.rs b/crates/openhuman-core/src/flows/copilot_bus_tests.rs
index 2086f04013..c6abd75b59 100644
--- a/crates/openhuman-core/src/flows/copilot_bus_tests.rs
+++ b/crates/openhuman-core/src/flows/copilot_bus_tests.rs
@@ -26,7 +26,9 @@ async fn model_arguments_cannot_replace_the_scoped_host_callback_address() {
config.workspace_dir = workspace.path().to_path_buf();
config.config_path = workspace.path().join("config.toml");
let catalog = CopilotToolCatalog::load(Arc::new(config)).expect("module tool catalog loads");
- let tool = catalog.tool("list_flows").expect("list_flows is catalogued");
+ let tool = catalog
+ .tool("list_flows")
+ .expect("list_flows is catalogued");
let result = tool
.execute(json!({
"host": {
@@ -102,7 +104,9 @@ async fn concurrent_tool_callbacks_keep_each_explicit_profile_scope() {
}
let catalog = CopilotToolCatalog::load(Arc::new(config)).expect("module tool catalog loads");
- let tool = catalog.tool("list_flows").expect("list_flows is catalogued");
+ let tool = catalog
+ .tool("list_flows")
+ .expect("list_flows is catalogued");
let alice_call = tool_context(alice, "copilot-alice");
let bob_call = tool_context(bob, "copilot-bob");
let alice_future = tool.execute_with_context(
diff --git a/crates/openhuman-core/src/flows/ops/discovery.rs b/crates/openhuman-core/src/flows/ops/discovery.rs
index efdc72392a..e26c956573 100644
--- a/crates/openhuman-core/src/flows/ops/discovery.rs
+++ b/crates/openhuman-core/src/flows/ops/discovery.rs
@@ -51,8 +51,8 @@ pub async fn flows_discover(
config: &Config,
stream: Option<FlowStreamTarget>,
) -> Result<Outcome<Vec<FlowSuggestion>>, String> {
- use crate::agent::turn_origin::{with_origin, AgentTurnOrigin};
use crate::agent::OpenHumanSessionHost;
+ use crate::agent::turn_origin::{AgentTurnOrigin, with_origin};
tracing::info!(
target: "flows",
diff --git a/crates/openhuman-core/src/flows/ops/drafts.rs b/crates/openhuman-core/src/flows/ops/drafts.rs
index d70a87a0b3..4a68d3ea66 100644
--- a/crates/openhuman-core/src/flows/ops/drafts.rs
+++ b/crates/openhuman-core/src/flows/ops/drafts.rs
@@ -25,8 +25,8 @@ pub(crate) fn flows_draft_create_from_copilot(
graph: Value,
origin: Value,
) -> Result<Value, String> {
- let origin = serde_json::from_value(origin)
- .map_err(|error| format!("bad `origin`: {error}"))?;
+ let origin =
+ serde_json::from_value(origin).map_err(|error| format!("bad `origin`: {error}"))?;
let draft = flows_draft_create(config, flow_id, name, graph, origin)?.value;
serde_json::to_value(draft).map_err(|error| error.to_string())
}
diff --git a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
index 7b3c664bc3..8ad1591bdd 100644
--- a/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_builder_repair_tests.rs
@@ -1,10 +1,10 @@
+use super::super::trail_off::{backend_repair_message, is_backend_or_infrastructure_failure};
use super::*;
use crate::core::runtime::DispatchCtx;
use crate::{
config::Config,
flows::ops::{FlowStreamTarget, flows_build_with_extra_hidden_tools},
};
-use super::super::trail_off::{backend_repair_message, is_backend_or_infrastructure_failure};
#[tokio::test]
async fn classifies_backend_failures_without_classifying_graph_timeouts() {
diff --git a/crates/openhuman-core/src/modules/tinyflows.rs b/crates/openhuman-core/src/modules/tinyflows.rs
index 7c29b508ab..f3658bbb61 100644
--- a/crates/openhuman-core/src/modules/tinyflows.rs
+++ b/crates/openhuman-core/src/modules/tinyflows.rs
@@ -42,9 +42,9 @@ pub(crate) fn disabled_message() -> String {
#[cfg(feature = "modules")]
mod imp {
- use super::{HOST_BUS_NAME, disabled_message};
#[cfg(not(test))]
use super::MODULE_ID;
+ use super::{HOST_BUS_NAME, disabled_message};
use crate::config::Config;
#[cfg(not(test))]
use crate::modules::ops;
@@ -239,9 +239,7 @@ mod imp {
Err(unavailable(config))
}
- pub(crate) async fn copilot_invoke_proxy(
- config: &Config,
- ) -> Result<tinybus::Proxy, String> {
+ pub(crate) async fn copilot_invoke_proxy(config: &Config) -> Result<tinybus::Proxy, String> {
Err(unavailable(config))
}
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index e3f8807196..103c34fe3d 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -19,17 +19,17 @@ use std::sync::{Arc, Mutex, OnceLock};
use std::time::Duration;
use axum::extract::State;
-use axum::http::{header::AUTHORIZATION, HeaderMap, StatusCode, Uri};
+use axum::http::{HeaderMap, StatusCode, Uri, header::AUTHORIZATION};
use axum::routing::{get, post};
use axum::{Json, Router};
use futures_util::StreamExt;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use sha2::{Digest, Sha256};
use tempfile::tempdir;
use tinyinference_llm::message::Message;
use tinyinference_llm::model::ModelRequest;
-use openhuman_core::core::auth::{init_rpc_token, CORE_TOKEN_ENV_VAR};
+use openhuman_core::core::auth::{CORE_TOKEN_ENV_VAR, init_rpc_token};
use openhuman_core::platform::connectivity::rpc::pick_listen_port;
use openhuman_rpc::server::build_core_http_router;
@@ -1539,10 +1539,12 @@ async fn json_rpc_tokenjuice_detect_and_cache_stats() {
)
.await;
let stats_result = assert_no_jsonrpc_error(&stats, "tokenjuice_cache_stats");
- assert!(stats_result
- .get("entries")
- .and_then(Value::as_u64)
- .is_some());
+ assert!(
+ stats_result
+ .get("entries")
+ .and_then(Value::as_u64)
+ .is_some()
+ );
assert!(stats_result.get("bytes").and_then(Value::as_u64).is_some());
rpc_join.abort();
@@ -1567,14 +1569,18 @@ async fn json_rpc_tokenjuice_settings_and_savings() {
let settings = get_result
.get("settings")
.expect("settings_get returns a settings object");
- assert!(settings
- .get("router_enabled")
- .and_then(Value::as_bool)
- .is_some());
- assert!(settings
- .get("ccr_min_tokens")
- .and_then(Value::as_u64)
- .is_some());
+ assert!(
+ settings
+ .get("router_enabled")
+ .and_then(Value::as_bool)
+ .is_some()
+ );
+ assert!(
+ settings
+ .get("ccr_min_tokens")
+ .and_then(Value::as_u64)
+ .is_some()
+ );
// settings_update: flip the CCR token threshold and confirm it round-trips.
let updated = post_json_rpc(
@@ -1603,11 +1609,13 @@ async fn json_rpc_tokenjuice_settings_and_savings() {
.await;
let savings_result = assert_no_jsonrpc_error(&savings, "tokenjuice_savings_stats");
assert!(savings_result.get("attributionModel").is_some());
- assert!(savings_result
- .get("total")
- .and_then(|t| t.get("tokensSaved"))
- .and_then(Value::as_u64)
- .is_some());
+ assert!(
+ savings_result
+ .get("total")
+ .and_then(|t| t.get("tokensSaved"))
+ .and_then(Value::as_u64)
+ .is_some()
+ );
assert!(savings_result.get("cache").is_some());
// savings_reset: zeroes the totals.
@@ -1817,24 +1825,32 @@ async fn json_rpc_agent_registry_manages_defaults_and_custom_agents() {
.iter()
.find(|definition| definition.get("id").and_then(Value::as_str) == Some("critic"))
.expect("safe agent library should include critic");
- assert!(memory_agent
- .get("display_name")
- .and_then(Value::as_str)
- .is_some());
- assert!(memory_agent
- .get("when_to_use")
- .and_then(Value::as_str)
- .is_some());
+ assert!(
+ memory_agent
+ .get("display_name")
+ .and_then(Value::as_str)
+ .is_some()
+ );
+ assert!(
+ memory_agent
+ .get("when_to_use")
+ .and_then(Value::as_str)
+ .is_some()
+ );
assert!(memory_agent.get("system_prompt").is_none());
assert!(memory_agent.get("tools").is_some());
- assert!(memory_agent
- .get("direct_tool_count")
- .and_then(Value::as_u64)
- .is_some());
- assert!(memory_agent
- .get("can_run_as_user_facing_worker")
- .and_then(Value::as_bool)
- .is_some());
+ assert!(
+ memory_agent
+ .get("direct_tool_count")
+ .and_then(Value::as_u64)
+ .is_some()
+ );
+ assert!(
+ memory_agent
+ .get("can_run_as_user_facing_worker")
+ .and_then(Value::as_bool)
+ .is_some()
+ );
let missing = post_json_rpc(
&rpc_base,
@@ -3335,10 +3351,12 @@ async fn json_rpc_thread_working_dir_binds_before_the_first_message() {
)
.await;
let cleared = assert_no_jsonrpc_error(&cleared, "threads_update_working_dir clear");
- assert!(cleared
- .get("data")
- .and_then(|d| d.get("actionDir"))
- .is_none());
+ assert!(
+ cleared
+ .get("data")
+ .and_then(|d| d.get("actionDir"))
+ .is_none()
+ );
// 3. A protected folder is refused.
let ssh = home.join(".ssh");
@@ -3553,8 +3571,7 @@ async fn json_rpc_thread_generate_title_falls_back_when_provider_path_is_unavail
assert_ne!(generated_title, original_title);
assert_eq!(
- generated_title,
- "summarize latest five",
+ generated_title, "summarize latest five",
"fallback title should be the 3-word shape derived from the first user message (filler stripped), got: {generated_title}"
);
@@ -3735,11 +3752,13 @@ async fn json_rpc_thread_turn_state_lifecycle() {
)
.await;
let missing_outer = assert_no_jsonrpc_error(&get_turn_missing, "turn_state_get_turn (absent)");
- assert!(missing_outer
- .get("data")
- .and_then(|d| d.get("turnState"))
- .map(|v| v.is_null())
- .unwrap_or(true));
+ assert!(
+ missing_outer
+ .get("data")
+ .and_then(|d| d.get("turnState"))
+ .map(|v| v.is_null())
+ .unwrap_or(true)
+ );
// clear → cleared:true
let cleared = post_json_rpc(
@@ -3767,11 +3786,13 @@ async fn json_rpc_thread_turn_state_lifecycle() {
)
.await;
let again_outer = assert_no_jsonrpc_error(&got_again, "turn_state_get (after clear)");
- assert!(again_outer
- .get("data")
- .and_then(|d| d.get("turnState"))
- .map(|v| v.is_null())
- .unwrap_or(true));
+ assert!(
+ again_outer
+ .get("data")
+ .and_then(|d| d.get("turnState"))
+ .map(|v| v.is_null())
+ .unwrap_or(true)
+ );
api_join.abort();
rpc_join.abort();
@@ -6474,7 +6495,9 @@ async fn json_rpc_wallet_solana_prepare_execute_round_trips() {
);
assert_eq!(
exec_result.get("transactionHash").and_then(Value::as_str),
- Some("5xS9pXmqVz8R1nuRZTfsdsAxBdBFmtnAtuYbCsmK5DYzGn5vR4VqWGmiR5McLnYx8oFqLdo62q4qiUZpQyR4Hkn3"),
+ Some(
+ "5xS9pXmqVz8R1nuRZTfsdsAxBdBFmtnAtuYbCsmK5DYzGn5vR4VqWGmiR5McLnYx8oFqLdo62q4qiUZpQyR4Hkn3"
+ ),
);
mock_join.abort();
@@ -7332,12 +7355,14 @@ async fn json_rpc_local_ai_ollama_endpoint_normalizes_bind_address_and_clears()
)
.await;
let clear_result = assert_no_jsonrpc_error(&clear, "clear ollama base_url");
- assert!(clear_result
- .get("result")
- .and_then(|value| value.get("config"))
- .and_then(|config| config.get("local_ai"))
- .and_then(|local_ai| local_ai.get("base_url"))
- .is_none_or(Value::is_null));
+ assert!(
+ clear_result
+ .get("result")
+ .and_then(|value| value.get("config"))
+ .and_then(|config| config.get("local_ai"))
+ .and_then(|local_ai| local_ai.get("base_url"))
+ .is_none_or(Value::is_null)
+ );
mock_join.abort();
rpc_join.abort();
@@ -8119,10 +8144,12 @@ async fn voice_live_settings_round_trip_over_json_rpc() {
.await;
let tested = assert_no_jsonrpc_error(&tested, "voice_live_test_provider");
assert_eq!(tested["ok"], false);
- assert!(tested["error"]
- .as_str()
- .unwrap_or_default()
- .contains("not_configured"));
+ assert!(
+ tested["error"]
+ .as_str()
+ .unwrap_or_default()
+ .contains("not_configured")
+ );
mock_join.abort();
rpc_join.abort();
@@ -10406,9 +10433,11 @@ async fn json_rpc_task_sources_crud_and_status() {
.as_array()
.expect("list returns array")
.clone();
- assert!(sources
- .iter()
- .any(|s| s.get("id").and_then(Value::as_str) == Some(id.as_str())));
+ assert!(
+ sources
+ .iter()
+ .any(|s| s.get("id").and_then(Value::as_str) == Some(id.as_str()))
+ );
// ── get roundtrips ───────────────────────────────────────────────
let get = post_json_rpc(
@@ -11550,10 +11579,7 @@ async fn json_rpc_flows_full_arc_discover_build_create_run_inner() {
// the builder loop.
push_forced_chat_completion_when(
"dry_run_workflow",
- forced_tool_call_completion(
- "dry_run_workflow",
- json!({ "graph": demo_graph.clone() }),
- ),
+ forced_tool_call_completion("dry_run_workflow", json!({ "graph": demo_graph.clone() })),
);
push_forced_chat_completion_when(
"propose_workflow",