Skip to content

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

fix(flows): check the harness runtime provider during readiness

Eloi Torrents36622d4b0ba2
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/factory.rs b/crates/openhuman-core/src/agent/harness/session/builder/factory.rs
index 1712541329..4702a03a78 100644
--- a/crates/openhuman-core/src/agent/harness/session/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/harness/session/builder/factory.rs
@@ -391,30 +391,8 @@ impl Agent {
// legacy callers. A built-in Master Agent has an explicit
// `hint:coding`, while existing pre-registry callers continue using
// `config.default_model` unchanged.
- let master_model_hint = config
- .default_model
- .is_none()
- .then(|| {
- target_def.and_then(|def| {
- if def.id == "orchestrator" {
- match &def.model {
- crate::agent::harness::definition::ModelSpec::Hint(hint) => {
- Some(format!("hint:{hint}"))
- }
- _ => None,
- }
- } else {
- None
- }
- })
- })
- .flatten();
- let provider_role = provider_role_for(
- agent_id,
- master_model_hint
- .as_deref()
- .or(config.default_model.as_deref()),
- );
+ let provider_role =
+ provider_role_for_definition(agent_id, config.default_model.as_deref(), target_def);
// Retry/backoff is now owned by the crate `RetryPolicy` at the harness
// model call (issue #4249, Phase 3a) — see `tinyagents::run_policy_for`.
// The turn path therefore no longer wraps the resolved provider in
@@ -1442,6 +1420,33 @@ pub(crate) fn provider_role_for(agent_id: &str, default_model: Option<&str>) ->
#[path = "factory_provider_role_tests_tests.rs"]
mod provider_role_tests;
+/// Resolve the initial harness workload without constructing a session.
+/// Flow readiness shares this path so it checks the provider used at runtime.
+pub(crate) fn provider_role_for_definition(
+ agent_id: &str,
+ default_model: Option<&str>,
+ target_def: Option<&crate::agent::harness::definition::AgentDefinition>,
+) -> &'static str {
+ let master_hint = default_model
+ .is_none()
+ .then(|| {
+ target_def.and_then(|def| {
+ if def.id == "orchestrator" {
+ match &def.model {
+ crate::agent::harness::definition::ModelSpec::Hint(hint) => {
+ Some(format!("hint:{hint}"))
+ }
+ _ => None,
+ }
+ } else {
+ None
+ }
+ })
+ })
+ .flatten();
+ provider_role_for(agent_id, master_hint.as_deref().or(default_model))
+}
+
pub(crate) fn derive_profile_workspace_descriptor(
action_dir: &std::path::Path,
profile: Option<&crate::agent::profiles::AgentProfile>,
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/mod.rs b/crates/openhuman-core/src/agent/harness/session/builder/mod.rs
index dcdc1b6830..e1b25c16b6 100644
--- a/crates/openhuman-core/src/agent/harness/session/builder/mod.rs
+++ b/crates/openhuman-core/src/agent/harness/session/builder/mod.rs
@@ -6,6 +6,8 @@
//! registry from a loaded [`Config`]. Per-turn behaviour lives in
//! [`super::turn`]; accessors and run-helpers live in [`super::runtime`].
+pub(crate) use factory::provider_role_for_definition;
+
mod builder_build;
mod factory;
mod helpers;
diff --git a/crates/openhuman-core/src/agent/harness/session/mod.rs b/crates/openhuman-core/src/agent/harness/session/mod.rs
index 7047ab77cc..e79f76b0be 100644
--- a/crates/openhuman-core/src/agent/harness/session/mod.rs
+++ b/crates/openhuman-core/src/agent/harness/session/mod.rs
@@ -33,6 +33,8 @@
//! `crate::agent`, which re-exports them from this module.
//! The child files are an implementation detail.
+pub(crate) use builder::provider_role_for_definition;
+
mod builder;
mod migration;
mod runtime;
diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
index ec29ee86bd..a1af48de4c 100644
--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs
+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs
@@ -161,17 +161,43 @@ pub(super) async fn cached_probe_inference_readiness(
/// 3. Otherwise, caps.rs's own default role (`"summarization"`, its fallback
/// absent a `role` field on the completion request).
///
-/// A static `agent_ref` that instead resolves to a shipped/TOML harness
-/// `AgentDefinition` (`AgentRoute::Harness`) can *also* pin a model via
-/// `ModelSpec::Exact`/`ModelSpec::Hint` — but `ModelSpec::Inherit` (the
-/// default) resolves against the *parent* agent's live model at spawn time,
-/// which this static, pre-run gate has no parent turn to read. Resolving only
-/// the Exact/Hint cases here — while silently mis-defaulting every
-/// `Inherit`-using definition — would be a half-correct, fragile lookup, so
-/// this case falls back to the default role rather than guess.
-/// TODO(B45): resolve agent_ref-pinned model for harness `AgentDefinition`s
-/// once a parent-model-free resolution path exists.
+/// Known harness agents use the session builder's provider-role resolver.
+/// Definition hints are interpreted exactly as at construction; sub-agent
+/// ModelSpec resolution is a separate runtime path and is not guessed here.
pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) -> &'static str {
+ if let Some(agent_ref) = node
+ .config
+ .get("agent_ref")
+ .and_then(Value::as_str)
+ .map(str::trim)
+ .filter(|s| !s.is_empty() && !s.starts_with('='))
+ {
+ use crate::agent::harness::definition::AgentDefinitionRegistry;
+ if let Err(error) = AgentDefinitionRegistry::init_global(&config.workspace_dir) {
+ tracing::debug!(target: "flows", %error,
+ "[flows] readiness: agent definition registry unavailable; using registry fallback");
+ }
+ let definition = AgentDefinitionRegistry::global().and_then(|r| r.get(agent_ref));
+ let custom = crate::agent::registry::find_custom_in_config(config, agent_ref);
+ if definition.is_some() || custom.is_some() {
+ let entry_model = if definition.is_some() {
+ None
+ } else {
+ custom.as_ref().and_then(|entry| entry.model.as_deref())
+ };
+ let override_model =
+ crate::flows::tinyflows::caps::resolve_node_model(&node.config, entry_model).map(
+ |model| crate::flows::tinyflows::caps::harness_model_default_override(&model),
+ );
+ return crate::agent::harness::session::provider_role_for_definition(
+ agent_ref,
+ override_model
+ .as_deref()
+ .or(config.default_model.as_deref()),
+ definition,
+ );
+ }
+ }
let pinned_model = node
.config
.get("model")
@@ -182,23 +208,6 @@ pub(super) fn agent_node_role(config: &Config, node: &tinyflows::model::Node) ->
return crate::inference::provider::role_for_model_tier(model);
}
- let static_agent_ref = node
- .config
- .get("agent_ref")
- .and_then(Value::as_str)
- .map(str::trim)
- .filter(|s| !s.is_empty() && !s.starts_with('='));
- if let Some(agent_ref) = static_agent_ref {
- if let Some(entry_model) = crate::agent::registry::find_custom_in_config(config, agent_ref)
- .and_then(|entry| entry.model)
- {
- let entry_model = entry_model.trim();
- if !entry_model.is_empty() {
- return crate::inference::provider::role_for_model_tier(entry_model);
- }
- }
- }
-
"summarization"
}
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 a9d59b43d1..3025558876 100644
--- a/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_agent_binding_tests.rs
@@ -686,3 +686,65 @@ async fn claude_agent_flow_readiness_does_not_require_an_openhuman_session() {
}
}
}
+
+#[test]
+fn harness_readiness_uses_runtime_role_and_node_override() {
+ let tmp = TempDir::new().unwrap();
+ let mut config = test_config(&tmp);
+ config.default_model = None;
+ let mut g = graph(json!({
+ "nodes": [
+ { "id": "t", "kind": "trigger", "name": "Manual" },
+ { "id": "a", "kind": "agent", "name": "Agent",
+ "config": { "agent_ref": "orchestrator", "prompt": "go" } }
+ ],
+ "edges": [{"from_node": "t", "to_node": "a"}]
+ }));
+ let node = g.nodes.iter_mut().find(|n| n.id == "a").unwrap();
+ assert_eq!(agent_node_role(&config, node), "coding");
+ config.default_model = Some("hint:reasoning".into());
+ assert_eq!(agent_node_role(&config, node), "reasoning");
+ node.config["model"] = json!("chat-v1");
+ assert_eq!(agent_node_role(&config, node), "chat");
+ node.config["model"] = json!("hint:summarization");
+ assert_eq!(agent_node_role(&config, node), "summarization");
+ node.config["model"] = json!("custom-model-id");
+ assert_eq!(agent_node_role(&config, node), "chat");
+}
+
+#[tokio::test]
+async fn harness_readiness_checks_session_for_execution_provider() {
+ let _inference = crate::inference::inference_test_guard();
+ let _signed_out = crate::cron::scheduler_gate::SignedOutTestGuard::set(true);
+ let _model =
+ crate::inference::provider::factory::test_provider_override::install_model(Arc::new(
+ tinyagents_harness::testkit::ScriptedModel::replies(vec!["OK"]),
+ ));
+ let g = graph(json!({
+ "nodes": [
+ { "id": "t", "kind": "trigger", "name": "Manual" },
+ { "id": "a", "kind": "agent", "name": "Agent",
+ "config": { "agent_ref": "orchestrator", "prompt": "go" } }
+ ],
+ "edges": [{"from_node": "t", "to_node": "a"}]
+ }));
+ for (runtime, summary, should_reject) in [
+ ("ollama:test", "openhuman", false),
+ ("openhuman", "ollama:test", true),
+ ] {
+ let tmp = TempDir::new().unwrap();
+ let mut config = test_config(&tmp);
+ config.default_model = Some("hint:reasoning".into());
+ config.reasoning_provider = Some(runtime.into());
+ config.memory_provider = Some(summary.into());
+ let errors = validate_inference_readiness(&config, &g).await;
+ assert_eq!(
+ errors.iter().any(|e| e.contains("signed out")),
+ should_reject,
+ "{errors:?}"
+ );
+ if !should_reject {
+ assert!(errors.is_empty(), "{errors:?}");
+ }
+ }
+}
diff --git a/crates/openhuman-core/src/inference/provider/README.md b/crates/openhuman-core/src/inference/provider/README.md
index bac0481c95..d8f37c1d35 100644
--- a/crates/openhuman-core/src/inference/provider/README.md
+++ b/crates/openhuman-core/src/inference/provider/README.md
@@ -120,3 +120,9 @@ 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.
+
+Flow readiness checks the initial provider role used by a known harness agent,
+including node model overrides, custom registry pins, and the session builder's
+configured default. It shares the builder's role resolver before deciding whether
+a session is required. A separate summarization provider does not determine the
+session requirement for that agent.
diff --git a/docs/RELEASE-MANUAL-SMOKE.md b/docs/RELEASE-MANUAL-SMOKE.md
index 33ee1b6a85..5269eeffaf 100644
--- a/docs/RELEASE-MANUAL-SMOKE.md
+++ b/docs/RELEASE-MANUAL-SMOKE.md
@@ -59,7 +59,7 @@ 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.
+- [ ] **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. For a named harness agent, also configure the summarization route to managed inference and verify that the agent still uses its local route; reversing those routes must retain the managed agent's session requirement. 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.
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index d2bc56133d..08ea238a3e 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 | 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.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. Harness readiness shares runtime role selection and tests local/cloud routes against an opposing summarization route. |
| 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 |