swarm: set the fresh-session threshold per agent
This commit is contained in:
parent
49ee678117
commit
5175d3663e
2 changed files with 154 additions and 32 deletions
|
|
@ -37,6 +37,7 @@ impl SetFlags {
|
|||
subagent_models: self.subagent_models.or(current.subagent_models),
|
||||
max_subagents: current.max_subagents,
|
||||
soft_context_percent: current.soft_context_percent,
|
||||
fresh_session_percent: current.fresh_session_percent,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +132,7 @@ fn render_configured(s: Option<&InferenceSettings>) -> String {
|
|||
fn render(s: &InferenceSettings) -> String {
|
||||
const UNSET: &str = "(not set; the agent's own)";
|
||||
format!(
|
||||
"model: {}\neffort: {}\nsubagent_models: {}\nmax_subagents: {}\nsoft_context_percent: {}\n",
|
||||
"model: {}\neffort: {}\nsubagent_models: {}\nmax_subagents: {}\nsoft_context_percent: {}\nfresh_session_percent: {}\n",
|
||||
s.model.as_deref().unwrap_or(UNSET),
|
||||
s.effort.map_or(UNSET, Effort::as_str),
|
||||
s.subagent_models
|
||||
|
|
@ -142,6 +143,10 @@ fn render(s: &InferenceSettings) -> String {
|
|||
s.soft_context_percent.map_or_else(
|
||||
|| "(not set; the harness's own watermark)".to_owned(),
|
||||
|n| format!("{n}%")
|
||||
),
|
||||
s.fresh_session_percent.map_or_else(
|
||||
|| "(not set; the harness's own half)".to_owned(),
|
||||
|n| format!("{n}%")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -203,12 +208,14 @@ mod tests {
|
|||
assert_eq!(merged.effort, Some(Effort::High));
|
||||
}
|
||||
|
||||
/// `set` has no flag for the cap or the soft limit, and stored ones
|
||||
/// survive it.
|
||||
/// `set` has no flag for the cap or the two context limits, and stored
|
||||
/// ones survive it.
|
||||
#[test]
|
||||
fn set_keeps_the_stored_cap_and_soft_limit() {
|
||||
let current: InferenceSettings =
|
||||
serde_json::from_str(r#"{"max_subagents":3,"soft_context_percent":20}"#).unwrap();
|
||||
fn set_keeps_the_stored_cap_and_context_limits() {
|
||||
let current: InferenceSettings = serde_json::from_str(
|
||||
r#"{"max_subagents":3,"soft_context_percent":20,"fresh_session_percent":10}"#,
|
||||
)
|
||||
.unwrap();
|
||||
let merged = SetFlags {
|
||||
model: Some("opus".to_owned()),
|
||||
..flags()
|
||||
|
|
@ -217,6 +224,7 @@ mod tests {
|
|||
.unwrap();
|
||||
assert_eq!(merged.max_subagents, Some(3));
|
||||
assert_eq!(merged.soft_context_percent, Some(20));
|
||||
assert_eq!(merged.fresh_session_percent, Some(10));
|
||||
}
|
||||
|
||||
/// An effort the controller would answer 422 for fails before the request.
|
||||
|
|
@ -267,16 +275,17 @@ mod tests {
|
|||
serde_json::from_str(r#"{"configured":{},"effective":null}"#).unwrap();
|
||||
assert_eq!(
|
||||
render_configured(empty.configured.as_ref()).lines().count(),
|
||||
5
|
||||
6
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_value_renders_every_field_as_unset() {
|
||||
let row = render(&serde_json::from_str("{}").unwrap());
|
||||
assert_eq!(row.lines().count(), 5);
|
||||
assert_eq!(row.lines().count(), 6);
|
||||
assert!(
|
||||
row.ends_with("soft_context_percent: (not set; the harness's own watermark)\n"),
|
||||
row.contains("soft_context_percent: (not set; the harness's own watermark)\n")
|
||||
&& row.ends_with("fresh_session_percent: (not set; the harness's own half)\n"),
|
||||
"{row}"
|
||||
);
|
||||
assert!(row.contains("max_subagents: (not set; no cap)\n"), "{row}");
|
||||
|
|
|
|||
|
|
@ -386,13 +386,14 @@ enum AgentVerb {
|
|||
/// show what it last did. Fails when the swarm has never heard from the
|
||||
/// agent.
|
||||
Watch(AgentWatchArgs),
|
||||
/// Show the model, effort, subagent models, subagent cap and soft context
|
||||
/// limit the swarm sets for an agent, or change the model, effort and
|
||||
/// Show the model, effort, subagent models, subagent cap and the two context
|
||||
/// limits the swarm sets for an agent, or change the model, effort and
|
||||
/// subagent models.
|
||||
///
|
||||
/// `get` prints the subagent cap (`max_subagents`) and the soft context
|
||||
/// limit (`soft_context_percent`); `set` has no flag for them and keeps
|
||||
/// stored ones. Only swarm-ui sets them.
|
||||
/// `get` prints the subagent cap (`max_subagents`), the soft context limit
|
||||
/// (`soft_context_percent`) and the fresh-session threshold
|
||||
/// (`fresh_session_percent`); `set` has no flag for them and keeps stored
|
||||
/// ones. Only swarm-ui sets them.
|
||||
///
|
||||
/// A field the swarm sets wins over the agent's own value (its agent.nix
|
||||
/// or a `hyperhive-model`/`hyperhive-effort` file) from its next turn on;
|
||||
|
|
|
|||
Loading…
Reference in a new issue