Skip to content

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

chore(agent_chat): apply rustfmt formatting across agent chat modules

Steven Enamakel440cfe081a3a
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/attachments.rs b/crates/openhuman-core/src/agent_runs/agent_chat/attachments.rs
index dcf7dab567..bc5b5702d4 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/attachments.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/attachments.rs
@@ -21,14 +21,10 @@ pub(super) async fn stage_host_attachments(
external_channel: false,
workspace: cwd,
};
- let references = crate::attachments::host::stage_host(
- attachments,
- session_id,
- &staging_config,
- &scope,
- )
- .await
- .map_err(|error| error.to_string())?;
+ let references =
+ crate::attachments::host::stage_host(attachments, session_id, &staging_config, &scope)
+ .await
+ .map_err(|error| error.to_string())?;
log::debug!(
"[inference] agent_chat staged {} host attachment(s)",
attachments.len()
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/controllers.rs b/crates/openhuman-core/src/agent_runs/agent_chat/controllers.rs
index 1ef4f91f86..e73407975d 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/controllers.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/controllers.rs
@@ -46,7 +46,10 @@ pub(crate) fn schemas(function: &str) -> ControllerSchema {
function: "agent_chat",
description: "Run one-shot agent chat with optional model overrides.",
inputs,
- outputs: vec![json_output("response", "Agent response payload with result, logs, hit_cap, and an optional checkpoint.")],
+ outputs: vec![json_output(
+ "response",
+ "Agent response payload with result, logs, hit_cap, and an optional checkpoint.",
+ )],
},
"agent_chat_simple" => ControllerSchema {
namespace: "inference",
@@ -56,7 +59,10 @@ pub(crate) fn schemas(function: &str) -> ControllerSchema {
required_string("message", "User message."),
optional_string("model_override", "Optional model override."),
optional_f64("temperature", "Optional temperature override."),
- optional_string("thread_id", "Optional backend thread id for cache grouping and inference logs."),
+ optional_string(
+ "thread_id",
+ "Optional backend thread id for cache grouping and inference logs.",
+ ),
],
outputs: vec![json_output("response", "Agent response payload.")],
},
@@ -81,12 +87,21 @@ pub(crate) fn all_controller_schemas() -> Vec<ControllerSchema> {
pub(crate) fn all_registered_controllers() -> Vec<RegisteredController> {
vec![
- RegisteredController { schema: schemas("agent_chat"), handler: handle_agent_chat },
- RegisteredController { schema: schemas("agent_chat_simple"), handler: handle_agent_chat_simple },
+ RegisteredController {
+ schema: schemas("agent_chat"),
+ handler: handle_agent_chat,
+ },
+ RegisteredController {
+ schema: schemas("agent_chat_simple"),
+ handler: handle_agent_chat_simple,
+ },
]
}
-fn handle_agent_chat(ctx: crate::core::runtime::DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_chat(
+ ctx: crate::core::runtime::DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let params = deserialize_params::<InferenceAgentChatParams>(params)?;
let mut config = ctx.load_config().await?;
@@ -102,8 +117,11 @@ fn handle_agent_chat(ctx: crate::core::runtime::DispatchCtx, params: Map<String,
params.common.temperature,
params.common.thread_id,
params.common.cwd,
- crate::config::schema::EphemeralRoute::from_params(params.inference_url, params.api_key)
- .map(|route| route.with_headers(params.inference_headers)),
+ crate::config::schema::EphemeralRoute::from_params(
+ params.inference_url,
+ params.api_key,
+ )
+ .map(|route| route.with_headers(params.inference_headers)),
super::AgentChatEnv::default(),
)
.await?
@@ -111,7 +129,10 @@ fn handle_agent_chat(ctx: crate::core::runtime::DispatchCtx, params: Map<String,
})
}
-fn handle_agent_chat_simple(ctx: crate::core::runtime::DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
+fn handle_agent_chat_simple(
+ ctx: crate::core::runtime::DispatchCtx,
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let params = deserialize_params::<InferenceAgentChatParams>(params)?;
let config = ctx.load_config().await?;
@@ -128,22 +149,44 @@ fn handle_agent_chat_simple(ctx: crate::core::runtime::DispatchCtx, params: Map<
})
}
-fn deserialize_params<T: serde::de::DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {
+fn deserialize_params<T: serde::de::DeserializeOwned>(
+ params: Map<String, Value>,
+) -> Result<T, String> {
serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
}
fn required_string(name: &'static str, comment: &'static str) -> FieldSchema {
- FieldSchema { name, ty: TypeSchema::String, comment, required: true }
+ FieldSchema {
+ name,
+ ty: TypeSchema::String,
+ comment,
+ required: true,
+ }
}
fn optional_string(name: &'static str, comment: &'static str) -> FieldSchema {
- FieldSchema { name, ty: TypeSchema::Option(Box::new(TypeSchema::String)), comment, required: false }
+ FieldSchema {
+ name,
+ ty: TypeSchema::Option(Box::new(TypeSchema::String)),
+ comment,
+ required: false,
+ }
}
fn optional_f64(name: &'static str, comment: &'static str) -> FieldSchema {
- FieldSchema { name, ty: TypeSchema::Option(Box::new(TypeSchema::F64)), comment, required: false }
+ FieldSchema {
+ name,
+ ty: TypeSchema::Option(Box::new(TypeSchema::F64)),
+ comment,
+ required: false,
+ }
}
fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {
- FieldSchema { name, ty: TypeSchema::Json, comment, required: true }
+ FieldSchema {
+ name,
+ ty: TypeSchema::Json,
+ comment,
+ required: true,
+ }
}
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs b/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs
index 2e202258f7..1b59e4150c 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs
@@ -4,7 +4,10 @@ use super::*;
fn inference_agent_chat_controllers_keep_their_wire_names_and_namespace() {
let controllers = all_registered_controllers();
assert_eq!(controllers.len(), 2);
- assert_eq!(controllers[0].rpc_method_name(), crate::agent_runs::INFERENCE_AGENT_CHAT);
+ assert_eq!(
+ controllers[0].rpc_method_name(),
+ crate::agent_runs::INFERENCE_AGENT_CHAT
+ );
assert_eq!(controllers[0].schema.namespace, "inference");
assert_eq!(controllers[0].schema.function, "agent_chat");
assert_eq!(controllers[1].schema.function, "agent_chat_simple");
@@ -35,6 +38,12 @@ fn inference_agent_chat_parses_its_route_fields() {
}))
.expect("inference route params decode");
assert_eq!(params.agent_id.as_deref(), Some("alpha"));
- assert_eq!(params.inference_url.as_deref(), Some("https://example.test/v1"));
- assert_eq!(params.inference_headers, vec![("x-test".into(), "value".into())]);
+ assert_eq!(
+ params.inference_url.as_deref(),
+ Some("https://example.test/v1")
+ );
+ assert_eq!(
+ params.inference_headers,
+ vec![("x-test".into(), "value".into())]
+ );
}
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs b/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs
index 8eb72f72a4..4deed08b9f 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs
@@ -44,4 +44,3 @@ impl AgentChatReply {
Ok(value)
}
}
-
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/mod.rs b/crates/openhuman-core/src/agent_runs/agent_chat/mod.rs
index 0f8a24d34c..78b91e1a99 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/mod.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/mod.rs
@@ -1,16 +1,16 @@
//! Full agent chat turns and their shared turn guards.
-pub(crate) mod guards;
-mod envelope;
mod attachments;
mod controllers;
+mod envelope;
+pub(crate) mod guards;
pub(crate) mod params;
mod session_turn;
+pub use envelope::AgentChatReply;
pub use session_turn::{
agent_chat, agent_chat_for, agent_chat_reply_for, AgentChatEnv, AgentChatTarget,
};
-pub use envelope::AgentChatReply;
pub(crate) use controllers::{
all_controller_schemas as all_inference_agent_chat_controller_schemas,
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
index f62cfcb375..e8553095ec 100644
--- a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
+++ b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs
@@ -1,8 +1,8 @@
//! Agent chat turns with the full tool-using harness.
+use super::envelope::AgentChatReply;
use crate::agent::OpenHumanSessionHost;
use crate::config::Config;
-use super::envelope::AgentChatReply;
use crate::core::Outcome;
use super::guards::{
@@ -564,4 +564,3 @@ pub async fn agent_chat_reply_for(
#[cfg(test)]
#[path = "session_turn_tests.rs"]
mod tests;
-
diff --git a/crates/openhuman-core/src/agent_runs/mod.rs b/crates/openhuman-core/src/agent_runs/mod.rs
index 31052bc0a8..49261cd5ca 100644
--- a/crates/openhuman-core/src/agent_runs/mod.rs
+++ b/crates/openhuman-core/src/agent_runs/mod.rs
@@ -1,7 +1,7 @@
//! Product-facing RPC surfaces for agent runs, teams, workflows, replay, and tools.
-pub(crate) mod agent_teams;
pub mod agent_chat;
+pub(crate) mod agent_teams;
pub(crate) mod command_center;
pub(crate) mod context_breakdown;
pub(crate) mod replay;
@@ -11,13 +11,12 @@ mod subagent_finalize;
pub(crate) mod workflow_runs;
pub(crate) mod worktree_schemas;
+pub(crate) use agent_chat::{
+ all_inference_agent_chat_controller_schemas, all_inference_agent_chat_registered_controllers,
+};
pub(crate) use agent_teams::{
all_agent_team_controller_schemas, all_agent_team_registered_controllers,
};
-pub(crate) use agent_chat::{
- all_inference_agent_chat_controller_schemas,
- all_inference_agent_chat_registered_controllers,
-};
pub const INFERENCE_AGENT_CHAT: &str = "openhuman.inference_agent_chat";
pub(crate) use command_center::{
all_command_center_controller_schemas, all_command_center_registered_controllers,
diff --git a/crates/openhuman-core/src/agent_runs/schemas.rs b/crates/openhuman-core/src/agent_runs/schemas.rs
index 8ef5dc5336..79cde86702 100644
--- a/crates/openhuman-core/src/agent_runs/schemas.rs
+++ b/crates/openhuman-core/src/agent_runs/schemas.rs
@@ -1,6 +1,6 @@
use crate::core::runtime::DispatchCtx;
-use serde::Deserialize;
use serde::de::DeserializeOwned;
+use serde::Deserialize;
use serde_json::{Map, Value};
use crate::config::rpc as config_rpc;
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rs
index 8c55a09021..26ed3469fe 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs
@@ -19,9 +19,9 @@ pub use runtime_ops::{
local_ai_transcribe_bytes, local_ai_tts, local_ai_vision_prompt,
};
-#[cfg(test)]
-use crate::config::Config;
#[cfg(test)]
use crate::agent_runs::agent_chat::guards::{
effective_agent_chat_origin, grant_turn_cwd, normalize_model_override, resolve_turn_cwd,
};
+#[cfg(test)]
+use crate::config::Config;
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
index 3c73d453c9..45935e821c 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
@@ -1,11 +1,11 @@
//! The lightweight provider-only agent chat variant.
-use crate::config::Config;
-use crate::core::Outcome;
-use crate::inference::provider as providers;
use crate::agent_runs::agent_chat::guards::{
enforce_user_prompt_or_reject, normalize_model_override,
};
+use crate::config::Config;
+use crate::core::Outcome;
+use crate::inference::provider as providers;
/// A simplified chat interface that does not update the base configuration.
pub async fn agent_chat_simple(
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
index bece79bd15..5d18330968 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::agent_runs::agent_chat::{agent_chat_for, AgentChatEnv, AgentChatTarget};
use crate::agent_runs::agent_chat::guards::effective_agent_chat_origin;
+use crate::agent_runs::agent_chat::{agent_chat_for, AgentChatEnv, AgentChatTarget};
// ── Op-level validation / error paths (no hardware) ───────────
diff --git a/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs b/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
index 057f73dcb8..ce096c1c12 100644
--- a/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/schemas_tests.rs
@@ -11,12 +11,7 @@ fn all_schemas_use_inference_namespace_and_have_descriptions() {
#[test]
fn every_registered_key_resolves_to_non_unknown_schema() {
- let keys = [
- "transcribe",
- "transcribe_bytes",
- "tts",
- "test_connection",
- ];
+ let keys = ["transcribe", "transcribe_bytes", "tts", "test_connection"];
for k in keys {
let s = schemas(k);
assert_eq!(s.namespace, "inference");
@@ -74,4 +69,3 @@ fn to_json_wraps_rpc_outcome() {
let v = to_json(Outcome::single_log(serde_json::json!({"ok": true}), "l")).expect("serialize");
assert!(v.get("logs").is_some() || v.get("result").is_some() || v.get("ok").is_some());
}
-
diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rs
index 4f821cc2a8..23facf3aa2 100644
--- a/crates/openhuman-embed/src/turn.rs
+++ b/crates/openhuman-embed/src/turn.rs
@@ -42,8 +42,8 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use super::error::CoreError;
-use openhuman_core::core::runtime::CoreRuntime;
use openhuman_core::agent_runs::INFERENCE_AGENT_CHAT as AGENT_CHAT;
+use openhuman_core::core::runtime::CoreRuntime;
use openhuman_core::progress::AgentProgress;
use openhuman_core::security::turn_origin::AgentTurnOrigin;
@@ -651,9 +651,7 @@ async fn dispatch(
// allocation per turn is nothing next to the turn itself.
let turn: futures_box::BoxFuture<'_, Result<AgentReply, CoreError>> =
Box::pin(async move {
- use openhuman_core::agent_runs::agent_chat::{
- agent_chat_for, AgentChatTarget,
- };
+ use openhuman_core::agent_runs::agent_chat::{agent_chat_for, AgentChatTarget};
let mut config = inner.config.clone();
let route = openhuman_core::config::schema::EphemeralRoute::from_params(
request.inference_url,