The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(agent): expose compression policy as a public function
Steven Enamakelbad0650edd10
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder.rs b/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder.rsindex aa14a3682d..9d96865163 100644--- a/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder.rs+++ b/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder.rs@@ -38,6 +38,12 @@ impl CapturedOutcomes for OutcomeSinkSource {}}+/// The compression policy for a model with a `window`-token context: the+/// default threshold, for now unchanged.+pub(super) fn compression_policy(window: u64) -> tinyagents_harness::summarization::SummarizationPolicy {+ tinyagents_harness::summarization::summarization_policy(window)+}+/// Push the context ladder onto `harness` and return the two handles the run/// loop reads after the drive future returns: the installed compression/// middleware (to drain its provenance records), and the wrap-up middleware's@@ -88,7 +94,7 @@ pub(super) fn install_context_ladder(let mut compression_mw: Option<Arc<ContextCompressionMiddleware>> = None;if let Some(window) = context_window.filter(|w| *w > 0) {if autocompact_enabled {- let policy = tinyagents_harness::summarization::summarization_policy(window);+ let policy = compression_policy(window);// Wrap the LLM-backed summarizer in a fault-tolerant, per-turn-caching// adapter (issue #4461): a summarizer failure must no longer abort the// turn (warn + circuit-breaker + deterministic trim instead), and an@@ -227,3 +233,7 @@ pub(super) fn install_context_ladder((compression_mw, wrap_up_fired)}++#[cfg(test)]+#[path = "harness_context_ladder_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder_tests.rs b/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder_tests.rsnew file mode 100644index 0000000000..9815611729--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/harness_context_ladder_tests.rs@@ -0,0 +1,16 @@+use super::*;++/// Issue #6960: a compaction that fires mid-turn must keep the turn's+/// assignment verbatim and size its tail in tokens, not by message count.+#[test]+fn compression_policy_keeps_a_token_tail_and_pins_the_turn_user_message() {+ let policy = compression_policy(200_000);++ assert_eq!(policy.context_window, Some(200_000));+ assert_eq!(+ policy.threshold_fraction,+ tinyagents_harness::summarization::DEFAULT_SUMMARIZE_THRESHOLD_FRACTION+ );+ assert_eq!(policy.keep_recent_tokens, Some(60_000));+ assert!(policy.pin_turn_user_message);+}