Skip to content

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

test(storage): cover cached input tokens and claim ttl renewal

Steven Enamakel6d01c6c3e217
diff --git a/crates/openhuman-core/src/storage/import/sessions_tests.rs b/crates/openhuman-core/src/storage/import/sessions_tests.rs
index 1003725177..0fcbd2637c 100644
--- a/crates/openhuman-core/src/storage/import/sessions_tests.rs
+++ b/crates/openhuman-core/src/storage/import/sessions_tests.rs
@@ -58,7 +58,7 @@ fn host_jsonl_reader_preserves_meta_usage_typed_rows_and_tool_state() {
concat!(
"{\"_meta\":{\"agent\":\"Orchestrator\",\"agent_id\":\"orchestrator\",\"dispatcher\":\"native\",\"created\":\"2026-01-01T00:00:00Z\",\"updated\":\"2026-01-02T00:00:00Z\",\"turn_count\":2,\"input_tokens\":7,\"output_tokens\":3,\"cached_input_tokens\":1,\"charged_amount_usd\":0.25,\"thread_id\":\"thread\"}}\n",
"{\"kind\":\"tools\",\"tools\":[{\"name\":\"lookup\"}]}\n",
- "{\"role\":\"assistant\",\"content\":\"answer\",\"provider\":\"local\",\"model\":\"m1\",\"usage\":{\"input\":7,\"output\":3,\"cost_usd\":0.25},\"ts\":\"2026-01-02T00:00:00Z\",\"request_id\":\"r1\",\"iteration\":2}\n",
+ "{\"role\":\"assistant\",\"content\":\"answer\",\"provider\":\"local\",\"model\":\"m1\",\"usage\":{\"input\":7,\"output\":3,\"cached_input\":1,\"cost_usd\":0.25},\"ts\":\"2026-01-02T00:00:00Z\",\"request_id\":\"r1\",\"iteration\":2}\n",
"{\"role\":\"user\",\"content\":\"old envelope\",\"tool_call_id\":\"call-1\"}\n"
),
)
diff --git a/crates/openhuman-core/src/storage/import_state_tests.rs b/crates/openhuman-core/src/storage/import_state_tests.rs
index f88d99a584..bbc3b3124e 100644
--- a/crates/openhuman-core/src/storage/import_state_tests.rs
+++ b/crates/openhuman-core/src/storage/import_state_tests.rs
@@ -242,14 +242,13 @@ fn a_waiting_process_runs_once_the_holder_releases() {
#[cfg(feature = "storage-sqlite")]
fn a_long_import_keeps_its_claim_alive() {
let (_dir, _backend, repo) = sqlite_repo();
- let now = chrono::Utc::now().timestamp_millis();
let rival_repo = repo.clone();
- let rival_ran = with_claim_at(&repo, OWNER, "m", now, 90, |_| {
+ let rival_ran = with_claim_ttl(&repo, OWNER, "m", 1_000, |_| {
let mut took_over = false;
- for _ in 0..8 {
+ for _ in 0..26 {
std::thread::sleep(Duration::from_millis(50));
let at = chrono::Utc::now().timestamp_millis();
- took_over |= with_claim_at(&rival_repo, OWNER, "m", at, 90, |_| Ok(()))
+ took_over |= with_claim_at(&rival_repo, OWNER, "m", at, 1_000, |_| Ok(()))
.unwrap()
.is_some();
}