Skip to content

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

docs(tinyagents): clarify idle fold tail cap and test intent

Steven Enamakel43d1a7e2b52b
diff --git a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
index cb2a00ed03..d69ae074ac 100644
--- a/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/context_wiring.rs
@@ -247,7 +247,8 @@ pub(crate) struct IdleFold<'a> {
/// The caller's threshold: the conversation is at least this large.
pub(crate) min_tokens: u64,
/// The verbatim tail in tokens; `None` sizes it as a turn would against
- /// a `min_tokens` trigger.
+ /// a `min_tokens` trigger. Either way the policy caps it at half of
+ /// `min_tokens`, as it caps a turn's tail at half its trigger.
pub(crate) keep_recent_tokens: Option<u64>,
/// `[context] compaction_strategy`.
pub(crate) strategy: crate::config::CompactionStrategy,
diff --git a/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs b/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
index b5b73a65a2..c4011df70d 100644
--- a/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/context_wiring_tests.rs
@@ -273,14 +273,17 @@ async fn an_idle_fold_puts_the_summary_after_the_system_prompt() {
assert_eq!(summarizer_model.requests().len(), 1);
}
-/// A tail that covers the whole conversation leaves nothing to fold.
+/// A conversation of one message leaves nothing older than the tail to fold.
#[tokio::test]
async fn an_idle_fold_with_nothing_old_enough_returns_none() {
use tinyagents_harness::testkit::ScriptedModel;
let summarizer_model = Arc::new(ScriptedModel::replies(vec!["unused"]));
let folded = compact_history(
- &idle_history(),
+ &[
+ Message::system("system prompt"),
+ Message::user(format!("only ask: {}", "detail ".repeat(200))),
+ ],
IdleFold {
min_tokens: 100,
keep_recent_tokens: Some(1_000_000),