Skip to content

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

chore(tinyagents): add prompt-size and cache summary logging

Steven Enamakelfd1924e3ffcd
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
index 17eab99dfe..7b5c8de994 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
@@ -247,6 +247,28 @@ pub(super) async fn finalize_turn_outcome(
subagent = subagent_scope.is_some(),
"[tinyagents] persisting post-request transcript (shared path; steer-safe boundary)"
);
+ // Prompt-size and cache summary for the turn (grep `turn prompt summary`):
+ // the frozen system prefix in bytes, per tier segment, beside the token
+ // counts the provider reported. `cached_input_tokens` rising to roughly
+ // the prefix on turn 2 is what a working prefix cache looks like.
+ let system_segment_bytes: Vec<usize> = run
+ .messages
+ .iter()
+ .take_while(|message| matches!(message, tinyinference_llm::Message::System(_)))
+ .map(|message| message.text().len())
+ .collect();
+ tracing::info!(
+ model,
+ system_segments = system_segment_bytes.len(),
+ system_bytes = system_segment_bytes.iter().sum::<usize>(),
+ ?system_segment_bytes,
+ model_calls = run.model_calls,
+ tool_calls = run.tool_calls,
+ input_tokens,
+ cached_input_tokens,
+ output_tokens,
+ "[tinyagents] turn prompt summary"
+ );
TinyagentsTurnOutcome {
text,