Skip to content

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

feat(inference): add thread-based reasoning preference

Steven Enamakelc94b432705f9
diff --git a/crates/openhuman-core/src/inference/reasoning.rs b/crates/openhuman-core/src/inference/reasoning.rs
index 3940d15043..aefc60b583 100644
--- a/crates/openhuman-core/src/inference/reasoning.rs
+++ b/crates/openhuman-core/src/inference/reasoning.rs
@@ -37,6 +37,20 @@ pub(crate) fn reasoning_for_config(config: &Config) -> Option<ReasoningConfig> {
None
}
+/// A thread preference takes precedence over the selected model's config.
+pub(crate) fn turn_reasoning(
+ dispatch: &crate::core::runtime::DispatchCtx,
+ thread_id: Option<&str>,
+ config: Option<&Config>,
+) -> Option<ReasoningConfig> {
+ if let Some(effort) = thread_id.and_then(|thread_id| {
+ crate::agent::tinyagents::thread_reasoning::thread_effort(dispatch, thread_id)
+ }) {
+ return Some(ReasoningConfig::effort(effort));
+ }
+ config.and_then(reasoning_for_config)
+}
+
/// Reasoning configuration for one root turn. The store snapshots an explicit
/// thread choice once; subsequent updates apply to later turns only.
pub(crate) fn turn_reasoning_for(
@@ -49,16 +63,19 @@ pub(crate) fn turn_reasoning_for(
}
let dispatch = ctx.dispatch_ctx();
- let thread_id = ctx.thread_id.as_deref();
- let reasoning = crate::agent::tinyagents::thread_reasoning::store(&dispatch)
- .reasoning_for_turn(
- thread_id.map(tinyagents_harness::ids::ThreadId::new).as_ref(),
- max_output_tokens,
- )
- .or_else(|| {
- reasoning_for_config(config?)
- .map(|reasoning| reasoning.with_output_room(max_output_tokens))
- });
+ let reasoning = if let Some(thread_id) = ctx.thread_id.as_deref() {
+ crate::agent::tinyagents::thread_reasoning::store(&dispatch)
+ .reasoning_for_turn(
+ Some(&tinyagents_harness::ids::ThreadId::new(thread_id)),
+ max_output_tokens,
+ )
+ } else {
+ None
+ }
+ .or_else(|| {
+ reasoning_for_config(config?)
+ .map(|reasoning| reasoning.with_output_room(max_output_tokens))
+ });
if let Some(reasoning) = reasoning.as_ref() {
log::debug!(
diff --git a/crates/openhuman-core/src/inference/reasoning_tests.rs b/crates/openhuman-core/src/inference/reasoning_tests.rs
index 343dc3217d..6137624f01 100644
--- a/crates/openhuman-core/src/inference/reasoning_tests.rs
+++ b/crates/openhuman-core/src/inference/reasoning_tests.rs
@@ -1,4 +1,7 @@
use super::*;
+use crate::agent::tinyagents::thread_reasoning::{
+ apply_requested_effort, parse_reasoning_effort, set_thread_effort, thread_effort,
+};
#[test]
fn parses_wire_tokens_and_aliases() {