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): correct reasoning agent to use model config for local AI
Steven Enamakel8588529f1d3f
diff --git a/crates/openhuman-core/src/agent/tinyagents/mod.rs b/crates/openhuman-core/src/agent/tinyagents/mod.rsindex b5cc3f4284..eea335aba9 100644--- a/crates/openhuman-core/src/agent/tinyagents/mod.rs+++ b/crates/openhuman-core/src/agent/tinyagents/mod.rs@@ -56,6 +56,7 @@ pub(crate) mod tools;mod topology;mod turn_models;mod turn_outcome;+mod reasoning;mod turn_policy;mod turn_run_error;mod turn_run_finalize;@@ -79,6 +80,7 @@ pub(crate) use turn_outcome::{HaltSummarySlot, TinyagentsTurnOutcome, ToolCallOutcome, ToolOutcomeSink,};#[cfg(test)]+pub(crate) use reasoning::{parse_reasoning_effort, reasoning_for_config};pub(crate) use turn_policy::is_subagent_spawn_or_delegate_tool;pub(crate) use turn_policy::{agent_turn_wall_clock_ms, ToolPolicyEnforcement};pub(crate) use turn_runner::{run_root_turn_via_hosted_agent, run_turn_via_tinyagents_shared};diff --git a/crates/openhuman-core/src/agent/tinyagents/reasoning.rs b/crates/openhuman-core/src/agent/tinyagents/reasoning.rsnew file mode 100644index 0000000000..4cf3e01ad9--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/reasoning.rs@@ -0,0 +1,57 @@+//! The user's reasoning ("thinking") choice for an agent turn, resolved into+//! the provider-neutral [`ReasoningConfig`] the harness attaches to every+//! model request (`RunPolicy::default_reasoning`).+//!+//! The source is the turn's effective config: `runtime.reasoning_effort`+//! (a chat thread's per-turn choice is written there by `web_chat`), falling+//! back to `runtime.reasoning_enabled = false` meaning "no reasoning". Nothing+//! set means the provider keeps its own default.++use tinyinference_llm::model::{ReasoningConfig, ReasoningEffort};++use crate::config::Config;++/// Parses a user-facing effort name. Accepts the wire tokens plus the aliases+/// `off`/`disabled` (none) and `max`/`maximum` (xhigh), case-insensitively.+pub(crate) fn parse_reasoning_effort(raw: &str) -> Option<ReasoningEffort> {+ match raw.trim().to_ascii_lowercase().as_str() {+ "none" | "off" | "disabled" => Some(ReasoningEffort::None),+ "minimal" => Some(ReasoningEffort::Minimal),+ "low" => Some(ReasoningEffort::Low),+ "medium" | "med" => Some(ReasoningEffort::Medium),+ "high" => Some(ReasoningEffort::High),+ "xhigh" | "max" | "maximum" => Some(ReasoningEffort::XHigh),+ _ => None,+ }+}++/// The reasoning config an agent turn on `config` should request, or `None`+/// to leave the provider default alone.+pub(crate) fn reasoning_for_config(config: &Config) -> Option<ReasoningConfig> {+ if let Some(raw) = config+ .runtime+ .reasoning_effort+ .as_deref()+ .map(str::trim)+ .filter(|raw| !raw.is_empty())+ {+ return match parse_reasoning_effort(raw) {+ Some(effort) => Some(ReasoningConfig::effort(effort)),+ None => {+ log::warn!(+ "[agent][reasoning] ignoring unknown runtime.reasoning_effort {raw:?}; \+ using the provider default"+ );+ None+ }+ };+ }+ if config.runtime.reasoning_enabled == Some(false) {+ return Some(ReasoningConfig::effort(ReasoningEffort::None));+ }+ None+}++#[cfg(test)]+#[path = "reasoning_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/reasoning_tests.rs b/crates/openhuman-core/src/agent/tinyagents/reasoning_tests.rsnew file mode 100644index 0000000000..f8258ba891--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/reasoning_tests.rs@@ -0,0 +1,54 @@+use super::*;++#[test]+fn parses_wire_tokens_and_aliases() {+ assert_eq!(parse_reasoning_effort("high"), Some(ReasoningEffort::High));+ assert_eq!(parse_reasoning_effort(" Low "), Some(ReasoningEffort::Low));+ assert_eq!(parse_reasoning_effort("off"), Some(ReasoningEffort::None));+ assert_eq!(parse_reasoning_effort("max"), Some(ReasoningEffort::XHigh));+ assert_eq!(parse_reasoning_effort("xhigh"), Some(ReasoningEffort::XHigh));+ assert_eq!(parse_reasoning_effort("turbo"), None);+}++#[test]+fn unset_config_leaves_the_provider_default() {+ assert_eq!(reasoning_for_config(&Config::default()), None);+}++#[test]+fn configured_effort_becomes_the_turn_reasoning() {+ let mut config = Config::default();+ config.runtime.reasoning_effort = Some("high".into());+ assert_eq!(+ reasoning_for_config(&config),+ Some(ReasoningConfig::effort(ReasoningEffort::High))+ );+}++#[test]+fn reasoning_disabled_without_an_effort_asks_for_none() {+ let mut config = Config::default();+ config.runtime.reasoning_enabled = Some(false);+ assert_eq!(+ reasoning_for_config(&config),+ Some(ReasoningConfig::effort(ReasoningEffort::None))+ );+}++#[test]+fn explicit_effort_wins_over_reasoning_disabled() {+ let mut config = Config::default();+ config.runtime.reasoning_enabled = Some(false);+ config.runtime.reasoning_effort = Some("low".into());+ assert_eq!(+ reasoning_for_config(&config),+ Some(ReasoningConfig::effort(ReasoningEffort::Low))+ );+}++#[test]+fn unknown_effort_falls_back_to_the_provider_default() {+ let mut config = Config::default();+ config.runtime.reasoning_effort = Some("turbo".into());+ assert_eq!(reasoning_for_config(&config), None);+}diff --git a/crates/openhuman-core/src/config/ops_model_and_local_ai_tests.rs b/crates/openhuman-core/src/config/ops_model_and_local_ai_tests.rsindex d9523d54c0..a60398e046 100644--- a/crates/openhuman-core/src/config/ops_model_and_local_ai_tests.rs+++ b/crates/openhuman-core/src/config/ops_model_and_local_ai_tests.rs@@ -408,6 +408,7 @@ async fn apply_runtime_settings_updates_kind_and_reasoning() {let patch = RuntimeSettingsPatch {kind: Some("desktop".into()),reasoning_enabled: Some(true),+ reasoning_effort: Some("max".into()),};let _ = apply_runtime_settings(&mut cfg, patch).await