Skip to content

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

feat(runtime): add chat workload startup module

Steven Enamakel4a7595d52b76
diff --git a/crates/openhuman-core/src/channels/runtime/startup/chat_workload.rs b/crates/openhuman-core/src/channels/runtime/startup/chat_workload.rs
new file mode 100644
index 0000000000..c271aa90b5
--- /dev/null
+++ b/crates/openhuman-core/src/channels/runtime/startup/chat_workload.rs
@@ -0,0 +1,38 @@
+//! Resolving which chat provider the channel runtime should build.
+
+use crate::config::Config;
+use crate::inference::provider;
+
+/// How the channels runtime should construct its default chat provider.
+///
+/// Issue #3098 sub-issue 1: the runtime used to ignore the per-workload
+/// `chat_provider` routing and unconditionally build a cloud chain, so
+/// Telegram (and other channels) never honored a user's local-Ollama /
+/// BYOK selection. `resolve_chat_workload` inspects the resolved chat
+/// workload string and chooses between the managed-cloud selection (Cloud)
+/// and dispatching to the unified workload factory (Workload).
+pub(super) enum ChatWorkloadResolution {
+ /// Preserve the managed-cloud selection and `config.default_model`.
+ Cloud,
+ /// Build the channel provider via `create_chat_provider("chat", config)`.
+ Workload {
+ provider_string: String,
+ slug: String,
+ },
+}
+
+pub(super) fn resolve_chat_workload(config: &Config) -> ChatWorkloadResolution {
+ let resolved = provider::provider_for_role("chat", config);
+ let trimmed = resolved.trim();
+ if trimmed.is_empty() || trimmed == "cloud" || trimmed == provider::INFERENCE_BACKEND_ID {
+ return ChatWorkloadResolution::Cloud;
+ }
+ let slug = trimmed
+ .split_once(':')
+ .map(|(s, _)| s.to_string())
+ .unwrap_or_else(|| trimmed.to_string());
+ ChatWorkloadResolution::Workload {
+ provider_string: trimmed.to_string(),
+ slug,
+ }
+}