Skip to content

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

refactor(tinyagents): extract turn context middleware

Steven Enamakeld9e0cb147a93
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
index 3a795510f4..32a7b67b86 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/turn_context.rs
@@ -91,6 +91,11 @@ pub(crate) struct TranscriptSnapshot {
pub(crate) input_tokens: u64,
pub(crate) output_tokens: u64,
pub(crate) cached_input_tokens: u64,
+ /// Input and output tokens of the newest answered call alone. The fields
+ /// above sum every call, so they measure spend; these measure how full the
+ /// context window was, which is what the context gauge shows.
+ pub(crate) last_call_input_tokens: u64,
+ pub(crate) last_call_output_tokens: u64,
/// Provider-reported cost where available, otherwise the host's per-call
/// estimate. This covers only model calls the provider answered.
pub(crate) charged_amount_usd: f64,