Watch
0
0
Fork
You've already forked hyperhive
0

swarm: a soft context limit per agent, as a percent of the window, applied at turn end

This commit is contained in:
damocles 2026-11-15 15:13:50 +01:00 • committed by mara
commit 1e03979836

View file

@ -8,6 +8,14 @@ pub use swarm_wire::agent_inference::{Effort, Source};
/// typo rather than a cap.
pub const MAX_SUBAGENTS: u32 = 32;
/// The lowest `soft_context_percent` a `PUT` may set. Below it the system
/// prompt and tools alone approach the mark on a large window, so every turn
/// would compact.
pub const MIN_SOFT_CONTEXT_PERCENT: u8 = 5;
/// The highest `soft_context_percent` a `PUT` may set: the whole window.
pub const MAX_SOFT_CONTEXT_PERCENT: u8 = 100;
/// One agent's inference settings. An absent field is not set at swarm level,
/// and the agent keeps its own value for it.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
@ -28,6 +36,12 @@ pub struct InferenceSettings {
/// subagents) to [`MAX_SUBAGENTS`]. Absent is no cap.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub max_subagents: Option<u32>,
/// The percent of the model's context window at which the agent compacts
/// at the end of a turn, from [`MIN_SOFT_CONTEXT_PERCENT`] to
/// [`MAX_SOFT_CONTEXT_PERCENT`]. A soft limit: a turn can run past it.
/// Absent keeps the harness's own watermark.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub soft_context_percent: Option<u8>,
}
/// What `GET` answers for one agent.
@ -72,8 +86,9 @@ mod tests {
effort: Some(Effort::Xhigh),
subagent_models: Some(vec!["haiku".to_owned()]),
max_subagents: Some(3),
soft_context_percent: Some(20),
},
r#"{"model":"opus","effort":"xhigh","subagent_models":["haiku"],"max_subagents":3}"#,
r#"{"model":"opus","effort":"xhigh","subagent_models":["haiku"],"max_subagents":3,"soft_context_percent":20}"#,
),
] {
assert_eq!(serde_json::to_string(&value).unwrap(), wire);