Skip to content

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

fix(inference): allow local runtimes without an OpenHuman session

Eloi Torrentsf49a3478b4ad
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
index 630305e99c..ec29ee86bd 100644
--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
@@ -272,8 +272,17 @@ pub(super) async fn evaluate_inference_readiness(
config,
)
});
- let needs_session = crate::inference::provider::factory::current_host_requires_session()
- || needs_backend_session;
+ let needs_session = needs_backend_session
+ || (crate::inference::provider::factory::current_host_requires_session()
+ && agent_nodes.iter().any(|node| {
+ let provider = crate::inference::provider::factory::provider_for_role(
+ agent_node_role(config, node),
+ config,
+ );
+ !crate::inference::provider::factory::access_gates::provider_uses_independent_auth(
+ &provider,
+ )
+ }));
// Layer 1: signed-out is the cheapest, most decisive check. Session-wide
// — checked once for the whole graph, not per node/role.
@@ -304,7 +313,9 @@ pub(super) async fn evaluate_inference_readiness(
// behavior for a real signed-out desktop user is unchanged — only the
// (redundant, in that case) early rejection here is test-only skipped.
#[cfg(not(test))]
- let session_result = if needs_backend_session {
+ let session_result = if !needs_session {
+ Ok(())
+ } else if needs_backend_session {
crate::inference::provider::factory::access_gates::verify_backend_session_active(config)
} else {
crate::inference::provider::factory::access_gates::verify_session_active(config)
diff --git a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
index 3c3d0e1961..4fdaa39ce4 100644
--- a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
@@ -623,3 +623,25 @@ async fn flows_run_fails_cleanly_without_invoking_engine_when_inference_not_read
// `SignedOutTestGuard` restores the prior flag on drop at the end of this
// scope — no other test observes this override.
}
+
+#[tokio::test]
+async fn local_agent_flow_is_ready_without_openhuman_session() {
+ let _inference = crate::inference::inference_test_guard();
+ let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);
+ let tmp = TempDir::new().unwrap();
+ let mut config = test_config(&tmp);
+ config.chat_provider = Some("omlx:test-model".into());
+ config.memory_provider = Some("omlx:test-model".into());
+ let g = graph(json!({
+ "nodes": [
+ { "id": "t", "kind": "trigger", "name": "Manual" },
+ { "id": "a", "kind": "agent", "name": "Local", "config": { "prompt": "test" } }
+ ],
+ "edges": [{ "from_node": "t", "to_node": "a" }]
+ }));
+ let errors = validate_inference_readiness(&config, &g).await;
+ assert!(
+ errors.is_empty(),
+ "local flow must not need a session: {errors:?}"
+ );
+}
diff --git a/crates/openhuman-core/src/inference/provider/README.md b/crates/openhuman-core/src/inference/provider/README.md
index b9d1bdb53e..bac0481c95 100644
--- a/crates/openhuman-core/src/inference/provider/README.md
+++ b/crates/openhuman-core/src/inference/provider/README.md
@@ -114,3 +114,9 @@ consumers: the agent harness (`agent/harness/session/builder/factory.rs`,
- `crate_openai_tests.rs`, `crate_anthropic_tests.rs`,
`openhuman_backend_model_tests.rs`, `openai_codex_tests.rs` — per-transport
model builders.
+
+Local runtime chat providers (Ollama, LM Studio, MLX, oMLX, local-openai)
+and caller-authenticated Claude Code/Agent SDK subprocesses do not require
+an OpenHuman session, including when used by channel agents. Claude subprocesses
+still contact their external provider and remain subject to the LocalOnly privacy
+gate. Managed inference and custom cloud routes retain their session checks.
diff --git a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
index c4cc718879..87bb164712 100644
--- a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
@@ -121,13 +121,31 @@ pub(super) fn emit_inference_egress(role: &str, provider: &str) {
);
}
+/// Caller-owned runtimes authenticate independently of the OpenHuman account.
+/// Claude subprocesses still use external inference and remain subject to the
+/// privacy gate; this exemption only concerns OpenHuman registration.
+pub(crate) fn provider_uses_independent_auth(provider: &str) -> bool {
+ let p = provider.trim();
+ crate::inference::local::profile::is_local_provider_string(p)
+ || p.starts_with(crate::inference::provider::claude_code::PROVIDER_PREFIX)
+ || p == CLAUDE_AGENT_SDK_PROVIDER
+ || p.starts_with(CLAUDE_AGENT_SDK_PREFIX)
+}
+
+pub(crate) fn verify_provider_session(config: &Config, provider: &str) -> anyhow::Result<()> {
+ if provider_uses_independent_auth(provider) {
+ log::debug!("[chat-factory] caller-owned runtime uses independent authentication");
+ return Ok(());
+ }
+ verify_session_active(config)
+}
+
/// Verify the user has an active OpenHuman backend session.
///
/// Without this check, an unregistered user can configure every workload
/// to use a custom cloud provider and bypass the session requirement
-/// entirely. This function ensures that custom providers (Ollama,
-/// `<slug>:<model>`) are only reachable when the workspace holds a valid
-/// `app-session` JWT.
+/// entirely. Custom cloud routes require an `app-session` JWT; caller-owned
+/// local runtimes and Claude subprocesses use `verify_provider_session` instead.
///
/// `pub(crate)`: also reused directly by the flows provider-connectivity
/// author gate (issue B45, `openhuman::flows::ops::evaluate_inference_readiness`)
diff --git a/crates/openhuman-core/src/inference/provider/factory/chat_model.rs b/crates/openhuman-core/src/inference/provider/factory/chat_model.rs
index 6e9e7834c4..da085aa025 100644
--- a/crates/openhuman-core/src/inference/provider/factory/chat_model.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/chat_model.rs
@@ -228,7 +228,7 @@ pub(super) fn create_chat_model_from_string_with_model_id_inner(
return result;
}
if let Some(result) =
- try_create_local_runtime_chat_model_from_string(role, &resolved, config, true)
+ try_create_local_runtime_chat_model_from_string(role, &resolved, config)
{
return result;
}
diff --git a/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs b/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
index 8f8c41f8f6..6e19b77cd4 100644
--- a/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/local_runtime.rs
@@ -3,8 +3,7 @@
use super::*;
use crate::inference::provider::crate_openai;
-#[cfg(not(test))]
-use crate::inference::provider::factory::access_gates::verify_session_active;
+use crate::inference::provider::factory::access_gates::verify_provider_session;
/// Local OpenAI-compatible runtimes (Ollama / LM Studio / MLX / OMLX /
/// local-openai) as a crate-native [`ChatModel`] (issue #4727).
@@ -16,8 +15,8 @@ use crate::inference::provider::factory::access_gates::verify_session_active;
/// `ollama_base_url_from_config` / `lm_studio_base_url` / profile helpers. It
/// runs the host access gates for custom/local providers —
/// [`enforce_local_only_inference`] (privacy mode) +
-/// [`verify_session_active`] (session requirement) — so routing a local runtime
-/// here cannot bypass either. Temperature rides the per-call `ModelRequest` on
+/// [`verify_provider_session`] (provider-specific authentication). Local runtimes
+/// do not require an OpenHuman account. Temperature rides the per-call `ModelRequest` on
/// the crate path (parity with the managed-backend cutover; the `@<temp>` suffix
/// still bakes a fixed override).
///
@@ -30,14 +29,13 @@ pub(super) fn try_create_local_runtime_chat_model(
config: &Config,
) -> OptionalChatModelResult {
let resolved = provider_for_role(role, config);
- try_create_local_runtime_chat_model_from_string(role, &resolved, config, true)
+ try_create_local_runtime_chat_model_from_string(role, &resolved, config)
}
pub(super) fn try_create_local_runtime_chat_model_from_string(
role: &str,
provider: &str,
config: &Config,
- require_session: bool,
) -> OptionalChatModelResult {
use crate::inference::local::profile::{LOCAL_OPENAI_PROFILE, MLX_PROFILE, OMLX_PROFILE};
@@ -51,16 +49,13 @@ pub(super) fn try_create_local_runtime_chat_model_from_string(
return None;
}
- // Preserve host privacy-mode refusal + the session requirement for
- // custom/local providers.
+ // Preserve privacy policy; local runtime authentication does not depend on
+ // an OpenHuman backend session.
if let Err(e) = enforce_local_only_inference(role, &p) {
return Some(Err(e));
}
- if require_session {
- #[cfg(not(test))]
- if let Err(e) = verify_session_active(config) {
- return Some(Err(e));
- }
+ if let Err(e) = verify_provider_session(config, provider) {
+ return Some(Err(e));
}
// Egress spine (privacy epic S2, #4436): committed to a local runtime here
@@ -201,6 +196,6 @@ pub(crate) fn create_local_chat_model_from_string(
provider: &str,
config: &Config,
) -> anyhow::Result<(Arc<dyn ChatModel<()>>, String)> {
- try_create_local_runtime_chat_model_from_string("chat", provider, config, false)
+ try_create_local_runtime_chat_model_from_string("chat", provider, config)
.ok_or_else(|| anyhow::anyhow!("unsupported local provider string '{provider}'"))?
}
diff --git a/crates/openhuman-core/src/inference/provider/factory/subprocess_providers.rs b/crates/openhuman-core/src/inference/provider/factory/subprocess_providers.rs
index 14ee47aeeb..8c2be9cc2c 100644
--- a/crates/openhuman-core/src/inference/provider/factory/subprocess_providers.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/subprocess_providers.rs
@@ -1,8 +1,7 @@
//! Subprocess-backed providers: the Claude Agent SDK and the Claude Code CLI.
use super::*;
-#[cfg(not(test))]
-use crate::inference::provider::factory::access_gates::verify_session_active;
+use crate::inference::provider::factory::access_gates::verify_provider_session;
/// Build the Claude Agent SDK subprocess directly as a crate model. This is a
/// prompt-guided model: TinyAgents owns its text-tool protocol, while the
@@ -41,8 +40,7 @@ pub(super) fn prepare_claude_agent_sdk_chat_model(
if let Err(error) = enforce_local_only_inference(role, provider) {
return Some(Err(error));
}
- #[cfg(not(test))]
- if let Err(error) = verify_session_active(config) {
+ if let Err(error) = verify_provider_session(config, provider) {
return Some(Err(error));
}
Some(Ok(model))
@@ -99,8 +97,7 @@ pub(super) fn try_create_claude_code_chat_model_from_string(
if let Err(error) = enforce_local_only_inference(role, provider) {
return Some(Err(error));
}
- #[cfg(not(test))]
- if let Err(error) = verify_session_active(config) {
+ if let Err(error) = verify_provider_session(config, provider) {
return Some(Err(error));
}
let workspace = crate::inference::provider::claude_code::workspace_dir_from_config(config);
diff --git a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
index 0fa1c0f323..6762abf92e 100644
--- a/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
+++ b/crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs
@@ -659,3 +659,49 @@ async fn from_string_external_provider_emits_egress_realpath() {
"external inference via create_test_chat_model_from_string must publish ExternalTransferPending"
);
}
+
+#[tokio::test]
+async fn caller_owned_models_build_without_openhuman_session() {
+ let _guard = crate::inference::inference_test_guard();
+ let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);
+ let dir = tempfile::tempdir().unwrap();
+ let config = Config {
+ config_path: dir.path().join("config.toml"),
+ workspace_dir: dir.path().join("workspace"),
+ ..Config::default()
+ };
+ for provider in [
+ "ollama:test-model",
+ "lmstudio:test-model",
+ "mlx:test-model",
+ "omlx:test-model",
+ "local-openai:test-model",
+ "claude_agent_sdk:test-model",
+ ] {
+ create_chat_model_from_string("chat", provider, &config, 0.0)
+ .unwrap_or_else(|e| panic!("{provider} must build while signed out: {e}"));
+ }
+ // CLI discovery is machine-specific; verify its authentication gate without
+ // starting or requiring an installed CLI.
+ crate::inference::provider::factory::access_gates::verify_provider_session(
+ &config,
+ "claude-code:test-model",
+ )
+ .expect("Claude Code uses its own authentication while OpenHuman is signed out");
+ // Exercise the real gate (cloud constructors skip auth under cfg(test)).
+ for provider in [
+ "openhuman",
+ "openai:test-model",
+ "unknown:test-model",
+ "cloud",
+ ] {
+ let error = crate::inference::provider::factory::access_gates::verify_provider_session(
+ &config, provider,
+ )
+ .unwrap_err();
+ assert!(
+ error.to_string().contains("SESSION_EXPIRED"),
+ "{provider}: {error}"
+ );
+ }
+}
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs b/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
index 7aa4e23871..2db08de6dd 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
@@ -18,7 +18,7 @@ Capability {
name: "Configure Local Provider",
domain: "local_ai",
category: CapabilityCategory::LocalAI,
- description: "Select Ollama, LM Studio, MLX, or a generic local OpenAI-compatible server as the local model provider and configure the endpoint.",
+ description: "Select Ollama, LM Studio, MLX, oMLX, or a generic local OpenAI-compatible server. Local chat inference does not require an OpenHuman account.",
how_to: "Connections → API keys → LLM, or use provider strings: ollama:<model>, lmstudio:<model>, mlx:<model>, local-openai:<model>",
status: CapabilityStatus::Beta,
privacy: None,
diff --git a/docs/RELEASE-MANUAL-SMOKE.md b/docs/RELEASE-MANUAL-SMOKE.md
index 8b23ad1773..c1e9febe25 100644
--- a/docs/RELEASE-MANUAL-SMOKE.md
+++ b/docs/RELEASE-MANUAL-SMOKE.md
@@ -58,6 +58,8 @@ Applies to every release, all platforms.
### Cross-platform
+- [ ] **Caller-owned inference works without an OpenHuman session** — In a local workspace without an OpenHuman login, configure Ollama/LM Studio/MLX/oMLX/local-openai or an independently authenticated Claude Code/Agent SDK provider. Run chat and an agent flow routed entirely to that provider. Expected: no OpenHuman session requirement. Select managed inference instead: it must still require a backend session. With LocalOnly privacy enabled, local runtimes remain allowed and Claude subprocesses remain blocked as external inference.
+
- [ ] **ChatGPT sign-in works after onboarding** — In desktop Settings > AI > Providers, add OpenAI and complete ChatGPT sign-in from its provider dialog. Expected: OpenAI is registered without an API key and existing workload routes are preserved. Reopen the provider dialog and disconnect. Expected: the connected badge clears, OpenAI is removed, and workloads no longer reference it. A failed callback shows a localized error without logging the redirect URL.
- [ ] **First launch flow completes for a brand-new user** — Fresh OS user account, no `~/.openhuman` directory. Walk through onboarding to first agent reply. Expected: no crashes, no permission deadlocks, no stale-config errors.
- [ ] **A background sub-agent result lands in Chat exactly once** — Ask for something that delegates to a background sub-agent (e.g. "how's my day looking?" with a calendar connected, or any `delegate_*` archetype), then wait for it to finish. Expected: the delivered reply appears once, as a normal agent message; no user-side (right-aligned) bubble showing raw `**markdown**`, and still one copy after switching to another thread and back (#5933).
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index 41d0c661c8..349d7a1834 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -132,7 +132,7 @@ Canonical mapping of every product feature to its test source(s). Drives gap-fil
| ID | Feature | Layer | Test path(s) | Status | Notes |
| ----- | ---------------------------------- | ----- | ------------------------------------------------------------------------------- | ------ | -------------------------------------------------------- |
-| 3.2.1 | Local Inference Execution | WD | `local-model-runtime.spec.ts` | ✅ | |
+| 3.2.1 | Local Inference Execution | RU+WD | `local-model-runtime.spec.ts`, `crates/openhuman-core/src/inference/provider/factory_crate_native_tests.rs`, `crates/openhuman-core/src/flows/ops_agent_binding_tests.rs` | ✅ | Caller-owned model construction and local agent-flow readiness work without an OpenHuman session; cloud session refusal is retained. |
| 3.2.2 | Resource Handling (CPU/GPU/Memory) | RU | `crates/openhuman-core/src/inference/device.rs` | 🟡 | Detection unit; runtime constraint manual |
| 3.2.3 | Runtime Failure Handling | RU+WD | `local-model-runtime.spec.ts` | ✅ | |
| 3.2.4 | LM Studio Chat Completions | RU+RI | `crates/openhuman-core/src/inference/local/service/public_infer_tests.rs`, `tests/json_rpc_e2e.rs` | ✅ | Covers prompt/chat success and non-success status errors |