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
chore: files changed crates/openhuman-core/src/config/ops/loader/load.rs,crates/openhuman-core/src/i
Steven Enamakeld594a92d3716
diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rsindex b406739f93..ad7d34a22b 100644--- a/crates/openhuman-core/src/config/ops/loader/load.rs+++ b/crates/openhuman-core/src/config/ops/loader/load.rs@@ -211,7 +211,7 @@ pub(crate) fn seed_and_enrich_model_registry(config: &mut Config) {log::debug!("[config] seeded empty model_registry with {} catalogued models (as_of {})",config.model_registry.len(),- catalog::PRICING_AS_OF+ tinyagents_registry::pricing::PRICING_AS_OF);return;}diff --git a/crates/openhuman-core/src/inference/model_context.rs b/crates/openhuman-core/src/inference/model_context.rsindex db617c7a34..4034259b47 100644--- a/crates/openhuman-core/src/inference/model_context.rs+++ b/crates/openhuman-core/src/inference/model_context.rs@@ -56,7 +56,7 @@ pub(crate) fn static_context_window_for_model(model: &str) -> Option<u64> {return Some(window);}- if let Some(price) = crate::platform::cost::catalog::lookup(normalized) {+ if let Some(price) = tinyagents_registry::pricing::lookup(normalized) {tracing::debug!(model = normalized,catalog_model = price.model_id,diff --git a/crates/openhuman-core/src/platform/cost/catalog.rs b/crates/openhuman-core/src/platform/cost/catalog.rsindex 5caa812c77..81d68ab4d7 100644--- a/crates/openhuman-core/src/platform/cost/catalog.rs+++ b/crates/openhuman-core/src/platform/cost/catalog.rs@@ -1,465 +1,15 @@-//! Static pricing + context-window catalog for known LLM models.+//! Product model configuration and runtime overlays over the owner price catalogue.//!-//! This is the single source of truth for **pre-filled** per-model metadata of-//! the default models the product can route to:-//!-//! - per-token pricing (input + cached-input + output, USD per million tokens),-//! - the model's **context window** (max input tokens) — different providers-//! ship very different windows, and callers need it to budget prompts,-//! trigger compaction, and route work.-//!-//! It exists so the client can estimate request cost and reason about context-//! limits for any provider, used to:-//!-//! - pre-fill [`crate::config::schema::ModelRegistryEntry`] rows so-//! the Model Health dashboard shows real numbers instead of zeros, and-//! - power the fallback estimate in-//! [`crate::agent::cost::lookup_pricing`] when a backend doesn't-//! echo an authoritative `charged_amount_usd`.-//! - project OpenHuman's static rows into TinyAgents catalog entries so later-//! phases can hydrate crate-native model profiles from the same pricing and-//! window source instead of carrying a second table.-//!-//! ## Authority & freshness-//!-//! These are **best-effort published values** captured at [`PRICING_AS_OF`].-//! The provider-reported `charged_amount_usd` always wins for cost when-//! present; the catalog is only a floor estimate. Context windows are the-//! published maximums and may differ from what a given deployment/tier exposes.-//! Prices and windows drift — when a provider changes them or a new default-//! model ships, update the matching row here (and bump [`PRICING_AS_OF`]). The-//! table is intentionally a plain `const` slice with no I/O so it's cheap to-//! consult on every lookup.-//!-//! ## Matching-//!-//! [`lookup`] resolves a concrete model string to a row. It normalises case,-//! strips a leading `vendor/` segment (OpenRouter-style ids like-//! `anthropic/claude-opus-4-8`) and trailing decorations (`:tag`, `@date`,-//! `[1m]`), and finally does a longest-substring match so dated/suffixed ids-//! (`claude-opus-4-8[1m]`, `gpt-5.4-2026-05-01`) still resolve.+//! Published prices, windows and id matching live in TinyAgents registry. The+//! host retains config enrichment, source attribution and discovered local models.use crate::config::schema::ModelRegistryEntry;--/// Month the published values below were last verified. Bump when refreshing.-pub const PRICING_AS_OF: &str = "2026-07";+use tinyagents_registry::pricing::{+ lookup, model_accepts_image_input, ModelPrice, KNOWN_MODEL_PRICING, PRICING_AS_OF,+};const TINYAGENTS_CATALOG_SOURCE: &str = "openhuman-cost-catalog";-/// A single model's published per-million-token rates (USD) and context window.-#[derive(Debug, Clone, Copy)]-pub struct ModelPrice {- /// Canonical provider slug, matching the `cloud_providers` type strings- /// (`anthropic`, `openai`, `google`, `deepseek`, `moonshot`, `qwen`,- /// `mistral`). Used as the `provider` field when pre-filling registry rows.- pub provider: &'static str,- /// Canonical, lower-case model id used for matching. Keep these distinctive- /// (no bare `gpt-5`) so substring matching stays unambiguous.- pub model_id: &'static str,- /// USD per million standard (cache-miss) input tokens.- pub input_per_mtok_usd: f64,- /// USD per million cached-prefix input tokens. Best-effort: exact where the- /// provider publishes it, otherwise the provider's typical cache discount.- pub cached_input_per_mtok_usd: f64,- /// USD per million output tokens.- pub output_per_mtok_usd: f64,- /// Maximum context window in tokens (published max input). Providers differ- /// widely (128K–1M+); callers budget prompts / trigger compaction off this.- pub context_window: u32,-}--/// Published list prices and context windows for the default models the product-/// can route to.-///-/// Sources (captured [`PRICING_AS_OF`]): vendor pricing/model pages. Anthropic-/// price rows are authoritative (cached = 0.1× input, the documented cache-read-/// rate); other providers' cached rates use the published discount where known-/// and a conservative provider-typical fraction otherwise. Context windows are-/// the published maximums.-const KNOWN_MODEL_PRICING: &[ModelPrice] = &[- // ── Anthropic (authoritative prices; cache read = 0.1× input) ────────────- ModelPrice {- provider: "anthropic",- model_id: "claude-fable-5",- input_per_mtok_usd: 10.00,- cached_input_per_mtok_usd: 1.00,- output_per_mtok_usd: 50.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-opus-4-8",- input_per_mtok_usd: 5.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 25.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-opus-4-7",- input_per_mtok_usd: 5.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 25.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-opus-4-6",- input_per_mtok_usd: 5.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 25.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-opus-4-5",- input_per_mtok_usd: 5.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 25.00,- context_window: 200_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-sonnet-4-6",- input_per_mtok_usd: 3.00,- cached_input_per_mtok_usd: 0.30,- output_per_mtok_usd: 15.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-sonnet-4-5",- input_per_mtok_usd: 3.00,- cached_input_per_mtok_usd: 0.30,- output_per_mtok_usd: 15.00,- context_window: 200_000,- },- ModelPrice {- provider: "anthropic",- model_id: "claude-haiku-4-5",- input_per_mtok_usd: 1.00,- cached_input_per_mtok_usd: 0.10,- output_per_mtok_usd: 5.00,- context_window: 200_000,- },- // ── OpenAI (cache read ≈ 0.25× input — published 75% off) ────────────────- ModelPrice {- provider: "openai",- model_id: "gpt-5.5",- input_per_mtok_usd: 5.00,- cached_input_per_mtok_usd: 1.25,- output_per_mtok_usd: 30.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "openai",- model_id: "gpt-5.4",- input_per_mtok_usd: 2.50,- cached_input_per_mtok_usd: 0.625,- output_per_mtok_usd: 15.00,- context_window: 1_000_000,- },- ModelPrice {- provider: "openai",- model_id: "gpt-5.4-mini",- input_per_mtok_usd: 0.75,- cached_input_per_mtok_usd: 0.1875,- output_per_mtok_usd: 4.50,- context_window: 400_000,- },- ModelPrice {- provider: "openai",- model_id: "gpt-5.4-nano",- input_per_mtok_usd: 0.20,- cached_input_per_mtok_usd: 0.05,- output_per_mtok_usd: 1.25,- context_window: 400_000,- },- ModelPrice {- provider: "openai",- model_id: "gpt-4.1",- input_per_mtok_usd: 2.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 8.00,- context_window: 1_047_576,- },- ModelPrice {- provider: "openai",- model_id: "gpt-4.1-mini",- input_per_mtok_usd: 0.40,- cached_input_per_mtok_usd: 0.10,- output_per_mtok_usd: 1.60,- context_window: 1_047_576,- },- ModelPrice {- provider: "openai",- model_id: "o3",- input_per_mtok_usd: 2.00,- cached_input_per_mtok_usd: 0.50,- output_per_mtok_usd: 8.00,- context_window: 200_000,- },- // ── Google Gemini (cache read ≈ 0.25× input; 1M-token windows) ───────────- ModelPrice {- provider: "google",- model_id: "gemini-2.5-pro",- input_per_mtok_usd: 1.25,- cached_input_per_mtok_usd: 0.3125,- output_per_mtok_usd: 10.00,- context_window: 1_048_576,- },- ModelPrice {- provider: "google",- model_id: "gemini-2.5-flash",- input_per_mtok_usd: 0.30,- cached_input_per_mtok_usd: 0.075,- output_per_mtok_usd: 2.50,- context_window: 1_048_576,- },- ModelPrice {- provider: "google",- model_id: "gemini-2.5-flash-lite",- input_per_mtok_usd: 0.10,- cached_input_per_mtok_usd: 0.025,- output_per_mtok_usd: 0.40,- context_window: 1_048_576,- },- // ── DeepSeek (cache hit = 0.1× input, published) ─────────────────────────- ModelPrice {- provider: "deepseek",- model_id: "deepseek-chat",- input_per_mtok_usd: 0.14,- cached_input_per_mtok_usd: 0.014,- output_per_mtok_usd: 0.28,- context_window: 128_000,- },- ModelPrice {- provider: "deepseek",- model_id: "deepseek-reasoner",- input_per_mtok_usd: 0.55,- cached_input_per_mtok_usd: 0.055,- output_per_mtok_usd: 2.19,- context_window: 128_000,- },- // ── Moonshot Kimi (cache hit published) ──────────────────────────────────- ModelPrice {- provider: "moonshot",- model_id: "kimi-k2.6",- input_per_mtok_usd: 0.95,- cached_input_per_mtok_usd: 0.16,- output_per_mtok_usd: 4.00,- context_window: 256_000,- },- ModelPrice {- provider: "moonshot",- model_id: "kimi-k2.5",- input_per_mtok_usd: 0.60,- cached_input_per_mtok_usd: 0.10,- output_per_mtok_usd: 3.00,- context_window: 256_000,- },- // ── Qwen / Alibaba (cache read ≈ 0.1× input) ─────────────────────────────- ModelPrice {- provider: "qwen",- model_id: "qwen3-max",- input_per_mtok_usd: 1.20,- cached_input_per_mtok_usd: 0.12,- output_per_mtok_usd: 6.00,- context_window: 256_000,- },- ModelPrice {- provider: "qwen",- model_id: "qwen-max",- input_per_mtok_usd: 1.20,- cached_input_per_mtok_usd: 0.12,- output_per_mtok_usd: 6.00,- context_window: 256_000,- },- ModelPrice {- provider: "qwen",- model_id: "qwen-plus",- input_per_mtok_usd: 0.40,- cached_input_per_mtok_usd: 0.04,- output_per_mtok_usd: 1.20,- context_window: 256_000,- },- ModelPrice {- provider: "qwen",- model_id: "qwen-flash",- input_per_mtok_usd: 0.05,- cached_input_per_mtok_usd: 0.005,- output_per_mtok_usd: 0.40,- context_window: 256_000,- },- // ── Mistral (cache read ≈ 0.1× input) ────────────────────────────────────- ModelPrice {- provider: "mistral",- model_id: "mistral-large",- input_per_mtok_usd: 2.00,- cached_input_per_mtok_usd: 0.20,- output_per_mtok_usd: 6.00,- context_window: 128_000,- },- ModelPrice {- provider: "mistral",- model_id: "mistral-medium",- input_per_mtok_usd: 0.40,- cached_input_per_mtok_usd: 0.04,- output_per_mtok_usd: 2.00,- context_window: 128_000,- },- ModelPrice {- provider: "mistral",- model_id: "mistral-small",- input_per_mtok_usd: 0.20,- cached_input_per_mtok_usd: 0.02,- output_per_mtok_usd: 0.60,- context_window: 128_000,- },- ModelPrice {- provider: "mistral",- model_id: "codestral",- input_per_mtok_usd: 0.30,- cached_input_per_mtok_usd: 0.03,- output_per_mtok_usd: 0.90,- context_window: 256_000,- },- ModelPrice {- provider: "mistral",- model_id: "ministral-8b",- input_per_mtok_usd: 0.10,- cached_input_per_mtok_usd: 0.01,- output_per_mtok_usd: 0.10,- context_window: 128_000,- },- ModelPrice {- provider: "minimax",- model_id: "minimax-m3",- input_per_mtok_usd: 0.60,- cached_input_per_mtok_usd: 0.12,- output_per_mtok_usd: 2.40,- context_window: 1_000_000,- },- ModelPrice {- provider: "minimax",- model_id: "minimax-m2.7",- input_per_mtok_usd: 0.30,- cached_input_per_mtok_usd: 0.06,- output_per_mtok_usd: 1.20,- context_window: 204_800,- },- ModelPrice {- provider: "minimax",- model_id: "minimax-m2.7-highspeed",- input_per_mtok_usd: 0.60,- cached_input_per_mtok_usd: 0.06,- output_per_mtok_usd: 2.40,- context_window: 204_800,- },-];--/// Normalise a model string for matching: lower-case, trim, drop a trailing-/// `:tag` / `@date` decoration and a `[...]` suffix.-fn normalize(model: &str) -> String {- let mut s = model.trim().to_ascii_lowercase();- // Strip a `[1m]`-style context-window suffix.- if let Some(idx) = s.find('[') {- s.truncate(idx);- }- // Strip `:tag` (e.g. ollama-style) and `@date` (Vertex-style) decorations.- for sep in [':', '@'] {- if let Some(idx) = s.find(sep) {- s.truncate(idx);- }- }- s.trim().to_string()-}--/// Resolve a concrete model string to its catalogued row, if known.-///-/// Match order: exact canonical id → id with a leading `vendor/` segment-/// stripped → longest canonical id that is a substring of the normalised-/// request (handles dated/suffixed ids). Returns `None` for unknown models —-/// callers should fall back to a tier estimate.-pub fn lookup(model: &str) -> Option<&'static ModelPrice> {- let norm = normalize(model);- if norm.is_empty() {- return None;- }- if let Some(p) = KNOWN_MODEL_PRICING.iter().find(|p| p.model_id == norm) {- return Some(p);- }- let bare = norm.rsplit('/').next().unwrap_or(norm.as_str());- if let Some(p) = KNOWN_MODEL_PRICING.iter().find(|p| p.model_id == bare) {- return Some(p);- }- KNOWN_MODEL_PRICING- .iter()- .filter(|p| {- contains_at_boundary(&norm, p.model_id) || contains_at_boundary(bare, p.model_id)- })- .max_by_key(|p| p.model_id.len())-}--/// Whether `needle` occurs in `haystack` at a token boundary — i.e. the-/// characters immediately flanking the match are non-alphanumeric (or the string-/// ends). This keeps the longest-substring fallback matching dated/suffixed ids-/// (`gpt-5.4-mini-2026-05-01` → `gpt-5.4-mini`, flanked by `-`/string end) while-/// refusing spurious mid-token collisions for short canonical ids-/// (`proto3-chat` must NOT match the `o3` row, `solo1-7b` must NOT match `o1`).-/// A naive `contains` overmatches those and, since [`context_window_for_model`]-/// now routes windows through this catalog, that leaked a bogus 200K window-/// (issue #4249 regression guard).-fn contains_at_boundary(haystack: &str, needle: &str) -> bool {- if needle.is_empty() {- return false;- }- let bytes = haystack.as_bytes();- let mut search_from = 0;- while let Some(rel) = haystack[search_from..].find(needle) {- let start = search_from + rel;- let end = start + needle.len();- let before_ok = start == 0 || !bytes[start - 1].is_ascii_alphanumeric();- let after_ok = end == haystack.len() || !bytes[end].is_ascii_alphanumeric();- if before_ok && after_ok {- return true;- }- search_from = start + 1;- }- false-}--/// Estimate the USD cost of a single model call from catalogued per-MTok rates.-///-/// Prices the standard (cache-miss) input tokens, the cached-prefix input-/// tokens, and the output tokens separately. `cached_input_tokens` are billed at-/// the (usually cheaper) cached rate and are assumed to be a subset of-/// `input_tokens`, so the standard-rate portion is `input − cached`. Returns-/// `0.0` when the model is not catalogued (caller should treat as "unknown, not-/// free" — this is a best-effort estimate used when the provider does not report-/// a charged amount).-pub fn estimate_cost_usd(- model: &str,- input_tokens: u64,- output_tokens: u64,- cached_input_tokens: u64,-) -> f64 {- let Some(p) = lookup(model) else {- return 0.0;- };- let cached = cached_input_tokens.min(input_tokens);- let standard_input = input_tokens.saturating_sub(cached);- if p.model_id == "minimax-m3" && input_tokens <= 512_000 {- return (standard_input as f64) * 0.30 / 1_000_000.0- + (cached as f64) * 0.06 / 1_000_000.0- + (output_tokens as f64) * 1.20 / 1_000_000.0;- }- let per_tok = |mtok_rate: f64| mtok_rate / 1_000_000.0;- (standard_input as f64) * per_tok(p.input_per_mtok_usd)- + (cached as f64) * per_tok(p.cached_input_per_mtok_usd)- + (output_tokens as f64) * per_tok(p.output_per_mtok_usd)-}-/// Build a default registry, one [`ModelRegistryEntry`] per catalogued model/// with prices and context window pre-filled. Used to seed an empty/// `config.model_registry`.@@ -478,53 +28,9 @@ pub fn default_registry_entries() -> Vec<ModelRegistryEntry> {.collect()}-fn per_token(rate_per_mtok: f64) -> Option<f64> {- (rate_per_mtok > 0.0).then_some(rate_per_mtok / 1_000_000.0)-}--const VISION_INPUT_MODELS: &[&str] = &["minimax-m3"];--pub fn model_accepts_image_input(model_id: &str) -> bool {- let normalized = normalize(model_id);- let bare = normalized.rsplit('/').next().unwrap_or(normalized.as_str());- VISION_INPUT_MODELS.contains(&normalized.as_str()) || VISION_INPUT_MODELS.contains(&bare)-}--/// Project one OpenHuman catalog row into a TinyAgents model-catalog entry.-///-/// This is intentionally a pricing/window projection only. OpenHuman still-/// derives live runtime capability flags (tools, vision, streaming) from the-/// provider adapter at construction time, because the static cost catalog does-/// not yet encode those fields authoritatively for every provider/model.+/// Project an owner price row with this product catalogue source label.pub fn tinyagents_catalog_entry(price: &ModelPrice) -> tinyagents_registry::ModelCatalogEntry {- tinyagents_registry::ModelCatalogEntry {- provider: price.provider.to_string(),- model_id: price.model_id.to_string(),- aliases: Vec::new(),- mode: "chat".to_string(),- max_input_tokens: Some(u64::from(price.context_window)),- max_output_tokens: None,- deprecation_date: None,- release_date: None,- pricing: tinyagents_harness::cost::ModelPricing {- input_per_token: per_token(price.input_per_mtok_usd),- output_per_token: per_token(price.output_per_mtok_usd),- cache_read_input_per_token: per_token(price.cached_input_per_mtok_usd),- cache_creation_input_per_token: None,- input_audio_per_token: None,- output_reasoning_per_token: None,- // The local price table is flat; context-size tiers are not modeled.- tiers: Vec::new(),- },- capabilities: tinyagents_registry::ModelCapabilities {- prompt_caching: price.cached_input_per_mtok_usd > 0.0,- vision: model_accepts_image_input(price.model_id),- ..tinyagents_registry::ModelCapabilities::default()- },- source: TINYAGENTS_CATALOG_SOURCE.to_string(),- source_url: None,- raw: serde_json::json!({ "pricing_as_of": PRICING_AS_OF }),- }+ tinyagents_registry::pricing::catalog_entry(price, TINYAGENTS_CATALOG_SOURCE)}/// Source tag for local (runtime-discovered) model entries in the unifieddiff --git a/crates/openhuman-core/src/platform/cost/catalog_tests.rs b/crates/openhuman-core/src/platform/cost/catalog_tests.rsindex 2c91d33622..6e9eaa6de7 100644--- a/crates/openhuman-core/src/platform/cost/catalog_tests.rs+++ b/crates/openhuman-core/src/platform/cost/catalog_tests.rs@@ -1,65 +1,5 @@use super::*;-#[test]-fn exact_lookup_resolves_canonical_ids() {- let p = lookup("claude-opus-4-8").expect("anthropic row");- assert_eq!(p.provider, "anthropic");- assert_eq!(p.input_per_mtok_usd, 5.00);- assert_eq!(p.output_per_mtok_usd, 25.00);- assert_eq!(p.cached_input_per_mtok_usd, 0.50);- assert_eq!(p.context_window, 1_000_000);-}--#[test]-fn lookup_is_case_insensitive() {- assert_eq!(lookup("GPT-4.1").unwrap().model_id, "gpt-4.1");-}--#[test]-fn lookup_strips_vendor_prefix_openrouter_style() {- assert_eq!(- lookup("anthropic/claude-sonnet-4-6").unwrap().model_id,- "claude-sonnet-4-6"- );- assert_eq!(- lookup("deepseek/deepseek-chat").unwrap().model_id,- "deepseek-chat"- );- assert_eq!(lookup("qwen/qwen3-max").unwrap().model_id, "qwen3-max");-}--#[test]-fn lookup_strips_context_and_tag_decorations() {- assert_eq!(- lookup("claude-opus-4-8[1m]").unwrap().model_id,- "claude-opus-4-8"- );- assert_eq!(lookup("kimi-k2.6:turbo").unwrap().model_id, "kimi-k2.6");- assert_eq!(- lookup("claude-opus-4-5@20251101").unwrap().model_id,- "claude-opus-4-5"- );-}--#[test]-fn lookup_longest_substring_wins_for_suffixed_ids() {- // A dated/suffixed id should resolve to the most specific row.- assert_eq!(- lookup("gpt-5.4-mini-2026-05-01").unwrap().model_id,- "gpt-5.4-mini"- );-}--#[test]-fn lookup_returns_none_for_unknown() {- assert!(lookup("totally-made-up-model").is_none());- assert!(lookup("").is_none());- assert!(- lookup("agentic-v1").is_none(),- "abstract tiers aren't vendor models"- );-}-#[test]fn default_registry_entries_are_fully_populated() {let entries = default_registry_entries();@@ -178,78 +118,6 @@ fn enrich_unknown_model_is_noop() {assert_eq!(e.context_window, 0);}-#[test]-fn every_row_has_sane_values() {- for p in KNOWN_MODEL_PRICING {- assert!(p.input_per_mtok_usd > 0.0, "{}", p.model_id);- assert!(p.output_per_mtok_usd > 0.0, "{}", p.model_id);- assert!(p.context_window > 0, "{}", p.model_id);- assert!(- p.cached_input_per_mtok_usd <= p.input_per_mtok_usd,- "{} cached should not exceed input",- p.model_id- );- }-}--// ── estimate_cost_usd (issue #4249, Phase 5 — the $0-cost turn fix) ──────--fn approx(a: f64, b: f64) {- assert!((a - b).abs() < 1e-9, "expected {b}, got {a}");-}--#[test]-fn estimate_prices_standard_input_and_output() {- // opus-4-8: $5/$25 per MTok in/out. 1M in + 1M out, no cache.- approx(- estimate_cost_usd("claude-opus-4-8", 1_000_000, 1_000_000, 0),- 30.00,- );-}--#[test]-fn estimate_bills_cached_prefix_at_the_cheaper_rate() {- // Fully cached input (cached == input) → cached rate only ($0.50/MTok).- approx(- estimate_cost_usd("claude-opus-4-8", 1_000_000, 0, 1_000_000),- 0.50,- );- // Half cached: 0.5M standard @ $5 + 0.5M cached @ $0.50 = 2.50 + 0.25.- approx(- estimate_cost_usd("claude-opus-4-8", 1_000_000, 0, 500_000),- 2.75,- );-}--#[test]-fn estimate_clamps_cached_to_input() {- // cached_input_tokens > input_tokens must not underflow or overcharge:- // it is clamped to input, so this is billed as fully cached.- approx(- estimate_cost_usd("claude-opus-4-8", 1_000_000, 0, 5_000_000),- 0.50,- );-}--#[test]-fn estimate_returns_zero_for_uncatalogued_models() {- // "unknown, not free" — the caller treats 0.0 as no estimate available.- assert_eq!(- estimate_cost_usd("totally-made-up-model", 1_000_000, 1_000_000, 0),- 0.0- );-}--#[test]-fn estimate_resolves_decorated_model_ids() {- // The catalog lookup normalizes tags/suffixes, so a decorated id- // (e.g. the runtime "[1m]" window tag) still prices correctly.- approx(- estimate_cost_usd("claude-opus-4-8[1m]", 1_000_000, 0, 0),- 5.00,- );-}-#[test]fn minimax_rows_and_vision_normalization() {assert_eq!(@@ -268,12 +136,6 @@ fn minimax_rows_and_vision_normalization() {.any(|entry| entry.id == "minimax-m3" && entry.vision));}-#[test]-fn minimax_m3_uses_standard_tier_through_512k() {- approx(estimate_cost_usd("minimax-m3", 512_000, 0, 0), 0.1536);- approx(estimate_cost_usd("minimax-m3", 512_001, 0, 0), 0.3072006);-}-#[test]fn enrich_backfills_minimax_vision() {let mut entry = ModelRegistryEntry {diff --git a/crates/openhuman-core/src/platform/cost/global.rs b/crates/openhuman-core/src/platform/cost/global.rsindex 3adc797d11..659f2b20b8 100644--- a/crates/openhuman-core/src/platform/cost/global.rs+++ b/crates/openhuman-core/src/platform/cost/global.rs@@ -275,7 +275,7 @@ pub(super) fn build_token_usage(model: &str, usage: &BilledUsage) -> Option<Toke/// `"<provider>/<model>"` model key so it matches the embedding `CostRecord`/// shape used elsewhere (e.g. `voyage/voyage-3`).///-/// Pricing resolution: [`catalog::estimate_cost_usd`] prices `input_tokens` at+/// Pricing resolution: [`tinyagents_registry::pricing::estimate_cost_usd`] prices `input_tokens` at/// the catalogued per-token input rate. Embedding models are frequently **not**/// in the pricing catalog; in that case `estimate_cost_usd` returns `0.0` and/// we record the usage with **zero** cost (and log it) rather than fabricating a@@ -304,7 +304,7 @@ pub fn record_embedding_usage();return;};- let cost_usd = super::catalog::estimate_cost_usd(model, input_tokens, 0, 0);+ let cost_usd = tinyagents_registry::pricing::estimate_cost_usd(model, input_tokens, 0, 0);if cost_usd == 0.0 {log::debug!("[cost][embed] no catalog embedding rate for model={model}; recording usage with \diff --git a/crates/openhuman-core/src/platform/cost/report.rs b/crates/openhuman-core/src/platform/cost/report.rsindex ce3e8c4dbc..deec92d60f 100644--- a/crates/openhuman-core/src/platform/cost/report.rs+++ b/crates/openhuman-core/src/platform/cost/report.rs@@ -364,8 +364,13 @@ pub fn build_cache_report(}// Through the tier-aware estimator: what this call's input cost against// what it would have cost had every input token been cached.- let actual = super::catalog::estimate_cost_usd(&usage.model, usage.input_tokens, 0, cached);- let all_cached = super::catalog::estimate_cost_usd(+ let actual = tinyagents_registry::pricing::estimate_cost_usd(+ &usage.model,+ usage.input_tokens,+ 0,+ cached,+ );+ let all_cached = tinyagents_registry::pricing::estimate_cost_usd(&usage.model,usage.input_tokens,0,diff --git a/crates/openhuman-core/src/platform/cost/report_tests.rs b/crates/openhuman-core/src/platform/cost/report_tests.rsindex 6668596bf5..aa5c6173d5 100644--- a/crates/openhuman-core/src/platform/cost/report_tests.rs+++ b/crates/openhuman-core/src/platform/cost/report_tests.rs@@ -228,7 +228,7 @@ fn cache_report_prices_the_uncached_premium_for_known_models() {true,)];let report = build_cache_report(&records, from, to, &ReportFilter::default());- let price = crate::platform::cost::catalog::lookup("anthropic/claude-sonnet-4-5");+ let price = tinyagents_registry::pricing::lookup("anthropic/claude-sonnet-4-5");match price {Some(p) => assert!((report.uncached_premium_usd - (p.input_per_mtok_usd - p.cached_input_per_mtok_usd))