swarm: set the fresh-session threshold per agent
This commit is contained in:
parent
49ee678117
commit
5175d3663e
1 changed files with 154 additions and 32 deletions
|
|
@ -218,6 +218,11 @@ pub struct Bus {
|
|||
/// compaction policy compacts at it instead of the harness's own
|
||||
/// watermark. `None` until the swarm sets one.
|
||||
soft_context_percent: Arc<Mutex<Option<u8>>>,
|
||||
/// The swarm's fresh-session threshold, as a percent of the context window
|
||||
/// (`fresh_session_percent` of the agent's `agent-inference` key): above it, a
|
||||
/// turn that finds the prompt cache cold starts a fresh session. `None`
|
||||
/// until the swarm sets one, which keeps the harness's own half.
|
||||
fresh_session_percent: Arc<Mutex<Option<u8>>>,
|
||||
/// Resolved model id from the most recent turn's `assistant` events
|
||||
/// (the API-echoed `message.model`, e.g. `claude-opus-4-8`), as
|
||||
/// opposed to the requested `--model` name which may be a short
|
||||
|
|
@ -261,6 +266,7 @@ impl Bus {
|
|||
last_turn_ended_unix: Arc::new(AtomicI64::new(0)),
|
||||
api_context_window: Arc::new(Mutex::new(None)),
|
||||
soft_context_percent: Arc::new(Mutex::new(None)),
|
||||
fresh_session_percent: Arc::new(Mutex::new(None)),
|
||||
last_resolved_model: Arc::new(Mutex::new(None)),
|
||||
}
|
||||
}
|
||||
|
|
@ -530,6 +536,17 @@ impl Bus {
|
|||
*self.soft_context_percent.lock().unwrap()
|
||||
}
|
||||
|
||||
/// Set (or clear, with `None`) the swarm's fresh-session threshold.
|
||||
pub fn set_fresh_session_percent(&self, percent: Option<u8>) {
|
||||
*self.fresh_session_percent.lock().unwrap() = percent;
|
||||
}
|
||||
|
||||
/// The swarm's fresh-session threshold, as a percent of the window.
|
||||
#[must_use]
|
||||
pub fn fresh_session_percent(&self) -> Option<u8> {
|
||||
*self.fresh_session_percent.lock().unwrap()
|
||||
}
|
||||
|
||||
/// Walk a stream-json value for `tool_use` blocks and bump the
|
||||
/// per-turn counter for each one we find. Called by the stdout
|
||||
/// pump on every parsed line. Cheap when the line isn't an
|
||||
|
|
|
|||
Loading…
Reference in a new issue