Skip to content

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

style: apply rustfmt formatting across agent and inference modules

Steven Enamakel8ac6be7c1dd9
diff --git a/crates/openhuman-core/src/agent/cost.rs b/crates/openhuman-core/src/agent/cost.rs
index ffa2d1664f..1276914457 100644
--- a/crates/openhuman-core/src/agent/cost.rs
+++ b/crates/openhuman-core/src/agent/cost.rs
@@ -66,7 +66,16 @@ pub fn estimate_call_cost_usd(model: &str, usage: &BilledUsage) -> Option<f64> {
/// Where a cost figure came from. Ordered from most to least certain, so the
/// cost of several calls takes the least certain of their sources.
#[derive(
- Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, serde::Serialize, serde::Deserialize,
+ Debug,
+ Clone,
+ Copy,
+ PartialEq,
+ Eq,
+ PartialOrd,
+ Ord,
+ Default,
+ serde::Serialize,
+ serde::Deserialize,
)]
#[serde(rename_all = "snake_case")]
pub enum CostSource {
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
index cbad87c2c8..5fd11d4dc9 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
@@ -72,10 +72,11 @@ async fn run(candidates: Vec<String>, verdicts: Vec<Option<CloseViolation>>) ->
async move { (violation, None) }
};
- let (output, usage) = close_with_one_repair("test-model", instruction.clone(), None, ask, verify, || {
- FALLBACK.to_string()
- })
- .await;
+ let (output, usage) =
+ close_with_one_repair("test-model", instruction.clone(), None, ask, verify, || {
+ FALLBACK.to_string()
+ })
+ .await;
Shipped {
output,
diff --git a/crates/openhuman-core/src/agent/session_host/driver_tests.rs b/crates/openhuman-core/src/agent/session_host/driver_tests.rs
index 378e5dde50..498f367222 100644
--- a/crates/openhuman-core/src/agent/session_host/driver_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver_tests.rs
@@ -140,7 +140,10 @@ fn graph_failure_copies_snapshot_usage_and_failed_tool_outcome_to_sidecar() {
(13, 5)
);
assert!((observed.cost.known_usd - 0.004).abs() < f64::EPSILON);
- assert_eq!(observed.cost.source, crate::agent::cost::CostSource::Charged);
+ assert_eq!(
+ observed.cost.source,
+ crate::agent::cost::CostSource::Charged
+ );
let route = observed
.resolved_route
.as_ref()
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index c8371f0c7f..02dfb0f041 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -880,9 +880,11 @@ impl OpenHumanPersistence {
.saturating_add(checkpoint.usage.output_tokens),
cache_read_tokens: checkpoint.usage.cached_input_tokens,
// An unknown cost crosses as no charge at all, never as $0.
- charged_amount: checkpoint.usage.cost().usd().map(|usd| {
- ChargedAmount::usd_micros((usd * 1_000_000.0).round() as i64)
- }),
+ charged_amount: checkpoint
+ .usage
+ .cost()
+ .usd()
+ .map(|usd| ChargedAmount::usd_micros((usd * 1_000_000.0).round() as i64)),
..Usage::default()
},
},
@@ -1197,9 +1199,11 @@ fn host_outcome_to_neutral(
.saturating_add(outcome.usage.output_tokens),
cache_read_tokens: outcome.usage.cached_input_tokens,
// An unknown cost crosses as no charge at all, never as $0.
- charged_amount: outcome.usage.cost().usd().map(|usd| {
- ChargedAmount::usd_micros((usd * 1_000_000.0).round() as i64)
- }),
+ charged_amount: outcome
+ .usage
+ .cost()
+ .usd()
+ .map(|usd| ChargedAmount::usd_micros((usd * 1_000_000.0).round() as i64)),
..Usage::default()
},
},
@@ -1307,16 +1311,13 @@ fn outcome_to_host(
fn map_lifecycle_error(error: SubagentError) -> SubagentRunError {
SubagentRunError::Provider(anyhow::anyhow!(error.to_string()))
-}/// A child run's cost as it comes back across the orchestration boundary.
+}
+/// A child run's cost as it comes back across the orchestration boundary.
/// That `Usage` can only say whether a charge is present, so a present one is
/// read as charged and an absent one as unknown (it was sent as absent).
-fn cost_source_of(
- charged: Option<&ChargedAmount>,
-) -> crate::agent::cost::CostSource {
+fn cost_source_of(charged: Option<&ChargedAmount>) -> crate::agent::cost::CostSource {
match charged {
Some(_) => crate::agent::cost::CostSource::Charged,
None => crate::agent::cost::CostSource::Unknown,
}
}
-
-
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
index 26499121a4..6685d45a18 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/transcript.rs
@@ -80,9 +80,7 @@ pub(super) fn persist_subagent_transcript(
cost_usd: usage.cost.known_usd,
cost_source: Some(match usage.cost.source {
crate::agent::cost::CostSource::Charged => transcript::UsageCostSource::Charged,
- crate::agent::cost::CostSource::Estimated => {
- transcript::UsageCostSource::Estimated
- }
+ crate::agent::cost::CostSource::Estimated => transcript::UsageCostSource::Estimated,
crate::agent::cost::CostSource::Unknown => transcript::UsageCostSource::Unknown,
}),
// No per-call figure reaches here; readers fall back to the mean
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
index 07252808df..55581da712 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
@@ -166,8 +166,8 @@ pub(super) async fn finalize_turn_outcome(
// cached tokens and the estimated charged USD) when the observed path ran;
// otherwise fall back to the run's aggregate totals and estimate the cost from
// them so a fire-and-forget turn still reports a real (non-$0) cost.
- let (input_tokens, output_tokens, cached_input_tokens, cost) = bridge_totals
- .unwrap_or_else(|| {
+ let (input_tokens, output_tokens, cached_input_tokens, cost) =
+ bridge_totals.unwrap_or_else(|| {
let input = run.usage.usage.input_tokens;
let output = run.usage.usage.output_tokens;
let cached = run.usage.usage.cache_read_tokens;
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
index 5f606ee6e2..42392b45d1 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
@@ -68,7 +68,11 @@ fn crate_model_response_preserves_flow_completion_contract() {
},
usage: Some(usage),
finish_reason: Some("tool_calls".to_string()),
- raw: crate::agent::tinyagents::model::merge_openhuman_usage_meta(None, Some(0.125), 128_000),
+ raw: crate::agent::tinyagents::model::merge_openhuman_usage_meta(
+ None,
+ Some(0.125),
+ 128_000,
+ ),
resolved_model: None,
continue_turn: None,
served_from_cache: false,
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_calls.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_calls.rs
index 849143ddbd..701d9c8372 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_calls.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_calls.rs
@@ -85,9 +85,9 @@ impl ChatModel<()> for OpenHumanBackendModel {
observe_in_band_failure(&item);
match item {
tinyinference_llm::model::ModelStreamItem::Completed(response) => {
- tinyinference_llm::model::ModelStreamItem::Completed(
- project_managed_usage(response),
- )
+ tinyinference_llm::model::ModelStreamItem::Completed(project_managed_usage(
+ response,
+ ))
}
other => other,
}
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs
index 9ca215c339..c93b5f04d6 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model_stream_tests.rs
@@ -261,7 +261,10 @@ async fn managed_stream_carries_the_backend_charge_to_the_cost_accounting() {
let billed = crate::agent::tinyagents::model::usage_info_from_response(&response)
.expect("usage reported");
- assert!(billed.charge_reported, "the backend's charge reached the core");
+ assert!(
+ billed.charge_reported,
+ "the backend's charge reached the core"
+ );
assert!((billed.charged_amount_usd - 0.0000634).abs() < 1e-12);
assert_eq!(billed.cached_input_tokens(), 800);
assert_eq!(
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index ab864e1fb6..83de91d4c4 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -12463,7 +12463,10 @@ async fn json_rpc_threads_token_usage_reads_persisted_thread_totals() {
assert_eq!(subs[0]["input_tokens"], 1000);
assert_eq!(subs[0]["output_tokens"], 200);
assert_eq!(subs[0]["runs"], 1);
- assert!(subs[0]["cost_usd"].is_null(), "an unpriced sub-agent reports no cost");
+ assert!(
+ subs[0]["cost_usd"].is_null(),
+ "an unpriced sub-agent reports no cost"
+ );
// Unknown thread → all-zero totals with has_usage=false (brand-new thread).
let resp_unknown = post_json_rpc(