The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(agent_chat): apply turn overrides when compacting a thread
Steven Enamakeld384c912f667
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/compact.rs b/crates/openhuman-core/src/agent_runs/agent_chat/compact.rsindex a0c4a70015..cf38dbfd8a 100644--- a/crates/openhuman-core/src/agent_runs/agent_chat/compact.rs+++ b/crates/openhuman-core/src/agent_runs/agent_chat/compact.rs@@ -3,13 +3,14 @@use crate::agent::session_host::{CompactOptions, CompactOutcome};use crate::config::Config;-use super::session_turn::{build_turn_agent, AgentChatTarget};+use super::session_turn::{apply_turn_overrides, build_turn_agent, AgentChatTarget};/// Compact `thread_id`'s stored conversation on `target`'s session now, so/// its next turn resends a summary instead of the full history.///-/// The session is built and bound exactly as [`agent_chat_for`]-/// (super::agent_chat_for) builds a turn's, so the compaction addresses the+/// `model_override`, `temperature` and `route` are applied to `config` as a+/// turn applies them, and the session is built and bound exactly as+/// [`agent_chat_for`](super::agent_chat_for) builds a turn's, so the compaction addresses the/// transcript that turn would resume and holds the same per-session turn/// lock. See [`OpenHumanSessionHost::compact_bound_history`]/// (crate::agent::OpenHumanSessionHost::compact_bound_history).@@ -21,14 +22,19 @@ use super::session_turn::{build_turn_agent, AgentChatTarget};////// When `thread_id` is blank, the session cannot be built, or the compaction/// fails.+#[allow(clippy::too_many_arguments)]#[inline(never)]pub fn compact_thread_for<'a>(- config: &'a Config,+ config: &'a mut Config,target: AgentChatTarget<'a>,thread_id: &'a str,+ model_override: Option<String>,+ temperature: Option<f64>,+ route: Option<crate::config::schema::EphemeralRoute>,options: CompactOptions,) -> futures::future::BoxFuture<'a, anyhow::Result<CompactOutcome>> {Box::pin(async move {+ apply_turn_overrides(config, model_override, temperature, route);let thread_id = thread_id.trim();if thread_id.is_empty() {anyhow::bail!("compact_thread needs a thread id");diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rsindex 5ec2299524..457b27c723 100644--- a/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs+++ b/crates/openhuman-core/src/agent_runs/agent_chat/session_turn.rs@@ -451,6 +451,30 @@ pub async fn agent_chat_reply_for_controlled(.await}+/// Applies a call's model, temperature and inference route to `config`, in+/// memory, before its session is built.+pub(super) fn apply_turn_overrides(+ config: &mut Config,+ model_override: Option<String>,+ temperature: Option<f64>,+ route: Option<crate::config::schema::EphemeralRoute>,+) {+ // TAURI-RUST-RS: an upstream caller (frontend, JSON-RPC client) can pass+ // `model_override: Some("")`. See `normalize_model_override` for the+ // rationale — an empty / whitespace-only override collapses to `None`.+ if let Some(model) = normalize_model_override(model_override) {+ config.default_model = Some(model);+ }+ if let Some(temp) = temperature {+ config.default_temperature = temp;+ }+ // After the model override, because the route pins its roles to+ // `"<slug>:<model>"` and the model it uses is the one this call resolved.+ if let Some(route) = route {+ crate::config::schema::ephemeral_route::apply(config, route);+ }+}+#[allow(clippy::too_many_arguments)]pub(super) async fn agent_chat_reply_for_inner(config: &mut Config,@@ -484,21 +508,8 @@ pub(super) async fn agent_chat_reply_for_inner(.map_err(anyhow::Error::msg)?,}- // TAURI-RUST-RS: an upstream caller (frontend, JSON-RPC client) can pass- // `model_override: Some("")`. See `normalize_model_override` for the- // rationale — an empty / whitespace-only override collapses to `None`.- if let Some(model) = normalize_model_override(model_override) {- config.default_model = Some(model);- }- if let Some(temp) = temperature {- config.default_temperature = temp;- }- // After the model override, because the route pins its roles to- // `"<slug>:<model>"` and the model it uses is the one this call resolved.// Before the `cwd` clone below, so a rooted turn is routed too.- if let Some(route) = route {- crate::config::schema::ephemeral_route::apply(config, route);- }+ apply_turn_overrides(config, model_override, temperature, route);// The conversation this turn runs in, normalised once: the factory below is// told the same id `set_thread_id` will bind, so a belt keyed on the// session cannot disagree with the session it is built for.