The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(inference): drop managed reasoning wire helpers
Steven Enamakelbeac74c55939
diff --git a/crates/openhuman-tinyhumans/src/inference/managed_reasoning.rs b/crates/openhuman-tinyhumans/src/inference/managed_reasoning.rsindex b21ae8bd10..2e21a0078e 100644--- a/crates/openhuman-tinyhumans/src/inference/managed_reasoning.rs+++ b/crates/openhuman-tinyhumans/src/inference/managed_reasoning.rs@@ -1,5 +1,4 @@-//! Managed-backend wire extensions: the `reasoning` object and the `thread_id`-//! field, derived from the provider-neutral request.+//! OpenHuman's provider-neutral hint for a managed call that disables reasoning.use serde_json::Value;use tinyinference_llm::model::ModelRequest;@@ -16,81 +15,6 @@ pub(crate) fn without_reasoning(mut request: ModelRequest) -> ModelRequest {request}-/// Translate the request's reasoning choice into the managed backend's wire-/// field: the OpenRouter-style `reasoning` object, which the backend forwards-/// upstream.-///-/// Sources, highest first: a `reasoning` object the caller already put in-/// provider options (left alone); the `without_reasoning` hint (core, `REASONING_OFF_METADATA_KEY`), which marks-/// one helper call specifically; the request's provider-neutral-/// `ModelRequest::reasoning` (the user's thinking level, from the harness-/// `RunPolicy::default_reasoning`). The-/// neutral field is consumed here, so the OpenAI-compatible transport does not-/// also emit a top-level `reasoning_effort` for the same choice.-pub(super) fn apply_reasoning_hint(mut request: ModelRequest) -> ModelRequest {- if request.provider_options.get("reasoning").is_some() {- return request;- }- let wants_off = request- .metadata- .get(REASONING_OFF_METADATA_KEY)- .and_then(Value::as_bool)- .unwrap_or(false);- let neutral = request.reasoning.take();- let wire = if wants_off {- Some(serde_json::json!({ "enabled": false }))- } else {- neutral.as_ref().and_then(managed_reasoning_wire)- };- let Some(wire) = wire else {- return request;- };- let mut options = request.provider_options.clone();- if !options.is_object() {- options = Value::Object(serde_json::Map::new());- }- if let Some(map) = options.as_object_mut() {- map.insert("reasoning".to_string(), wire.clone());- }- log::debug!("[inference][managed] reasoning for this call: {wire}");- request.with_provider_options(options)-}--/// The OpenRouter `reasoning` object for a provider-neutral config: `none`-/// disables reasoning, an explicit budget becomes `max_tokens`, and any other-/// effort is sent by name. An empty config sends nothing.-fn managed_reasoning_wire(reasoning: &tinyinference_llm::model::ReasoningConfig) -> Option<Value> {- use tinyinference_llm::model::ReasoningEffort;- if reasoning.effort == Some(ReasoningEffort::None) {- return Some(serde_json::json!({ "enabled": false }));- }- if let Some(budget) = reasoning.budget_tokens {- return Some(serde_json::json!({ "max_tokens": budget }));- }- reasoning- .effort- .map(|effort| serde_json::json!({ "effort": effort.as_str() }))-}--/// Inject this managed model's explicitly owned thread into provider options.-/// This backend-only wire extension is never inferred from ambient state.-pub(super) fn with_thread_id(request: ModelRequest, thread_id: Option<&str>) -> ModelRequest {- let Some(thread_id) = thread_id else {- return request;- };- let mut options = request.provider_options.clone();- if !options.is_object() {- options = Value::Object(serde_json::Map::new());- }- if let Some(map) = options.as_object_mut() {- map.insert(- "thread_id".to_string(),- Value::String(thread_id.to_string()),- );- }- request.with_provider_options(options)-}-#[cfg(test)]#[path = "managed_reasoning_tests.rs"]mod tests;diff --git a/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs b/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rsindex bfb8a428c4..08a68c846d 100644--- a/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs+++ b/crates/openhuman-tinyhumans/src/inference/managed_reasoning_tests.rs@@ -2,22 +2,15 @@ use super::*;use tinyinference_llm::message::Message;#[test]-fn with_thread_id_injects_explicit_thread() {- let request = ModelRequest::new(vec![Message::user("hi")]);- let updated = with_thread_id(request, Some("thread-42"));- assert_eq!(- updated.provider_options["thread_id"],- serde_json::json!("thread-42")- );-}+fn without_reasoning_marks_the_request_without_rewriting_other_options() {+ let options = serde_json::json!({ "transport": { "trace": true } });+ let mut request = ModelRequest::new(vec![Message::user("hi")])+ .with_provider_options(options.clone());+ request.metadata = serde_json::json!({ "caller": "kept" });-#[test]-fn an_explicit_reasoning_option_is_left_alone() {- let request = ModelRequest::new(vec![Message::user("hi")])- .with_provider_options(serde_json::json!({ "reasoning": { "effort": "high" } }));- let updated = apply_reasoning_hint(request);- assert_eq!(- updated.provider_options["reasoning"],- serde_json::json!({ "effort": "high" })- );+ let updated = without_reasoning(request);++ assert_eq!(updated.metadata["caller"], "kept");+ assert_eq!(updated.metadata[REASONING_OFF_METADATA_KEY], true);+ assert_eq!(updated.provider_options, options);}