Watch
0
0
Fork
You've already forked hyperhive
0

swarm: set the fresh-session threshold per agent

This commit is contained in:
iris 2026-11-16 10:50:13 +01:00
commit 5175d3663e

View file

@ -54,6 +54,11 @@ pub struct AgentInference {
/// in place of the harness's own watermark. `None` keeps the harness's.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub soft_context_percent: Option<u8>,
/// The percent of the model's context window above which a turn that finds
/// the prompt cache cold starts a fresh session instead of resuming. `None`
/// keeps the harness's own half.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub fresh_session_percent: Option<u8>,
}
/// A claude `--effort` level, ascending.
@ -147,11 +152,12 @@ mod tests {
subagent_models: Some(vec!["haiku".to_owned(), "sonnet".to_owned()]),
max_subagents: Some(3),
soft_context_percent: Some(20),
fresh_session_percent: Some(10),
};
let encoded = serde_json::to_string(&value).unwrap();
assert_eq!(
encoded,
r#"{"model":"opus","effort":"xhigh","subagent_models":["haiku","sonnet"],"max_subagents":3,"soft_context_percent":20}"#
r#"{"model":"opus","effort":"xhigh","subagent_models":["haiku","sonnet"],"max_subagents":3,"soft_context_percent":20,"fresh_session_percent":10}"#
);
assert_eq!(
serde_json::from_str::<AgentInference>(&encoded).unwrap(),
@ -176,8 +182,8 @@ mod tests {
);
}
/// A value written before `max_subagents` or `soft_context_percent`
/// existed decodes with neither set.
/// A value written before `max_subagents`, `soft_context_percent` or
/// `fresh_session_percent` existed decodes with none set.
#[test]
fn a_value_without_the_caps_has_neither_set() {
let decoded: AgentInference =
@ -185,6 +191,7 @@ mod tests {
.unwrap();
assert_eq!(decoded.max_subagents, None);
assert_eq!(decoded.soft_context_percent, None);
assert_eq!(decoded.fresh_session_percent, None);
assert_eq!(decoded.model.as_deref(), Some("opus"));
}