Skip to content

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

style: apply rustfmt import ordering and line wrapping

Steven Enamakel4c4ded63c93b
diff --git a/crates/openhuman-core/src/agent/tinyagents/budget.rs b/crates/openhuman-core/src/agent/tinyagents/budget.rs
index a2bac9d82e..908a1e6a83 100644
--- a/crates/openhuman-core/src/agent/tinyagents/budget.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/budget.rs
@@ -7,13 +7,13 @@ use tinyinference_llm::model::ChatModel;
/// Product recursion ceiling shared by native and MCP delegation.
pub(crate) const MAX_SPAWN_DEPTH: usize = 3;
-pub use tinyinference_llm::model::budget::{
- Budget, BudgetExceeded, BudgetSnapshot, CallBudget, Spend, SpendLimits,
-};
pub use tinyagents_harness::cost::{
ControlledDispatchError, DispatchModelOptions, DispatchRefusal, DispatchRefusalReason,
PhysicalDispatchAdmission, PhysicalDispatchPermit,
};
+pub use tinyinference_llm::model::budget::{
+ Budget, BudgetExceeded, BudgetSnapshot, CallBudget, Spend, SpendLimits,
+};
/// OpenHuman's source-compatible carrier for the shared ledger and physical
/// call reservation bounds. The owner harness performs the wrapping engine.
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 8d007e1817..6e2c92c204 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -270,8 +270,7 @@ pub struct OpenHumanRunContext {
/// Explicit shared model-call budget inherited by synchronous children.
pub model_budget: Option<super::super::budget::ModelBudget>,
/// Host admission policy shared by this run and its synchronous descendants.
- pub dispatch_admission:
- Option<Arc<dyn super::super::budget::PhysicalDispatchAdmission>>,
+ pub dispatch_admission: Option<Arc<dyn super::super::budget::PhysicalDispatchAdmission>>,
/// The response format and output cap this root turn asks of every model
/// call, and the slot its final call is reported into. Carried explicitly
/// from the caller (`agent_chat`) through the session; children never
@@ -419,12 +418,12 @@ pub(crate) struct HarnessHostPolicy {
#[cfg(test)]
pub(crate) use super::operation_context::tool_context_with_approval;
-pub use super::operation_context::{approval_for_tool, OpenHumanRunExt};
pub(crate) use super::operation_context::{
- command_environment_for_tool, dispatch_ctx_for_tool, memory_identity_for_tool,
- memory_in_prompt_for_tool, parent_agent_id_for_tool, sandbox_mode_for_tool,
- task_recency_window_for_tool, turn_origin_for_tool, HostOperationContext,
+ HostOperationContext, command_environment_for_tool, dispatch_ctx_for_tool,
+ memory_identity_for_tool, memory_in_prompt_for_tool, parent_agent_id_for_tool,
+ sandbox_mode_for_tool, task_recency_window_for_tool, turn_origin_for_tool,
};
+pub use super::operation_context::{OpenHumanRunExt, approval_for_tool};
impl Default for OpenHumanRunContext {
fn default() -> Self {
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
index 1c1c666f9d..4dd7f3d9f8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context_tests.rs
@@ -109,16 +109,20 @@ fn child_inherits_tree_handles_but_isolates_observations_and_usage() {
assert_eq!(child.spawn_depth, 1);
assert_eq!(child.thread_id.as_deref(), Some("thread-a"));
assert!(child.file_state_agent_id().is_none());
- assert!(child
- .resolved_route
- .lock()
- .expect("child route lock")
- .is_none());
- assert!(child
- .subagent_usage
- .lock()
- .expect("child usage lock")
- .is_empty());
+ assert!(
+ child
+ .resolved_route
+ .lock()
+ .expect("child route lock")
+ .is_none()
+ );
+ assert!(
+ child
+ .subagent_usage
+ .lock()
+ .expect("child usage lock")
+ .is_empty()
+ );
parent.cancellation.cancel();
assert!(child.cancellation.is_cancelled());
diff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
index ce212b6148..ca547cb91d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
@@ -22,12 +22,12 @@
use std::sync::Arc;
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use tinyagents_harness::context::RunContext;
use tinyagents_harness::summarization::payload_summarizer::{
- run_unary_summary, summary_child_config, PayloadSummarizer as HarnessPayloadSummarizer,
+ PayloadSummarizer as HarnessPayloadSummarizer, run_unary_summary, summary_child_config,
};
-use tinyagents_orchestration::subagent::{subagent_framing, SubagentRole};
+use tinyagents_orchestration::subagent::{SubagentRole, subagent_framing};
use tracing::debug;
use crate::agent::subagent_host;
@@ -46,10 +46,10 @@ use {
/// way supplies its own. The prompt is not part of this — TinyJuice writes it
/// and sends it in the [`GenerateRequest`].
pub type DynPayloadSummarizer = dyn HarnessPayloadSummarizer<
- OpenHumanRunContext,
- Prepared = PreparedGenerate,
- Error = anyhow::Error,
->;
+ OpenHumanRunContext,
+ Prepared = PreparedGenerate,
+ Error = anyhow::Error,
+ >;
/// Runs the `summarizer` agent definition's model as a unary child of the turn.
pub struct SubagentPayloadSummarizer {
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
index 72ced1691b..9ba2c051e2 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_exec.rs
@@ -21,20 +21,20 @@ use tinyagents_runtime::turn_driver::{
use tinyagents_runtime::{DriverRequest, ToolSnapshot};
use crate::agent::harness::tool_result_artifacts::TINYAGENTS_TOOL_RESULT_ARTIFACT_STORE;
+use crate::agent::tinyagents::NativeSubagentRunContext;
use crate::agent::tinyagents::host::OpenHumanRunContext;
use crate::agent::tinyagents::middleware::turn_context::TurnContextMiddleware;
use crate::agent::tinyagents::observability::{OpenhumanEventBridge, SubagentScope};
use crate::agent::tinyagents::tool_registration::capability_diagnostics;
use crate::agent::tinyagents::turn_middleware::{
- install_turn_middleware, TurnMiddlewareInputs, TurnWiring,
+ TurnMiddlewareInputs, TurnWiring, install_turn_middleware,
};
use crate::agent::tinyagents::turn_outcome::TinyagentsTurnOutcome;
use crate::agent::tinyagents::turn_plan::{
- enforce_registry_diagnostics, turn_models_for_plan, turn_run_policy, OpenHumanTurnPlanner,
+ OpenHumanTurnPlanner, enforce_registry_diagnostics, turn_models_for_plan, turn_run_policy,
};
use crate::agent::tinyagents::turn_run_error::map_turn_run_error;
use crate::agent::tinyagents::turn_run_finalize::finalize_turn_outcome;
-use crate::agent::tinyagents::NativeSubagentRunContext;
use crate::agent::tinyagents::{journal, routes, steering_forwarder};
use crate::inference::turn_models::TurnModels;
use tinyagents_harness::events::EventSink;
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rs
index 38e3877bf4..d0b5106ae7 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs
@@ -14,11 +14,11 @@ mod runtime_ops;
mod turn_guards;
pub use agent_chat::{
- agent_chat, agent_chat_for, agent_chat_reply_for, agent_chat_simple, AgentChatEnv,
- AgentChatReply, AgentChatTarget,
+ AgentChatEnv, AgentChatReply, AgentChatTarget, agent_chat, agent_chat_for,
+ agent_chat_reply_for, agent_chat_simple,
};
pub use complete_once::{
- complete_once, complete_once_controlled, complete_once_observed, CompletionEndpoint,
+ CompletionEndpoint, complete_once, complete_once_controlled, complete_once_observed,
};
pub use runtime_ops::{
local_ai_prompt, local_ai_status, local_ai_summarize, local_ai_transcribe,
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
index 13c3d00538..797c5e742b 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once.rs
@@ -89,7 +89,9 @@ pub async fn complete_once_controlled(
endpoint: &CompletionEndpoint,
request: ModelRequest,
budget: Option<&crate::agent::tinyagents::budget::ModelBudget>,
- observer: Option<std::sync::Arc<dyn tinyagents_harness::observability::PhysicalDispatchObserver>>,
+ observer: Option<
+ std::sync::Arc<dyn tinyagents_harness::observability::PhysicalDispatchObserver>,
+ >,
admission: Option<std::sync::Arc<dyn tinyagents_harness::cost::PhysicalDispatchAdmission>>,
) -> Result<ModelResponse, tinyagents_harness::cost::ControlledDispatchError> {
if !request.tools.is_empty() {
@@ -101,16 +103,24 @@ pub async fn complete_once_controlled(
// reach the provider even though `request.tools` is empty above. The typed
// request fields own these keys.
if let Some(key) = reserved_provider_option(&request.provider_options) {
- return Err(tinyagents_harness::cost::ControlledDispatchError::Model(tinyinference_llm::Error::Validation(format!(
- "complete_once: provider_options may not set `{key}`; use the typed request fields"
- ))));
+ return Err(tinyagents_harness::cost::ControlledDispatchError::Model(
+ tinyinference_llm::Error::Validation(format!(
+ "complete_once: provider_options may not set `{key}`; use the typed request fields"
+ )),
+ ));
}
// Blank is refused, but the id itself goes out exactly as the caller named it.
let model_id = request
.model
.as_deref()
.filter(|model| !model.trim().is_empty())
- .ok_or_else(|| tinyagents_harness::cost::ControlledDispatchError::Model(tinyinference_llm::Error::Validation("complete_once: request.model is required".to_string())))?
+ .ok_or_else(|| {
+ tinyagents_harness::cost::ControlledDispatchError::Model(
+ tinyinference_llm::Error::Validation(
+ "complete_once: request.model is required".to_string(),
+ ),
+ )
+ })?
.to_string();
let mut model = OpenAiModel::new(endpoint.api_key.clone())
@@ -129,17 +139,15 @@ pub async fn complete_once_controlled(
);
let model: std::sync::Arc<dyn ChatModel<()>> = std::sync::Arc::new(model);
- let monetary_budget = budget.map(|budget| tinyagents_harness::cost::ModelBudget::new(
- budget.ledger.clone(),
- budget.call,
- ));
+ let monetary_budget = budget.map(|budget| {
+ tinyagents_harness::cost::ModelBudget::new(budget.ledger.clone(), budget.call)
+ });
if admission.is_none() {
let model: std::sync::Arc<dyn ChatModel<()>> = match (budget, observer) {
(Some(budget), observer) => budget.wrap_with_observer(model, observer),
(None, Some(observer)) => {
- let normalized = std::sync::Arc::new(
- tinyagents_harness::cost::GatewayChargeModel::new(model),
- );
+ let normalized =
+ std::sync::Arc::new(tinyagents_harness::cost::GatewayChargeModel::new(model));
std::sync::Arc::new(
tinyagents_harness::observability::physical_dispatch::ObservedChatModel::new(
normalized, observer,
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
index 054633c972..94dba635de 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/complete_once_tests.rs
@@ -1,5 +1,5 @@
use super::*;
-use serde_json::{json, Value};
+use serde_json::{Value, json};
use tinyinference_llm::message::Message;
use tinyinference_llm::model::ResponseFormat;
use tinyinference_llm::tool::ToolSchema;
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/turn_guards.rs b/crates/openhuman-core/src/inference/host_runtime/ops/turn_guards.rs
index 1e205115c8..812781e2b7 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/turn_guards.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/turn_guards.rs
@@ -4,7 +4,7 @@
use crate::config::Config;
use crate::security::prompt_injection::{
- enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,
+ PromptEnforcementAction, PromptEnforcementContext, enforce_prompt_input,
};
pub(super) fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'static str {
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 1877deed9d..eebbbce151 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs
@@ -280,7 +280,7 @@ async fn effective_origin_defaults_to_direct_chat_outside_any_scope() {
/// see, not the blanket `Cli` allowance this RPC would otherwise impose.
#[tokio::test]
async fn effective_origin_keeps_an_embedder_scoped_label() {
- use crate::security::turn_origin::{with_origin, AgentTurnOrigin, TrustedAutomationSource};
+ use crate::security::turn_origin::{AgentTurnOrigin, TrustedAutomationSource, with_origin};
let observed = with_origin(
AgentTurnOrigin::TrustedAutomation {
job_id: "run-7".to_string(),
@@ -308,7 +308,7 @@ async fn effective_origin_keeps_an_embedder_scoped_label() {
/// touched, not a silent fall-through to the orchestrator.
#[tokio::test]
async fn agent_chat_for_rejects_an_unknown_agent_id() {
- use crate::inference::host_runtime::ops::{agent_chat_for, AgentChatTarget};
+ use crate::inference::host_runtime::ops::{AgentChatTarget, agent_chat_for};
let tmp = tempfile::tempdir().unwrap();
let mut config = test_config(&tmp);
std::fs::create_dir_all(&config.workspace_dir).unwrap();
diff --git a/crates/openhuman-embed/src/complete.rs b/crates/openhuman-embed/src/complete.rs
index dce8db1fdc..fda84b1402 100644
--- a/crates/openhuman-embed/src/complete.rs
+++ b/crates/openhuman-embed/src/complete.rs
@@ -53,7 +53,7 @@ use tinyinference_llm::message::{ContentBlock, ImageRef, Message, UserMessage};
use tinyinference_llm::model::{ModelRequest, ModelResponse};
use crate::error::CoreError;
-use crate::turn::{is_safe_endpoint_for_bearer, sanitize_url_for_display, Route};
+use crate::turn::{Route, is_safe_endpoint_for_bearer, sanitize_url_for_display};
pub use tinyagents_harness::observability::{
PhysicalDispatchMetadata, PhysicalDispatchObserver, PhysicalDispatchOutcome,
@@ -576,7 +576,7 @@ impl Completer {
mut request: CompletionRequest,
) -> Result<CompletionResponse, CoreError> {
use crate::structured::{
- accumulate, StructuredFailureReason, StructuredOutputFailure, Validator,
+ StructuredFailureReason, StructuredOutputFailure, Validator, accumulate,
};
let initial_failure = |reason| CoreError::StructuredOutput {
method: COMPLETE,
diff --git a/crates/openhuman-embed/src/complete_tests.rs b/crates/openhuman-embed/src/complete_tests.rs
index 3bb0f10ba8..d35aa98472 100644
--- a/crates/openhuman-embed/src/complete_tests.rs
+++ b/crates/openhuman-embed/src/complete_tests.rs
@@ -291,7 +291,7 @@ async fn physical_observer_reports_content_free_provider_outcome() {
#[tokio::test]
async fn physical_observer_sees_the_buyer_charge_settled_by_the_budget() {
use tinyagents_harness::observability::turn_observer::{
- with_observer, ObserverScope, TraceContent, TurnObservation,
+ ObserverScope, TraceContent, TurnObservation, with_observer,
};
let mut reply = body("hi", "stop");
@@ -512,7 +512,11 @@ async fn repair_cannot_exceed_dispatch_limit() {
.and(path("/v1/chat/completions"))
.respond_with(move |_request: &wiremock::Request| {
let mut replies = replies_for_handler.lock().unwrap();
- let text = if *replies == 0 { "invalid" } else { "{\"ok\":true}" };
+ let text = if *replies == 0 {
+ "invalid"
+ } else {
+ "{\"ok\":true}"
+ };
*replies += 1;
ResponseTemplate::new(200).set_body_json(body(text, "stop"))
})
@@ -529,7 +533,11 @@ async fn repair_cannot_exceed_dispatch_limit() {
.await;
let requests = server.received_requests().await.expect("recording on");
- assert_eq!(requests.len(), 1, "a refused repair must not reach the server");
+ assert_eq!(
+ requests.len(),
+ 1,
+ "a refused repair must not reach the server"
+ );
assert!(result.is_err(), "the refused repair must be terminal");
}
@@ -563,7 +571,11 @@ async fn scoped_monetary_budget_keeps_the_shared_dispatch_admission() {
.and(path("/v1/chat/completions"))
.respond_with(move |_request: &wiremock::Request| {
let mut replies = replies_for_handler.lock().unwrap();
- let text = if *replies == 0 { "invalid" } else { "{\"ok\":true}" };
+ let text = if *replies == 0 {
+ "invalid"
+ } else {
+ "{\"ok\":true}"
+ };
*replies += 1;
ResponseTemplate::new(200).set_body_json(body(text, "stop"))
})
@@ -640,7 +652,11 @@ async fn refusal_preserves_paid_usage_without_a_phantom_observer_event() {
.and(path("/v1/chat/completions"))
.respond_with(move |_request: &wiremock::Request| {
let mut replies = replies_for_handler.lock().unwrap();
- let text = if *replies == 0 { "invalid" } else { "{\"ok\":true}" };
+ let text = if *replies == 0 {
+ "invalid"
+ } else {
+ "{\"ok\":true}"
+ };
*replies += 1;
ResponseTemplate::new(200).set_body_json(body(text, "stop"))
})
@@ -661,7 +677,10 @@ async fn refusal_preserves_paid_usage_without_a_phantom_observer_event() {
match error {
CoreError::DispatchAdmission { usage, .. } => {
- assert_eq!(usage.expect("first call usage is retained").cost_usd, Some(0.0125));
+ assert_eq!(
+ usage.expect("first call usage is retained").cost_usd,
+ Some(0.0125)
+ );
}
other => panic!("expected typed admission refusal, got {other:?}"),
}
diff --git a/crates/openhuman-embed/src/error.rs b/crates/openhuman-embed/src/error.rs
index a26b61614b..fe634a79eb 100644
--- a/crates/openhuman-embed/src/error.rs
+++ b/crates/openhuman-embed/src/error.rs
@@ -20,8 +20,8 @@
//! facade classifies it. A host that cannot make that distinction renders a
//! scary red error where it should simply hide a tab.
-use openhuman_core::core::dispatch::UNKNOWN_METHOD_PREFIX;
use openhuman_core::core::StructuredRpcError;
+use openhuman_core::core::dispatch::UNKNOWN_METHOD_PREFIX;
/// Error returned by every typed facade call.
#[derive(Debug, thiserror::Error)]