The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(cost): update tests for cost tally and source tracking
Steven Enamakela0d34b84b021
diff --git a/crates/openhuman-core/src/agent/session_host/driver_tests.rs b/crates/openhuman-core/src/agent/session_host/driver_tests.rsindex 89b5d0ce4d..378e5dde50 100644--- a/crates/openhuman-core/src/agent/session_host/driver_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/driver_tests.rs@@ -91,7 +91,10 @@ fn graph_failure_copies_snapshot_usage_and_failed_tool_outcome_to_sidecar() {cached_input_tokens: 3,last_call_input_tokens: 13,last_call_output_tokens: 5,- charged_amount_usd: 0.004,+ cost: crate::agent::cost::CostTally {+ known_usd: 0.004,+ source: crate::agent::cost::CostSource::Charged,+ },resolved_route: Some(tinyinference_llm::model::ResolvedModelRoute::new("openhuman","chat-concrete",@@ -136,7 +139,8 @@ fn graph_failure_copies_snapshot_usage_and_failed_tool_outcome_to_sidecar() {),(13, 5));- assert!((observed.cost_usd - 0.004).abs() < f64::EPSILON);+ assert!((observed.cost.known_usd - 0.004).abs() < f64::EPSILON);+ 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/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rsindex 4b4234720e..3b48ac420a 100644--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs@@ -112,7 +112,10 @@ fn codec_attaches_only_this_agents_own_sidecar_usage_to_atomic_append() {sidecar.input_tokens = 13;sidecar.output_tokens = 8;sidecar.cached_input_tokens = 3;- sidecar.cost_usd = 0.004;+ sidecar.cost = crate::agent::cost::CostTally {+ known_usd: 0.004,+ source: crate::agent::cost::CostSource::Charged,+ };sidecar.context_window = 128_000;sidecar.last_call_input_tokens = 9;sidecar.last_call_output_tokens = 2;@@ -135,6 +138,7 @@ fn codec_attaches_only_this_agents_own_sidecar_usage_to_atomic_append() {output_tokens: 2,cached_input_tokens: 1,charged_amount_usd: 0.001,+ cost_source: crate::agent::cost::CostSource::Charged,},});// `OpenHumanRunContext` is `Clone` and its child ledger is an `Arc`, so this@@ -199,7 +203,10 @@ fn last_turn_usage_reports_the_same_holistic_totals_as_transcript_billing() {input_tokens: 13,output_tokens: 8,cached_input_tokens: 3,- cost_usd: 0.004,+ cost: crate::agent::cost::CostTally {+ known_usd: 0.004,+ source: crate::agent::cost::CostSource::Charged,+ },context_window: 128_000,last_call_input_tokens: 9,last_call_output_tokens: 2,@@ -215,6 +222,7 @@ fn last_turn_usage_reports_the_same_holistic_totals_as_transcript_billing() {output_tokens: 2,cached_input_tokens: 1,charged_amount_usd: 0.001,+ cost_source: crate::agent::cost::CostSource::Charged,},});@@ -222,7 +230,7 @@ fn last_turn_usage_reports_the_same_holistic_totals_as_transcript_billing() {assert_eq!(usage.input_tokens, 18);assert_eq!(usage.output_tokens, 10);assert_eq!(usage.cached_input_tokens, 4);- assert!((usage.cost_usd - 0.005).abs() < f64::EPSILON);+ assert!((usage.cost_usd.expect("all calls charged") - 0.005).abs() < f64::EPSILON);assert_eq!(usage.context_window, 128_000);// The gauge numerator is the root's final call alone: neither the turn's// summed spend nor the child's tokens, which ran in their own window.diff --git a/crates/openhuman-core/src/agent/session_host/tool_progress.rs b/crates/openhuman-core/src/agent/session_host/tool_progress.rsindex 158b80a42e..69cf1eed14 100644--- a/crates/openhuman-core/src/agent/session_host/tool_progress.rs+++ b/crates/openhuman-core/src/agent/session_host/tool_progress.rs@@ -122,7 +122,8 @@ impl ProgressReporter for TurnProgress {input_tokens: cost.input_tokens,output_tokens: cost.output_tokens,cached_input_tokens: cost.cached_input_tokens,- total_usd: cost.total_usd(),+ // Known spend so far; an unpriced call adds nothing to it.+ total_usd: cost.cost.known_usd,};emit(sink, event);}diff --git a/crates/openhuman-core/src/agent/stop_hooks_tests.rs b/crates/openhuman-core/src/agent/stop_hooks_tests.rsindex 0a2334b27d..3201a4cb64 100644--- a/crates/openhuman-core/src/agent/stop_hooks_tests.rs+++ b/crates/openhuman-core/src/agent/stop_hooks_tests.rs@@ -77,7 +77,10 @@ async fn scoped_stop_hooks_are_visible_to_run_contexts() {async fn budget_stop_hook_fails_closed_and_stops_at_cap() {let hook = BudgetStopHook::new(1.0);let cost = TurnCost {- charged_usd: 1.0,+ cost: crate::agent::cost::CostTally {+ known_usd: 1.0,+ source: crate::agent::cost::CostSource::Charged,+ },..TurnCost::default()};let state = TurnState {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.rsindex edb3ce09d1..916e39454a 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@@ -170,6 +170,7 @@ fn child_ledgers_are_isolated_and_parent_keeps_completed_child_totals() {output_tokens: 2,cached_input_tokens: 1,charged_amount_usd: 0.01,+ cost_source: crate::agent::cost::CostSource::Charged,},});assert!(right.subagent_usage_entries().is_empty());diff --git a/crates/openhuman-core/src/agent/tinyagents/observability_tests.rs b/crates/openhuman-core/src/agent/tinyagents/observability_tests.rsindex b0f7d742a7..d8de4c3906 100644--- a/crates/openhuman-core/src/agent/tinyagents/observability_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/observability_tests.rs@@ -161,9 +161,10 @@ async fn model_completed_projects_generation_with_content_and_provider() {assert!(input.unwrap().to_string().contains("You are OpenHuman."));assert!(output.unwrap().to_string().contains("hi"));assert_eq!(input_tokens, 1_000);- // chat-v1 is a managed tier handle — the tier-aware estimator must- // price it (> $0); the old catalog-only lookup returned exactly 0.- assert!(cost_usd > 0.0, "managed tier call must not price as $0");+ // chat-v1 is a managed tier handle with no catalogued list price, and this+ // call carried no reported charge: its cost is unknown, not a guessed+ // default rate (which once priced glm-5.3-flash at 14x what was billed).+ assert_eq!(cost_usd, None, "an unpriced call reports no cost");}#[tokio::test]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.rsindex cda7238bca..5f606ee6e2 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,7 @@ 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, 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/web_chat/presentation_tests.rs b/crates/openhuman-core/src/web_chat/presentation_tests.rsindex c5227d3f61..fd0ed98ad2 100644--- a/crates/openhuman-core/src/web_chat/presentation_tests.rs+++ b/crates/openhuman-core/src/web_chat/presentation_tests.rs@@ -52,7 +52,8 @@ async fn chat_done_carries_timing_when_a_snapshot_is_supplied() {input_tokens: 100,output_tokens: 40,cached_input_tokens: 0,- cost_usd: 0.01,+ cost_usd: Some(0.01),+ cost_source: crate::agent::cost::CostSource::Charged,context_window: 8000,context_tokens: 60,subagents: Vec::new(),