Skip to content

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

chore: files changed crates/openhuman-core/src/agent/cost_tests.rs,crates/openhuman-core/src/agent/t

Steven Enamakel6c97d7f50c4f
diff --git a/crates/openhuman-core/src/agent/cost_tests.rs b/crates/openhuman-core/src/agent/cost_tests.rs
index 5d5695d21d..9a73526045 100644
--- a/crates/openhuman-core/src/agent/cost_tests.rs
+++ b/crates/openhuman-core/src/agent/cost_tests.rs
@@ -92,3 +92,42 @@ fn turn_cost_aggregates_token_counts() {
assert_eq!(tc.output_tokens, 125);
assert_eq!(tc.cached_input_tokens, 20);
}
+
+#[test]
+fn free_models_are_priced_at_zero() {
+ // OpenRouter `:free` variants are not billed; the catalog would otherwise
+ // price `deepseek/...:free` like its paid sibling, or the fallback at $3/$15.
+ for model in [
+ "deepseek/deepseek-chat-v3.1:free",
+ "openrouter/meta-llama/llama-3.3-70b-instruct:free",
+ "Totally-Unknown-Model:FREE",
+ ] {
+ assert!(is_free_model(model), "{model}");
+ let usage = usage(1_000_000, 1_000_000, 0, 0.0);
+ assert_eq!(estimate_call_cost_usd(model, &usage), 0.0, "{model}");
+ assert_eq!(estimate_known_call_cost_usd(model, &usage), Some(0.0));
+ assert_eq!(call_cost_usd(model, &usage), 0.0);
+ }
+ assert!(!is_free_model("deepseek/deepseek-chat"));
+}
+
+#[test]
+fn unknown_model_has_no_known_price() {
+ assert!(lookup_known_pricing("totally-unknown-model").is_none());
+ assert_eq!(
+ estimate_known_call_cost_usd("totally-unknown-model", &usage(1_000, 100, 0, 0.0)),
+ None,
+ "reporting must not fabricate a cost for an unpriced model"
+ );
+ // Budget enforcement still sees the conservative fallback.
+ assert!(estimate_call_cost_usd("totally-unknown-model", &usage(1_000, 100, 0, 0.0)) > 0.0);
+}
+
+#[test]
+fn known_model_estimate_matches_budget_estimate() {
+ let usage = usage(10_000, 2_000, 4_000, 0.0);
+ assert_eq!(
+ estimate_known_call_cost_usd(FLASH, &usage),
+ Some(estimate_call_cost_usd(FLASH, &usage))
+ );
+}
diff --git a/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs b/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs
index 814affbb32..7bb8b517e0 100644
--- a/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/deadline_wind_down.rs
@@ -25,9 +25,9 @@ use std::time::Instant;
use async_trait::async_trait;
use tinyagents_harness::context::RunContext;
-use tinyagents_harness::middleware::Middleware;
+use tinyagents_harness::middleware::{Middleware, ToolInvocationIdentity};
+use tinyagents_harness::runtime::AgentHarness;
use tinyagents_harness::steering::{SteeringCommand, SteeringHandle};
-use tinyagents_harness::AgentHarness;
use tinyinference_llm::model::ModelResponse;
use tinytools::ToolResult;
@@ -99,7 +99,7 @@ where
&self,
_ctx: &mut RunContext<Ctx>,
_state: &State,
- _invocation: &tinyagents_harness::middleware::ToolInvocationIdentity,
+ _invocation: &ToolInvocationIdentity,
_result: &mut ToolResult,
) -> tinyagents_harness::Result<()> {
self.maybe_pause("after_tool", Instant::now());
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rs
index 8e5e1a7858..ce1a58b4ec 100644
--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs
@@ -20,6 +20,7 @@
//! tinyagents harness.
mod compaction_carry;
+mod deadline_wind_down;
pub mod config;
pub mod discovery;
mod embeddings;