Skip to content

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

fix(agent): handle missing runtime session in turn runner

Steven Enamakel268ab49f2959
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session.rs b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
index 4ffc7ee11d..910fd40b45 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session.rs
@@ -744,6 +744,20 @@ impl OpenHumanTurnPrelude {
self.tool_dispatcher.tool_call_format(),
)
.harness_dispatcher();
+ // The thread's reasoning choice rides the effective config this session
+ // was built from (web_chat writes a per-turn override there).
+ run_context.reasoning = self
+ .runtime_config
+ .as_deref()
+ .and_then(crate::agent::tinyagents::reasoning_for_config);
+ if let Some(reasoning) = run_context.reasoning.as_ref() {
+ log::debug!(
+ "[agent][reasoning] turn reasoning effort={:?} budget_tokens={:?} agent={}",
+ reasoning.effort,
+ reasoning.budget_tokens,
+ self.agent_definition_id
+ );
+ }
self.context
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
diff --git a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
index cfb1677370..e4e6edf06f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/harness_assembly.rs
@@ -148,6 +148,9 @@ pub(super) fn assemble_turn_harness(
// `None` for a caller with no thread identity (a sub-agent child, most
// notably), which never runs in plan mode.
run_mode: Option<RunModeHandle>,
+ // The turn's reasoning choice (`OpenHumanRunContext::reasoning`), attached
+ // to every model request this harness builds.
+ reasoning: Option<tinyinference_llm::model::ReasoningConfig>,
) -> AssembledTurnHarness {
let mut harness: AgentHarness<(), OpenHumanRunContext> = AgentHarness::new();
// Cross-route fallback ownership (issue #4249, Workstream 02.2): populate the
@@ -166,6 +169,7 @@ pub(super) fn assemble_turn_harness(
policy.discovery = super::discovery::discovery_policy();
policy.tool_dialect = tool_dialect;
+ policy.default_reasoning = reasoning;
// The session composes its prompt for this same dialect: `ToolsSection`
// renders the protocol block and the catalogue of the visible tools into
// the system prompt (inside the cacheable prefix, counted by
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
index aab9227362..555e9b6e89 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/run_context.rs
@@ -307,6 +307,12 @@ pub struct OpenHumanRunContext {
/// the registry that recovers positional / code-style calls; `Auto`
/// (the default) leaves the harness to choose from the model profile.
pub(crate) tool_dialect: tinyagents_harness::config::ToolDispatcher,
+ /// The reasoning ("thinking") config this turn asks every model call for,
+ /// resolved from the session's effective config
+ /// (`agent::tinyagents::reasoning_for_config`). Turn assembly installs it
+ /// as the harness `RunPolicy::default_reasoning`; `None` leaves the
+ /// provider default.
+ pub(crate) reasoning: Option<tinyinference_llm::model::ReasoningConfig>,
}
impl Default for OpenHumanRunContext {
@@ -348,6 +354,7 @@ impl OpenHumanRunContext {
session_sidecar: Arc::new(Mutex::new(SessionTurnSidecar::default())),
required_output: None,
tool_dialect: tinyagents_harness::config::ToolDispatcher::Auto,
+ reasoning: None,
}
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
index f56e9fd335..05fad760e2 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_runner.rs
@@ -280,6 +280,7 @@ async fn run_turn_via_tinyagents_inner(
.thread_id
.as_deref()
.map(crate::agent::tinyagents::run_mode::handle_for_thread),
+ run_context.reasoning.clone(),
);
// Fail-closed registry validation gate (issue #4249, Workstream 10 — registry).
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.rs
index a60398e046..5b19fd6de2 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
@@ -415,6 +415,23 @@ async fn apply_runtime_settings_updates_kind_and_reasoning() {
.expect("apply");
assert_eq!(cfg.runtime.kind, "desktop");
assert_eq!(cfg.runtime.reasoning_enabled, Some(true));
+ // Aliases are stored as the canonical wire token.
+ assert_eq!(cfg.runtime.reasoning_effort.as_deref(), Some("xhigh"));
+
+ let cleared = RuntimeSettingsPatch {
+ reasoning_effort: Some(String::new()),
+ ..RuntimeSettingsPatch::default()
+ };
+ let _ = apply_runtime_settings(&mut cfg, cleared)
+ .await
+ .expect("apply clear");
+ assert_eq!(cfg.runtime.reasoning_effort, None);
+
+ let bogus = RuntimeSettingsPatch {
+ reasoning_effort: Some("turbo".into()),
+ ..RuntimeSettingsPatch::default()
+ };
+ assert!(apply_runtime_settings(&mut cfg, bogus).await.is_err());
}
#[tokio::test]