Skip to content

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

fix(subagent_host): backfill response usage from message usage

Steven Enamakelcc15653bc2c7
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
index f4b09aa1db..840e965141 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/checkpoint.rs
@@ -2,7 +2,6 @@
use crate::inference::provider::BilledUsage;
use std::sync::{Arc, Mutex};
-use tinyagents_harness::ids::CallId;
use tinyagents_harness::summarization::CapToolResult;
use tinyagents_orchestration::subagent::{summarize_at_cap, CapSummaryModel};
use tinyinference_llm::message::Message;
@@ -71,7 +70,13 @@ impl CapSummaryModel for HostCapSummaryModel<'_> {
.as_ref()
.map(|trace| (trace.clone(), trace.begin(&self.checkpoint.model)));
match self.checkpoint.chat_model.invoke(&(), request).await {
- Ok(response) => {
+ Ok(mut response) => {
+ // Direct ChatModel invocation skips the normal stream adapter's
+ // response normalization. Keep the product fold and native trace
+ // on the same message-level usage when providers only fill it there.
+ if response.usage.is_none() {
+ response.usage = response.message.usage;
+ }
if let Some((trace, (call_id, started_at_ms))) = trace_call {
trace.completed(
call_id,