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
refactor(tinyagents): simplify agent configuration logic
Steven Enamakelc4885b693724
diff --git a/crates/openhuman-core/src/agent/tinyagents/config.rs b/crates/openhuman-core/src/agent/tinyagents/config.rsindex bf1d330f42..a059bfcc10 100644--- a/crates/openhuman-core/src/agent/tinyagents/config.rs+++ b/crates/openhuman-core/src/agent/tinyagents/config.rs@@ -7,20 +7,15 @@//! single place OpenHuman's schema meets it. //!//! # Why the mapping is split into three functions//!-//! OpenHuman's model pins are not global. `Config::teams` is keyed by team name-//! and `Config::agents` by delegate id, so "the model for this session" is only-//! knowable once you know *which* agent is running. Folding all of that into-//! one `session_config_from(&Config)` would force it to invent an answer.-//! Instead [`session_config_from`] maps what is genuinely global, and the two-//! `apply_*` functions layer the narrower pins on top in the order the runtime-//! resolves them: team pins first, then the specific delegate's overrides.+//! `session_config_from` maps global settings, while `apply_team_models` layers+//! team-specific model pins when a team is selected.use tinyagents_harness::config::{RequiredOutput, SessionConfig, ToolConfig, ToolDispatcher, TurnConfig,};use crate::config::{- AgentConfig, Config, DelegateAgentConfig, RequiredOutputContract, DEFAULT_MODEL,+ AgentConfig, Config, RequiredOutputContract, DEFAULT_MODEL,};/// Translates OpenHuman's free-form `agent.tool_dispatcher` string into the@@ -148,33 +143,6 @@ pub fn apply_team_models(session: &mut SessionConfig, config: &Config, team: &st}}-/// Applies one delegate agent's overrides — its model, temperature, and the-/// nesting depth it is permitted.-///-/// `delegate.model` overwrites [`SessionConfig::model`] rather than-/// `lead_model`: a delegate *is* the agent running this session, so it is the-/// base model, not an override layered over some other base.-pub fn apply_delegate(session: &mut SessionConfig, delegate: &DelegateAgentConfig) {- // `DelegateAgentConfig::model` is a bare `String`, and TOML happily accepts- // `model = ""`. Assigning that unchecked would replace a working session- // model with the empty string and fail at dispatch rather than here, so a- // blank pin leaves the session default alone — the same trim-and-drop rule- // `TeamModelConfig::model_for_role` applies to team pins.- let model = delegate.model.trim();- if model.is_empty() {- tracing::warn!(- target: "tinyagents",- "[tinyagents] delegate model pin is blank; keeping the session default model"- );- } else {- session.model = model.to_string();- }- if let Some(t) = delegate.temperature {- session.temperature = Some(t);- }- session.max_depth = delegate.max_depth;-}-#[cfg(test)]#[path = "config_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/config_tests.rs b/crates/openhuman-core/src/agent/tinyagents/config_tests.rsindex f6ea7d4e21..75494f3760 100644--- a/crates/openhuman-core/src/agent/tinyagents/config_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/config_tests.rs@@ -234,57 +234,3 @@ fn a_blank_team_pin_does_not_displace_the_default() {assert_eq!(s.effective_subagent_model(), "sonnet");}-#[test]-fn a_blank_delegate_model_keeps_the_session_default() {- let mut c = base();- c.default_model = Some("sonnet".into());- let mut s = session_config_from(&c);- apply_delegate(- &mut s,- &DelegateAgentConfig {- model: " ".into(),- system_prompt: None,- temperature: None,- max_depth: 1,- },- );- assert_eq!(s.model, "sonnet");-}--#[test]-fn delegate_overrides_replace_the_base_model_and_enable_delegation() {- let c = base();- let mut s = session_config_from(&c);- apply_delegate(- &mut s,- &DelegateAgentConfig {- model: "haiku".into(),- system_prompt: None,- temperature: Some(0.1),- max_depth: 2,- },- );-- assert_eq!(s.model, "haiku");- assert_eq!(s.temperature, Some(0.1));- assert_eq!(s.max_depth, 2);- assert!(s.may_delegate_at(1));- assert!(!s.may_delegate_at(2));-}--#[test]-fn a_delegate_without_a_temperature_keeps_the_configured_default() {- let mut c = base();- c.default_temperature = 0.7;- let mut s = session_config_from(&c);- apply_delegate(- &mut s,- &DelegateAgentConfig {- model: "haiku".into(),- system_prompt: None,- temperature: None,- max_depth: 1,- },- );- assert_eq!(s.temperature, Some(0.7));-}