Skip to content

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

fix(threads): skip tool-call rows when tracking last spend

Steven Enamakel2698293d1c2b
diff --git a/crates/openhuman-core/src/threads/ops/usage.rs b/crates/openhuman-core/src/threads/ops/usage.rs
index eed05c4395..1ad3802e58 100644
--- a/crates/openhuman-core/src/threads/ops/usage.rs
+++ b/crates/openhuman-core/src/threads/ops/usage.rs
@@ -95,7 +95,8 @@ pub(super) fn transcript_spend(transcript: &SessionTranscript) -> TranscriptSpen
// A text-dialect tool round's issuing row carries a provenance-only
// record (its calls, zero spend); the turn's spend is on its final row.
// It is not a turn that spent, and must not become the "last" one.
- if usage.usage.input == 0
+ if !usage.tool_calls.is_empty()
+ && usage.usage.input == 0
&& usage.usage.output == 0
&& usage.usage.cached_input == 0
&& usage.usage.cost_usd == 0.0