Skip to content

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

chore(embed): re-export SESSION_EXPIRES_AT_META from security module

Steven Enamakelf471a809b0c2
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rs
index 574b7b8880..10e9a4b636 100644
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@ -252,6 +252,7 @@ pub mod security {
build_session_state, classify_session_token, current_session_is_local,
get_session_token, is_local_session_token, load_app_session_profile, publish_local_session_expiry,
resolve_backend_credential, BackendCredential, SessionTokenCheck,
+ SESSION_EXPIRES_AT_META,
LOCAL_SESSION_BACKEND_UNAVAILABLE, LOCAL_SESSION_MANAGED_INFERENCE_UNAVAILABLE,
};
}
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs
new file mode 100644
index 0000000000..bfb8a428c4
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs
@@ -0,0 +1,23 @@
+use super::*;
+use tinyinference_llm::message::Message;
+
+#[test]
+fn with_thread_id_injects_explicit_thread() {
+ let request = ModelRequest::new(vec![Message::user("hi")]);
+ let updated = with_thread_id(request, Some("thread-42"));
+ assert_eq!(
+ updated.provider_options["thread_id"],
+ serde_json::json!("thread-42")
+ );
+}
+
+#[test]
+fn an_explicit_reasoning_option_is_left_alone() {
+ let request = ModelRequest::new(vec![Message::user("hi")])
+ .with_provider_options(serde_json::json!({ "reasoning": { "effort": "high" } }));
+ let updated = apply_reasoning_hint(request);
+ assert_eq!(
+ updated.provider_options["reasoning"],
+ serde_json::json!({ "effort": "high" })
+ );
+}
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_usage_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_usage_tests.rs
new file mode 100644
index 0000000000..de41e8f930
--- /dev/null
+++ b/crates/openhuman-tinyhumans/src/inference/managed_usage_tests.rs
@@ -0,0 +1,95 @@
+use super::*;
+use tinyinference_llm::model::ModelResponse;
+use tinyinference_llm::usage::recover_usage;
+
+/// The managed `openhuman.{billing,usage}` envelope on `raw` must re-project
+/// into the host `BilledUsage` the cost bridge reads — charged USD, cached
+/// tokens, and context window — exactly as the legacy legacy model-adapter path did.
+#[test]
+fn project_managed_usage_recovers_charged_and_cached() {
+ use tinyinference_llm::message::AssistantMessage;
+ use tinyinference_llm::usage::Usage;
+
+ let raw = serde_json::json!({
+ "openhuman": {
+ "usage": { "cached_input_tokens": 128, "context_window": 200000 },
+ "billing": { "charged_amount_usd": 0.0042 }
+ }
+ });
+ let response = ModelResponse {
+ message: AssistantMessage {
+ id: None,
+ content: vec![],
+ tool_calls: vec![],
+ usage: None,
+ origin: None,
+ },
+ usage: Some(Usage {
+ input_tokens: 1000,
+ output_tokens: 50,
+ ..Usage::default()
+ }),
+ finish_reason: None,
+ raw: Some(raw),
+ resolved_model: None,
+ continue_turn: None,
+ served_from_cache: false,
+ correlation: None,
+ resolved_route: None,
+ };
+
+ let projected = project_managed_usage(response);
+ let recovered = recover_usage(&projected).expect("usage recovered");
+ let charged = recovered.charged_amount_usd.expect("charge recovered");
+ assert!((charged - 0.0042).abs() < 1e-9, "charged={charged}");
+ assert_eq!(
+ recovered.usage.cache_read_tokens, 128,
+ "cached tokens backfilled"
+ );
+ assert_eq!(recovered.context_window, 200_000);
+ assert_eq!(recovered.usage.input_tokens, 1000);
+ assert_eq!(recovered.usage.output_tokens, 50);
+}
+
+/// A response with no `openhuman` envelope stays untouched — no meta key, no
+/// charged USD — so non-managed/billing-free responses aren't fabricated.
+#[test]
+fn project_managed_usage_is_noop_without_envelope() {
+ use tinyinference_llm::message::AssistantMessage;
+ use tinyinference_llm::usage::Usage;
+
+ let response = ModelResponse {
+ message: AssistantMessage {
+ id: None,
+ content: vec![],
+ tool_calls: vec![],
+ usage: None,
+ origin: None,
+ },
+ usage: Some(Usage {
+ input_tokens: 10,
+ output_tokens: 5,
+ cache_read_tokens: 3,
+ ..Usage::default()
+ }),
+ finish_reason: None,
+ raw: Some(serde_json::json!({ "id": "resp_1" })),
+ resolved_model: None,
+ continue_turn: None,
+ served_from_cache: false,
+ correlation: None,
+ resolved_route: None,
+ };
+
+ let projected = project_managed_usage(response);
+ // raw keeps only the wire fields — no meta key injected.
+ assert!(projected
+ .raw
+ .as_ref()
+ .unwrap()
+ .get("openhuman_usage_meta")
+ .is_none());
+ let recovered = recover_usage(&projected).expect("usage present");
+ assert_eq!(recovered.charged_amount_usd, None);
+ assert_eq!(recovered.usage.cache_read_tokens, 3, "crate cached preserved");
+}