Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(config): add config schema types for model IDs and output language

Steven Enamakel5d590c25a57a
diff --git a/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs b/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
index 95cae0f6cd..1580773178 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/langfuse/span_export.rs
@@ -12,8 +12,6 @@ use super::ingestion_batch::{iso_millis, new_event_id};
use super::{environment_for_base, ingestion_url, skip_push, LOG_TARGET, PUSH_TIMEOUT};
use super::{SpanStatus, TraceSpan};
-
-
/// Langfuse observation level for a span status. Only `Error` is elevated so
/// failed tool calls / turns surface in the Langfuse UI.
fn level_for(status: SpanStatus) -> &'static str {
diff --git a/crates/openhuman-core/src/config/schema/types.rs b/crates/openhuman-core/src/config/schema/types.rs
index d2dcba4711..9a87c75444 100644
--- a/crates/openhuman-core/src/config/schema/types.rs
+++ b/crates/openhuman-core/src/config/schema/types.rs
@@ -1,7 +1,23 @@
-// Load/save and env overrides extend Config in load.rs
+//! The persisted [`Config`] document, its model-tier constants, and the
+//! resolvers layered on top of it.
+//!
+//! Load/save and env overrides extend `Config` in `load/`.
+
+mod config;
+mod defaults;
+mod model_ids;
+mod output_language;
+mod resolvers;
+
+pub(crate) use config::DEFAULT_TEMPERATURE;
+pub use config::{Config, CustomEmbeddingsConfig, ModelRegistryEntry};
+pub use model_ids::{
+ DEFAULT_MEMORY_SYNC_INTERVAL_SECS, DEFAULT_MODEL, MEMORY_SYNC_INTERVAL_PRESETS_SECS,
+ MODEL_AGENTIC_V1, MODEL_BURST_V1, MODEL_CHAT_V1, MODEL_CODING_V1, MODEL_REASONING_QUICK_V1,
+ MODEL_REASONING_V1, MODEL_SUMMARIZATION_V1, MODEL_VISION_V1,
+};
+pub use output_language::{normalize_output_language, output_language_directive};
#[cfg(test)]
#[path = "types_model_pin_tests_tests.rs"]
mod model_pin_tests;
-include!("types_part_01.rs");
-include!("types_part_02.rs");
diff --git a/crates/openhuman-core/src/config/schema/types_part_01.rs b/crates/openhuman-core/src/config/schema/types/config.rs
similarity index 83%
rename from crates/openhuman-core/src/config/schema/types_part_01.rs
rename to crates/openhuman-core/src/config/schema/types/config.rs
index b07d5b89e8..d59276fbaf 100644
--- a/crates/openhuman-core/src/config/schema/types_part_01.rs
+++ b/crates/openhuman-core/src/config/schema/types/config.rs
@@ -1,48 +1,12 @@
-use super::*;
+//! The persisted [`Config`] document and the helper types nested directly in
+//! it, plus the serde default functions its attributes reference.
-use directories::UserDirs;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
-/// Standard model identifiers matching the backend model registry.
-pub const MODEL_AGENTIC_V1: &str = "agentic-v1";
-pub const MODEL_REASONING_V1: &str = "reasoning-v1";
-/// Low-latency conversational tier.
-pub const MODEL_CHAT_V1: &str = "chat-v1";
-/// Legacy low-latency chat tier slug retained for older persisted configs.
-pub const MODEL_REASONING_QUICK_V1: &str = "reasoning-quick-v1";
-pub const MODEL_CODING_V1: &str = "coding-v1";
-/// High-throughput "burst" tier served by the managed backend. Cheap, fast,
-/// non-reasoning, text-only, 128k context, no prompt cache; used by fast
-/// high-fanout workers. Managed-backend only (no BYOK knob).
-pub const MODEL_BURST_V1: &str = "burst-v1";
-pub const MODEL_SUMMARIZATION_V1: &str = "summarization-v1";
-/// Multimodal (image-input) tier. Managed backend serves this with the vision
-/// flag enabled; the vision sub-agent rides this tier via `hint:vision`.
-pub const MODEL_VISION_V1: &str = "vision-v1";
-/// Default model used when no explicit model is configured.
-///
-/// Set to `chat-v1`, the backend's low-latency conversational tier. The
-/// orchestrator (user-facing front-line agent) rides on this tier by default
-/// via `hint:chat`; reach for the slower `reasoning-v1` only when deep
-/// reasoning is needed.
-pub const DEFAULT_MODEL: &str = MODEL_CHAT_V1;
-
-/// Effective default global memory-sync cadence (seconds) used when
-/// [`Config::memory_sync_interval_secs`] is `None` — i.e. the user has not
-/// explicitly picked a schedule. 24h, matching the "Sync every 24h" preset
-/// surfaced in the Memory Sources UI. See issue #3302.
-///
-/// Defined in `tinymemory_api::host` and re-exported here: the extracted memory
-/// subsystem applies this fallback too, and two `86_400`s that must agree is a
-/// drift waiting to happen.
-pub use tinymemory_api::host::DEFAULT_MEMORY_SYNC_INTERVAL_SECS;
-
-/// Preset memory-sync cadences (seconds) offered in the UI: 4h / 12h / 24h.
-/// "Manual only" is represented separately by `Some(0)`. See issue #3302.
-pub const MEMORY_SYNC_INTERVAL_PRESETS_SECS: [u64; 3] = [14_400, 43_200, 86_400];
+use crate::config::schema::*;
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
pub struct ModelRegistryEntry {
@@ -118,7 +82,7 @@ pub struct Config {
#[serde(skip)]
#[schemars(skip)]
#[doc(hidden)]
- pub cli_inference_snapshot: Option<super::AppliedInferenceOverride>,
+ pub cli_inference_snapshot: Option<AppliedInferenceOverride>,
/// Runtime only — `true` when this config was produced by the loader's
/// corruption-recovery path: the on-disk `config.toml` was unreadable
/// (non-UTF-8) or unparseable, so it was renamed to `.corrupted.<ts>` and the
@@ -171,9 +135,9 @@ pub struct Config {
/// Host-level switches for the configurable hook system. The hooks
/// themselves live in `hooks.json` files, not here — see
- /// [`super::HooksConfig`].
+ /// [`HooksConfig`].
#[serde(default)]
- pub hooks: super::HooksConfig,
+ pub hooks: HooksConfig,
/// Data-egress posture (Privacy Mode). Distinct from `autonomy` (which
/// governs agent *act* power). Missing `[privacy]` block → `Standard`
@@ -322,7 +286,7 @@ pub struct Config {
/// them, and where a developer's own build lives. The loadable *set* is
/// compiled in, not configured: see `openhuman::modules::registry`.
#[serde(default)]
- pub modules: super::ModulesConfig,
+ pub modules: ModulesConfig,
/// Trust metadata for external capability providers. Empty by default so
/// existing installations keep the same tool-discovery behavior.
@@ -577,7 +541,7 @@ fn default_temperature_value() -> f64 {
/// as well as Moonshot's Kimi K2 family which only accepts `temperature: 1`
/// (see #2076 — 146 Sentry events from users in China hitting *"invalid
/// temperature: only 1 is allowed for this model"* on `kimi-k2.6`).
-fn default_temperature_unsupported_models() -> Vec<String> {
+pub(super) fn default_temperature_unsupported_models() -> Vec<String> {
vec![
"o1*".to_string(),
"o3*".to_string(),
@@ -594,61 +558,3 @@ fn default_temperature_unsupported_models() -> Vec<String> {
"moonshotai/*".to_string(),
]
}
-
-/// Normalize a configured output language into a display name suitable for
-/// prompt directives. Unknown non-empty values are treated as user-provided
-/// language names after stripping control characters.
-pub fn normalize_output_language(language: &str) -> Option<String> {
- let trimmed = language.trim();
- if trimmed.is_empty() {
- return None;
- }
-
- let tag = trimmed.to_ascii_lowercase().replace('_', "-");
- let mapped = match tag.as_str() {
- "ar" | "arabic" => Some("Arabic"),
- "bn" | "bengali" | "bangla" => Some("Bengali"),
- "de" | "german" => Some("German"),
- "en" | "en-us" | "en-gb" | "english" => Some("English"),
- "es" | "spanish" => Some("Spanish"),
- "fr" | "french" => Some("French"),
- "hi" | "hindi" => Some("Hindi"),
- "id" | "indonesian" | "bahasa indonesia" => Some("Indonesian"),
- "it" | "italian" => Some("Italian"),
- "ja" | "japanese" => Some("Japanese"),
- "ko" | "korean" => Some("Korean"),
- "pt" | "pt-br" | "pt-pt" | "portuguese" => Some("Portuguese"),
- "ru" | "russian" => Some("Russian"),
- "th" | "thai" => Some("Thai"),
- "tr" | "turkish" => Some("Turkish"),
- "vi" | "vietnamese" => Some("Vietnamese"),
- "zh" | "zh-cn" | "zh-hans" | "chinese" | "simplified chinese" => Some("Simplified Chinese"),
- "zh-tw" | "zh-hant" | "traditional chinese" => Some("Traditional Chinese"),
- _ => None,
- };
- if let Some(language) = mapped {
- return Some(language.to_string());
- }
-
- let cleaned: String = trimmed
- .chars()
- .filter(|c| !c.is_control())
- .take(80)
- .collect();
- let cleaned = cleaned.trim();
- if cleaned.is_empty() {
- None
- } else {
- Some(cleaned.to_string())
- }
-}
-
-/// Build a shared instruction for non-chat background prompts. JSON keys and
-/// enum values stay stable; only user-visible prose changes language.
-pub fn output_language_directive(language: Option<&str>) -> Option<String> {
- let language = normalize_output_language(language?)?;
- Some(format!(
- "Output language: write all natural-language output in {language}. \
- Keep JSON keys, enum values, proper nouns, code, commands, and quoted source text unchanged."
- ))
-}
diff --git a/crates/openhuman-core/src/config/schema/types/defaults.rs b/crates/openhuman-core/src/config/schema/types/defaults.rs
new file mode 100644
index 0000000000..b63334627e
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/types/defaults.rs
@@ -0,0 +1,125 @@
+//! The [`Default`] impl for [`Config`], anchored at the OpenHuman root dir.
+
+use directories::UserDirs;
+use std::collections::HashMap;
+use std::path::PathBuf;
+
+use super::config::default_temperature_unsupported_models;
+use super::config::DEFAULT_TEMPERATURE;
+use super::model_ids::DEFAULT_MODEL;
+use crate::config::schema::*;
+
+impl Default for Config {
+ fn default() -> Self {
+ let openhuman_dir = crate::config::default_root_openhuman_dir().unwrap_or_else(|_| {
+ let home =
+ UserDirs::new().map_or_else(|| PathBuf::from("."), |u| u.home_dir().to_path_buf());
+ let dir_name = if crate::api::config::is_staging_app_env(
+ crate::api::config::app_env_from_env().as_deref(),
+ ) {
+ ".openhuman-staging"
+ } else {
+ ".openhuman"
+ };
+ home.join(dir_name)
+ });
+
+ Self {
+ workspace_dir: openhuman_dir.join("workspace"),
+ action_dir: crate::config::default_action_dir(),
+ action_dir_override: None,
+ config_path: openhuman_dir.join("config.toml"),
+ cli_inference_snapshot: None,
+ recovered_from_corruption: false,
+ schema_version: 0,
+ api_url: None,
+ api_key: None,
+ inference_url: None,
+ ephemeral_route: None,
+ default_model: Some(DEFAULT_MODEL.to_string()),
+ default_temperature: DEFAULT_TEMPERATURE,
+ output_language: None,
+ temperature_unsupported_models: default_temperature_unsupported_models(),
+ observability: ObservabilityConfig::default(),
+ dashboard: DashboardConfig::default(),
+ autonomy: AutonomyConfig::default(),
+ hooks: HooksConfig::default(),
+ privacy: PrivacyConfig::default(),
+ sandbox: SandboxConfig::default(),
+ runtime: RuntimeConfig::default(),
+ shell: ShellConfig::default(),
+ reliability: ReliabilityConfig::default(),
+ scheduler: SchedulerConfig::default(),
+ scheduler_gate: SchedulerGateConfig::default(),
+ agent_activity_level: AgentActivityLevel::default(),
+ memory_sync_interval_secs: None,
+ agent: AgentConfig::default(),
+ orchestrator: OrchestratorModelConfig::default(),
+ teams: HashMap::new(),
+ context: ContextConfig::default(),
+ model_routes: Vec::new(),
+ embedding_routes: Vec::new(),
+ heartbeat: HeartbeatConfig::default(),
+ subconscious: crate::config::schema::SubconsciousConfig::default(),
+ cron: CronConfig::default(),
+ task_sources: TaskSourcesConfig::default(),
+ channels_config: ChannelsConfig::default(),
+ memory: MemoryConfig::default(),
+ memory_tree: MemoryTreeConfig::default(),
+ storage: StorageConfig::default(),
+ subsystems: SubsystemsConfig::default(),
+ composio: ComposioConfig::default(),
+ secrets: SecretsConfig::default(),
+ browser: BrowserConfig::default(),
+ http_request: HttpRequestConfig::default(),
+ curl: CurlConfig::default(),
+ gitbooks: GitbooksConfig::default(),
+ mcp_client: McpClientConfig::default(),
+ modules: ModulesConfig::default(),
+ capability_providers: Vec::new(),
+ multimodal: MultimodalConfig::default(),
+ multimodal_files: MultimodalFileConfig::default(),
+ seltz: SeltzConfig::default(),
+ searxng: SearxngConfig::default(),
+ web_search: WebSearchConfig::default(),
+ search: SearchConfig::default(),
+ proxy: ProxyConfig::default(),
+ cost: CostConfig::default(),
+ memory_sources: Vec::new(),
+ agent_registry: crate::agent::registry::types::AgentRegistryConfig::default(),
+ agents: HashMap::new(),
+ local_ai: LocalAiConfig::default(),
+ claude_agent_sdk: ClaudeAgentSdkConfig::default(),
+ cloud_providers: Vec::new(),
+ primary_cloud: None,
+ chat_provider: None,
+ reasoning_provider: None,
+ agentic_provider: None,
+ coding_provider: None,
+ vision_provider: None,
+ memory_provider: None,
+ embeddings_provider: None,
+ custom_embeddings: None,
+ heartbeat_provider: None,
+ learning_provider: None,
+ subconscious_provider: None,
+ node: NodeConfig::default(),
+ runtime_python: RuntimePythonConfig::default(),
+ runtime_pool: RuntimePoolConfig::default(),
+ tokenjuice: TokenjuiceConfig::default(),
+ hosting: HostingConfig::default(),
+ voice_server: VoiceServerConfig::default(),
+ voice_providers: Vec::new(),
+ stt_provider: None,
+ tts_provider: None,
+ integrations: IntegrationsConfig::default(),
+ learning: LearningConfig::default(),
+ update: UpdateConfig::default(),
+ dictation: DictationConfig::default(),
+ onboarding_completed: false,
+ chat_onboarding_completed: false,
+ model_registry: Vec::new(),
+ composio_source_caps_migration_version: 0,
+ }
+ }
+}
diff --git a/crates/openhuman-core/src/config/schema/types/model_ids.rs b/crates/openhuman-core/src/config/schema/types/model_ids.rs
new file mode 100644
index 0000000000..0c581fb488
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/types/model_ids.rs
@@ -0,0 +1,39 @@
+//! Standard model-tier identifiers and memory-sync cadence constants.
+
+/// Standard model identifiers matching the backend model registry.
+pub const MODEL_AGENTIC_V1: &str = "agentic-v1";
+pub const MODEL_REASONING_V1: &str = "reasoning-v1";
+/// Low-latency conversational tier.
+pub const MODEL_CHAT_V1: &str = "chat-v1";
+/// Legacy low-latency chat tier slug retained for older persisted configs.
+pub const MODEL_REASONING_QUICK_V1: &str = "reasoning-quick-v1";
+pub const MODEL_CODING_V1: &str = "coding-v1";
+/// High-throughput "burst" tier served by the managed backend. Cheap, fast,
+/// non-reasoning, text-only, 128k context, no prompt cache; used by fast
+/// high-fanout workers. Managed-backend only (no BYOK knob).
+pub const MODEL_BURST_V1: &str = "burst-v1";
+pub const MODEL_SUMMARIZATION_V1: &str = "summarization-v1";
+/// Multimodal (image-input) tier. Managed backend serves this with the vision
+/// flag enabled; the vision sub-agent rides this tier via `hint:vision`.
+pub const MODEL_VISION_V1: &str = "vision-v1";
+/// Default model used when no explicit model is configured.
+///
+/// Set to `chat-v1`, the backend's low-latency conversational tier. The
+/// orchestrator (user-facing front-line agent) rides on this tier by default
+/// via `hint:chat`; reach for the slower `reasoning-v1` only when deep
+/// reasoning is needed.
+pub const DEFAULT_MODEL: &str = MODEL_CHAT_V1;
+
+/// Effective default global memory-sync cadence (seconds) used when
+/// [`Config::memory_sync_interval_secs`] is `None` — i.e. the user has not
+/// explicitly picked a schedule. 24h, matching the "Sync every 24h" preset
+/// surfaced in the Memory Sources UI. See issue #3302.
+///
+/// Defined in `tinymemory_api::host` and re-exported here: the extracted memory
+/// subsystem applies this fallback too, and two `86_400`s that must agree is a
+/// drift waiting to happen.
+pub use tinymemory_api::host::DEFAULT_MEMORY_SYNC_INTERVAL_SECS;
+
+/// Preset memory-sync cadences (seconds) offered in the UI: 4h / 12h / 24h.
+/// "Manual only" is represented separately by `Some(0)`. See issue #3302.
+pub const MEMORY_SYNC_INTERVAL_PRESETS_SECS: [u64; 3] = [14_400, 43_200, 86_400];
diff --git a/crates/openhuman-core/src/config/schema/types/output_language.rs b/crates/openhuman-core/src/config/schema/types/output_language.rs
new file mode 100644
index 0000000000..f2041666cf
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/types/output_language.rs
@@ -0,0 +1,59 @@
+//! Output-language normalization shared by prompt directives.
+
+/// Normalize a configured output language into a display name suitable for
+/// prompt directives. Unknown non-empty values are treated as user-provided
+/// language names after stripping control characters.
+pub fn normalize_output_language(language: &str) -> Option<String> {
+ let trimmed = language.trim();
+ if trimmed.is_empty() {
+ return None;
+ }
+
+ let tag = trimmed.to_ascii_lowercase().replace('_', "-");
+ let mapped = match tag.as_str() {
+ "ar" | "arabic" => Some("Arabic"),
+ "bn" | "bengali" | "bangla" => Some("Bengali"),
+ "de" | "german" => Some("German"),
+ "en" | "en-us" | "en-gb" | "english" => Some("English"),
+ "es" | "spanish" => Some("Spanish"),
+ "fr" | "french" => Some("French"),
+ "hi" | "hindi" => Some("Hindi"),
+ "id" | "indonesian" | "bahasa indonesia" => Some("Indonesian"),
+ "it" | "italian" => Some("Italian"),
+ "ja" | "japanese" => Some("Japanese"),
+ "ko" | "korean" => Some("Korean"),
+ "pt" | "pt-br" | "pt-pt" | "portuguese" => Some("Portuguese"),
+ "ru" | "russian" => Some("Russian"),
+ "th" | "thai" => Some("Thai"),
+ "tr" | "turkish" => Some("Turkish"),
+ "vi" | "vietnamese" => Some("Vietnamese"),
+ "zh" | "zh-cn" | "zh-hans" | "chinese" | "simplified chinese" => Some("Simplified Chinese"),
+ "zh-tw" | "zh-hant" | "traditional chinese" => Some("Traditional Chinese"),
+ _ => None,
+ };
+ if let Some(language) = mapped {
+ return Some(language.to_string());
+ }
+
+ let cleaned: String = trimmed
+ .chars()
+ .filter(|c| !c.is_control())
+ .take(80)
+ .collect();
+ let cleaned = cleaned.trim();
+ if cleaned.is_empty() {
+ None
+ } else {
+ Some(cleaned.to_string())
+ }
+}
+
+/// Build a shared instruction for non-chat background prompts. JSON keys and
+/// enum values stay stable; only user-visible prose changes language.
+pub fn output_language_directive(language: Option<&str>) -> Option<String> {
+ let language = normalize_output_language(language?)?;
+ Some(format!(
+ "Output language: write all natural-language output in {language}. \
+ Keep JSON keys, enum values, proper nouns, code, commands, and quoted source text unchanged."
+ ))
+}
diff --git a/crates/openhuman-core/src/config/schema/types/resolvers.rs b/crates/openhuman-core/src/config/schema/types/resolvers.rs
new file mode 100644
index 0000000000..fb2dd33177
--- /dev/null
+++ b/crates/openhuman-core/src/config/schema/types/resolvers.rs
@@ -0,0 +1,132 @@
+//! Read-only resolvers on [`Config`]: memory-tree content root, per-workload
+//! local-model routing, and exact agent model pins.
+
+use std::path::PathBuf;
+
+use super::output_language::output_language_directive;
+use crate::config::schema::Config;
+
+impl Config {
+ /// Resolve the root directory where chunk `.md` files are stored.
+ ///
+ /// Resolution order:
+ /// 1. `memory_tree.content_dir` if `Some`.
+ /// 2. Default: `<workspace_dir>/memory_tree/content/`.
+ ///
+ /// This is the only place in the codebase that should compute the content
+ /// root — all code that needs the path should call this method.
+ pub fn memory_tree_content_root(&self) -> PathBuf {
+ self.memory_tree
+ .content_dir
+ .clone()
+ .unwrap_or_else(|| self.workspace_dir.join("memory_tree").join("content"))
+ }
+
+ /// Read the per-workload provider string and return the local model id
+ /// when the workload is routed to Ollama.
+ ///
+ /// Recognised workload names:
+ /// `"chat"`, `"reasoning"`, `"agentic"`, `"coding"`, `"memory"`, `"embeddings"`,
+ /// `"heartbeat"`, `"learning"`, `"subconscious"`.
+ ///
+ /// Returns `None` when the provider isn't `"ollama:<model>"` (including
+ /// when the field is unset, blank, `"cloud"`, or any other prefix).
+ /// This is the single source of truth for "is this workload local?" —
+ /// callers MUST NOT consult the legacy `local_ai.usage.*` booleans or
+ /// `memory_tree.llm_backend`. Those fields are deprecated zombies kept
+ /// for migration only.
+ pub fn workload_local_model(&self, workload: &str) -> Option<String> {
+ let raw = match workload {
+ "chat" => self.chat_provider.as_deref(),
+ "reasoning" => self.reasoning_provider.as_deref(),
+ "agentic" => self.agentic_provider.as_deref(),
+ "coding" => self.coding_provider.as_deref(),
+ "vision" => self.vision_provider.as_deref(),
+ "memory" => self.memory_provider.as_deref(),
+ "embeddings" => self.embeddings_provider.as_deref(),
+ "heartbeat" => self.heartbeat_provider.as_deref(),
+ "learning" => self.learning_provider.as_deref(),
+ "subconscious" => self.subconscious_provider.as_deref(),
+ _ => None,
+ }?;
+ let trimmed = raw.trim();
+ let model = trimmed.strip_prefix("ollama:")?.trim();
+ if model.is_empty() {
+ None
+ } else {
+ Some(model.to_string())
+ }
+ }
+
+ /// `true` when `workload_local_model` returns `Some` for the named
+ /// workload. Convenience wrapper for the common "do I dispatch
+ /// locally?" branch.
+ pub fn workload_uses_local(&self, workload: &str) -> bool {
+ self.workload_local_model(workload).is_some()
+ }
+
+ /// Prompt directive for background LLM artifacts, if configured.
+ pub fn output_language_directive(&self) -> Option<String> {
+ output_language_directive(self.output_language.as_deref())
+ }
+
+ /// Resolve an exact model pin for an agent, if configured.
+ ///
+ /// Precedence is intentionally narrow and deterministic:
+ /// 1. `orchestrator.model` when resolving the front-line orchestrator.
+ /// 2. `[teams.<agent_id>]` entries, with `lead_model` used for agents
+ /// that can delegate and `agent_model` used for leaf workers.
+ /// 3. Built-in aliases such as `[teams.research]` for `researcher` and
+ /// `[teams.code]` for `code_executor`, matching the issue examples.
+ ///
+ /// Empty strings are ignored so partially-written configs fall back to
+ /// the existing auto-routing path.
+ pub fn configured_agent_model(&self, agent_id: &str, is_team_lead: bool) -> Option<&str> {
+ fn clean(model: Option<&str>) -> Option<&str> {
+ model.map(str::trim).filter(|value| !value.is_empty())
+ }
+
+ let agent_id = agent_id.trim();
+ if agent_id.is_empty() {
+ return None;
+ }
+
+ if agent_id == "orchestrator" {
+ if let Some(model) = clean(self.orchestrator.model.as_deref()) {
+ return Some(model);
+ }
+ }
+
+ if let Some(model) = self
+ .teams
+ .get(agent_id)
+ .and_then(|team| team.model_for_role(is_team_lead))
+ {
+ return Some(model);
+ }
+
+ if let Some(stripped) = agent_id.strip_suffix("_agent") {
+ if let Some(model) = self
+ .teams
+ .get(stripped)
+ .and_then(|team| team.model_for_role(is_team_lead))
+ {
+ return Some(model);
+ }
+ }
+
+ let aliases: &[&str] = match agent_id {
+ "researcher" => &["research"],
+ "code_executor" => &["code"],
+ "tool_maker" | "tools_agent" => &["tools"],
+ "integrations_agent" => &["integrations"],
+ _ => &[],
+ };
+
+ aliases.iter().find_map(|alias| {
+ self.teams
+ .get(*alias)
+ .and_then(|team| team.model_for_role(is_team_lead))
+ })
+ }
+}
diff --git a/crates/openhuman-core/src/config/schema/types_part_02.rs b/crates/openhuman-core/src/config/schema/types_part_02.rs
deleted file mode 100644
index 106853ae57..0000000000
--- a/crates/openhuman-core/src/config/schema/types_part_02.rs
+++ /dev/null
@@ -1,242 +0,0 @@
-
-impl Config {
- /// Resolve the root directory where chunk `.md` files are stored.
- ///
- /// Resolution order:
- /// 1. `memory_tree.content_dir` if `Some`.
- /// 2. Default: `<workspace_dir>/memory_tree/content/`.
- ///
- /// This is the only place in the codebase that should compute the content
- /// root — all code that needs the path should call this method.
- pub fn memory_tree_content_root(&self) -> PathBuf {
- self.memory_tree
- .content_dir
- .clone()
- .unwrap_or_else(|| self.workspace_dir.join("memory_tree").join("content"))
- }
-
- /// Read the per-workload provider string and return the local model id
- /// when the workload is routed to Ollama.
- ///
- /// Recognised workload names:
- /// `"chat"`, `"reasoning"`, `"agentic"`, `"coding"`, `"memory"`, `"embeddings"`,
- /// `"heartbeat"`, `"learning"`, `"subconscious"`.
- ///
- /// Returns `None` when the provider isn't `"ollama:<model>"` (including
- /// when the field is unset, blank, `"cloud"`, or any other prefix).
- /// This is the single source of truth for "is this workload local?" —
- /// callers MUST NOT consult the legacy `local_ai.usage.*` booleans or
- /// `memory_tree.llm_backend`. Those fields are deprecated zombies kept
- /// for migration only.
- pub fn workload_local_model(&self, workload: &str) -> Option<String> {
- let raw = match workload {
- "chat" => self.chat_provider.as_deref(),
- "reasoning" => self.reasoning_provider.as_deref(),
- "agentic" => self.agentic_provider.as_deref(),
- "coding" => self.coding_provider.as_deref(),
- "vision" => self.vision_provider.as_deref(),
- "memory" => self.memory_provider.as_deref(),
- "embeddings" => self.embeddings_provider.as_deref(),
- "heartbeat" => self.heartbeat_provider.as_deref(),
- "learning" => self.learning_provider.as_deref(),
- "subconscious" => self.subconscious_provider.as_deref(),
- _ => None,
- }?;
- let trimmed = raw.trim();
- let model = trimmed.strip_prefix("ollama:")?.trim();
- if model.is_empty() {
- None
- } else {
- Some(model.to_string())
- }
- }
-
- /// `true` when `workload_local_model` returns `Some` for the named
- /// workload. Convenience wrapper for the common "do I dispatch
- /// locally?" branch.
- pub fn workload_uses_local(&self, workload: &str) -> bool {
- self.workload_local_model(workload).is_some()
- }
-
- /// Prompt directive for background LLM artifacts, if configured.
- pub fn output_language_directive(&self) -> Option<String> {
- output_language_directive(self.output_language.as_deref())
- }
-
- /// Resolve an exact model pin for an agent, if configured.
- ///
- /// Precedence is intentionally narrow and deterministic:
- /// 1. `orchestrator.model` when resolving the front-line orchestrator.
- /// 2. `[teams.<agent_id>]` entries, with `lead_model` used for agents
- /// that can delegate and `agent_model` used for leaf workers.
- /// 3. Built-in aliases such as `[teams.research]` for `researcher` and
- /// `[teams.code]` for `code_executor`, matching the issue examples.
- ///
- /// Empty strings are ignored so partially-written configs fall back to
- /// the existing auto-routing path.
- pub fn configured_agent_model(&self, agent_id: &str, is_team_lead: bool) -> Option<&str> {
- fn clean(model: Option<&str>) -> Option<&str> {
- model.map(str::trim).filter(|value| !value.is_empty())
- }
-
- let agent_id = agent_id.trim();
- if agent_id.is_empty() {
- return None;
- }
-
- if agent_id == "orchestrator" {
- if let Some(model) = clean(self.orchestrator.model.as_deref()) {
- return Some(model);
- }
- }
-
- if let Some(model) = self
- .teams
- .get(agent_id)
- .and_then(|team| team.model_for_role(is_team_lead))
- {
- return Some(model);
- }
-
- if let Some(stripped) = agent_id.strip_suffix("_agent") {
- if let Some(model) = self
- .teams
- .get(stripped)
- .and_then(|team| team.model_for_role(is_team_lead))
- {
- return Some(model);
- }
- }
-
- let aliases: &[&str] = match agent_id {
- "researcher" => &["research"],
- "code_executor" => &["code"],
- "tool_maker" | "tools_agent" => &["tools"],
- "integrations_agent" => &["integrations"],
- _ => &[],
- };
-
- aliases.iter().find_map(|alias| {
- self.teams
- .get(*alias)
- .and_then(|team| team.model_for_role(is_team_lead))
- })
- }
-}
-
-impl Default for Config {
- fn default() -> Self {
- let openhuman_dir =
- crate::config::default_root_openhuman_dir().unwrap_or_else(|_| {
- let home = UserDirs::new()
- .map_or_else(|| PathBuf::from("."), |u| u.home_dir().to_path_buf());
- let dir_name = if crate::api::config::is_staging_app_env(
- crate::api::config::app_env_from_env().as_deref(),
- ) {
- ".openhuman-staging"
- } else {
- ".openhuman"
- };
- home.join(dir_name)
- });
-
- Self {
- workspace_dir: openhuman_dir.join("workspace"),
- action_dir: crate::config::default_action_dir(),
- action_dir_override: None,
- config_path: openhuman_dir.join("config.toml"),
- cli_inference_snapshot: None,
- recovered_from_corruption: false,
- schema_version: 0,
- api_url: None,
- api_key: None,
- inference_url: None,
- ephemeral_route: None,
- default_model: Some(DEFAULT_MODEL.to_string()),
- default_temperature: DEFAULT_TEMPERATURE,
- output_language: None,
- temperature_unsupported_models: default_temperature_unsupported_models(),
- observability: ObservabilityConfig::default(),
- dashboard: DashboardConfig::default(),
- autonomy: AutonomyConfig::default(),
- hooks: super::HooksConfig::default(),
- privacy: PrivacyConfig::default(),
- sandbox: SandboxConfig::default(),
- runtime: RuntimeConfig::default(),
- shell: ShellConfig::default(),
- reliability: ReliabilityConfig::default(),
- scheduler: SchedulerConfig::default(),
- scheduler_gate: SchedulerGateConfig::default(),
- agent_activity_level: AgentActivityLevel::default(),
- memory_sync_interval_secs: None,
- agent: AgentConfig::default(),
- orchestrator: OrchestratorModelConfig::default(),
- teams: HashMap::new(),
- context: ContextConfig::default(),
- model_routes: Vec::new(),
- embedding_routes: Vec::new(),
- heartbeat: HeartbeatConfig::default(),
- subconscious: crate::config::schema::SubconsciousConfig::default(),
- cron: CronConfig::default(),
- task_sources: TaskSourcesConfig::default(),
- channels_config: ChannelsConfig::default(),
- memory: MemoryConfig::default(),
- memory_tree: MemoryTreeConfig::default(),
- storage: StorageConfig::default(),
- subsystems: SubsystemsConfig::default(),
- composio: ComposioConfig::default(),
- secrets: SecretsConfig::default(),
- browser: BrowserConfig::default(),
- http_request: HttpRequestConfig::default(),
- curl: CurlConfig::default(),
- gitbooks: GitbooksConfig::default(),
- mcp_client: McpClientConfig::default(),
- modules: super::ModulesConfig::default(),
- capability_providers: Vec::new(),
- multimodal: MultimodalConfig::default(),
- multimodal_files: MultimodalFileConfig::default(),
- seltz: SeltzConfig::default(),
- searxng: SearxngConfig::default(),
- web_search: WebSearchConfig::default(),
- search: SearchConfig::default(),
- proxy: ProxyConfig::default(),
- cost: CostConfig::default(),
- memory_sources: Vec::new(),
- agent_registry: crate::agent::registry::types::AgentRegistryConfig::default(
- ),
- agents: HashMap::new(),
- local_ai: LocalAiConfig::default(),
- claude_agent_sdk: ClaudeAgentSdkConfig::default(),
- cloud_providers: Vec::new(),
- primary_cloud: None,
- chat_provider: None,
- reasoning_provider: None,
- agentic_provider: None,
- coding_provider: None,
- vision_provider: None,
- memory_provider: None,
- embeddings_provider: None,
- custom_embeddings: None,
- heartbeat_provider: None,
- learning_provider: None,
- subconscious_provider: None,
- node: NodeConfig::default(),
- runtime_python: RuntimePythonConfig::default(),
- runtime_pool: RuntimePoolConfig::default(),
- tokenjuice: TokenjuiceConfig::default(),
- hosting: HostingConfig::default(),
- voice_server: VoiceServerConfig::default(),
- voice_providers: Vec::new(),
- stt_provider: None,
- tts_provider: None,
- integrations: IntegrationsConfig::default(),
- learning: LearningConfig::default(),
- update: UpdateConfig::default(),
- dictation: DictationConfig::default(),
- onboarding_completed: false,
- chat_onboarding_completed: false,
- model_registry: Vec::new(),
- composio_source_caps_migration_version: 0,
- }
- }
-}