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
fix(test): correct test module naming in model_g1_usage_tests
Steven Enamakeld109f46cba4f
diff --git a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rsindex df15252719..bccd2b4eb2 100644--- a/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/model_g1_usage_tests_tests.rs@@ -35,8 +35,8 @@ fn usage_round_trips_charged_usd_and_all_token_breakdowns() {let recovered = usage_info_from_response(&model_response).expect("usage info");assert_eq!(recovered.input_tokens, 100);assert_eq!(recovered.output_tokens, 20);- assert_eq!(recovered.context_window, 128_000);- assert_eq!(recovered.cached_input_tokens, 40);+ assert_eq!(recovered.context_window(), 128_000);+ assert_eq!(recovered.cached_input_tokens(), 40);assert_eq!(recovered.cache_creation_tokens, 10);assert_eq!(recovered.reasoning_tokens, 7);assert!((recovered.charged_amount_usd - 0.0123).abs() < 1e-9);@@ -57,7 +57,7 @@ fn no_billing_metadata_leaves_raw_clean() {);let recovered = usage_info_from_response(&model_response).expect("usage info");assert_eq!(recovered.charged_amount_usd, 0.0);- assert_eq!(recovered.context_window, 0);+ assert_eq!(recovered.context_window(), 0);assert_eq!(recovered.input_tokens, 5);}@@ -165,3 +165,44 @@ fn prompt_guided_response_keeps_legacy_pformat_fallback() {serde_json::json!({"id": 7, "query": "needle"}));}++/// Wire shape of the billing/context metadata stashed in `ModelResponse.raw`:+/// a literal-JSON pin so the key and field names cannot drift, and a response+/// written by the current release (with the old key set) still reconstructs.+#[test]+fn usage_meta_raw_wire_shape_is_stable_and_old_payloads_load() {+ let chat = ChatResponse {+ text: Some("hi".to_string()),+ tool_calls: Vec::new(),+ usage: Some(+ BilledUsage::from_counts(100, 20)+ .with_context_window(128_000)+ .with_charged_usd(0.0123),+ ),+ reasoning_content: None,+ };+ let written = response_to_model_response(&chat, &empty_registry(), false);+ assert_eq!(+ written.raw,+ Some(serde_json::json!({+ "openhuman_usage_meta": {"charged_amount_usd": 0.0123, "context_window": 128000}+ }))+ );++ let mut old = response_to_model_response(+ &ChatResponse {+ text: Some("x".into()),+ usage: Some(BilledUsage::from_counts(7, 2)),+ ..Default::default()+ },+ &empty_registry(),+ false,+ );+ old.raw = Some(serde_json::json!({+ "openhuman_usage_meta": {"charged_amount_usd": 0.5, "context_window": 32000}+ }));+ let recovered = usage_info_from_response(&old).expect("usage");+ assert_eq!(recovered.charged_amount_usd, 0.5);+ assert_eq!(recovered.context_window(), 32_000);+ assert_eq!(recovered.input_tokens, 7);+}diff --git a/crates/openhuman-core/src/platform/cost/global_tests.rs b/crates/openhuman-core/src/platform/cost/global_tests.rsindex c0dd151f8c..2a9863824d 100644--- a/crates/openhuman-core/src/platform/cost/global_tests.rs+++ b/crates/openhuman-core/src/platform/cost/global_tests.rs@@ -213,3 +213,40 @@ fn rebind_global_moves_recording_to_the_new_workspace() {*GLOBAL_TRACKER.write() = previous;}++/// Persisted cost rows are `TokenUsage`/`CostRecord` JSON lines. Pin the exact+/// serialized key set produced from a provider usage record, and prove a row+/// written by the current release (literal JSON) still deserializes.+#[test]+fn token_usage_row_shape_is_stable_and_old_rows_load() {+ let usage = BilledUsage::from_counts(1000, 500)+ .with_cached_input_tokens(400)+ .with_cache_creation_tokens(30)+ .with_reasoning_tokens(7)+ .with_charged_usd(0.0123);+ let row = build_token_usage("m/x", &usage).unwrap();+ let mut value = serde_json::to_value(&row).unwrap();+ let obj = value.as_object_mut().unwrap();+ obj.remove("timestamp").expect("timestamp key present");+ assert_eq!(+ value,+ serde_json::json!({+ "model": "m/x",+ "input_tokens": 1000,+ "output_tokens": 500,+ "total_tokens": 1500,+ "cached_input_tokens": 400,+ "cache_creation_tokens": 30,+ "reasoning_tokens": 7,+ "cost_usd": 0.0123,+ "cost_source": "provider_charged",+ "run_id": null,+ "root_run_id": null+ })+ );++ let old = r#"{"model":"m/x","input_tokens":10,"output_tokens":5,"total_tokens":15,"cost_usd":0.25,"timestamp":"2026-01-02T03:04:05Z"}"#;+ let parsed: TokenUsage = serde_json::from_str(old).expect("old row loads");+ assert_eq!(parsed.input_tokens, 10);+ assert_eq!(parsed.cost_usd, 0.25);+}