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: reformat long lines and restructure match arms for readability
Steven Enamakelde73fcaef5b7
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rsindex 61a8f5562a..b12d3489ae 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/tool_output.rs@@ -170,7 +170,9 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext> for Too) -> TaResult<()> {// Taken out before validation and before the tool runs: it is an// argument to the summary of the result, not to the tool.- if let Some(focus) = crate::inference::tokenjuice::focus::take_summary_focus(&mut call.arguments) {+ if let Some(focus) =+ crate::inference::tokenjuice::focus::take_summary_focus(&mut call.arguments)+ {tracing::debug!(tool = %call.name,call_id = %call.id,diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rsindex 59e38ac1e6..7f0bb34779 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_compaction_tests.rs@@ -270,13 +270,8 @@ async fn a_focus_belongs_to_its_own_call() {mw.before_tool(&mut ctx, &(), &mut call).await.unwrap();let mut result = tool_result("web_fetch", &"page ".repeat(200));- let (_, requests) = with_module(mw.after_tool(- &mut ctx,- &(),- &invocation("b", "web_fetch"),- &mut result,- ))- .await;+ let (_, requests) =+ with_module(mw.after_tool(&mut ctx, &(), &invocation("b", "web_fetch"), &mut result)).await;assert_eq!(requests[0].focus, None);}diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rsindex c841589c08..bab20a957a 100644--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_output_tests.rs@@ -49,7 +49,9 @@ fn estimate_text_tokens_charges_each_image_marker_once() {#[tokio::test]async fn unavailable_summarization_is_disclosed_in_the_payload() {use crate::inference::tokenjuice::module_stub::FAILED_NOTICE;- let mw = summarizer_mw(StubSummarizer::replying(Err(anyhow::anyhow!("model offline"))));+ let mw = summarizer_mw(StubSummarizer::replying(Err(anyhow::anyhow!(+ "model offline"+ ))));let mut ctx = ctx();let mut result = tool_result("test_tool", "RAW-TOOL-OUTPUT");diff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rsindex 1a92a7234f..4b53fa4719 100644--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs@@ -78,9 +78,10 @@ pub(crate) fn unary_child_context(impl PayloadSummarizer for SubagentPayloadSummarizer {fn prepare(&self, parent_ctx: &RunContext<OpenHumanRunContext>) -> Result<PreparedGenerate> {- let parent = parent_ctx.data.parent.clone().ok_or_else(|| {- anyhow!("payload summarizer needs the turn's ParentExecutionContext")- })?;+ let parent =+ parent_ctx.data.parent.clone().ok_or_else(|| {+ anyhow!("payload summarizer needs the turn's ParentExecutionContext")+ })?;let definition = self.definition.clone();let thread_id = parent_ctx.data.thread_id.clone();let max_output_tokens = definition@@ -125,7 +126,11 @@ impl PayloadSummarizer for SubagentPayloadSummarizer {let mut harness: AgentHarness<(), OpenHumanRunContext> = AgentHarness::new();harness.with_policy(policy);let provider_model = super::model::MaxTokensModel::new(- source.build_summarizer(&model, definition.temperature, thread_id.as_deref())?,+ source.build_summarizer(+ &model,+ definition.temperature,+ thread_id.as_deref(),+ )?,max_output_tokens,);harness@@ -142,7 +147,10 @@ impl PayloadSummarizer for SubagentPayloadSummarizer {.invoke_in_context(&(),child_context,- vec![Message::system(system_prompt), Message::user(request.prompt)],+ vec![+ Message::system(system_prompt),+ Message::user(request.prompt),+ ],).await?;Ok(run.text().unwrap_or_default())diff --git a/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rsindex fb3fe91b7d..bf31420729 100644--- a/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/focus_tests.rs@@ -3,7 +3,10 @@ use super::*;#[test]fn the_focus_is_taken_out_of_the_arguments() {let mut args = json!({ "url": "https://example.com", "summary_focus": " the pricing " });- assert_eq!(take_summary_focus(&mut args).as_deref(), Some("the pricing"));+ assert_eq!(+ take_summary_focus(&mut args).as_deref(),+ Some("the pricing")+ );assert_eq!(args, json!({ "url": "https://example.com" }));}@@ -29,5 +32,8 @@ fn arguments_without_a_focus_are_untouched() {fn the_property_is_an_optional_string() {let property = summary_focus_property();assert_eq!(property["type"], "string");- assert!(property["description"].as_str().unwrap().contains("summarized"));+ assert!(property["description"]+ .as_str()+ .unwrap()+ .contains("summarized"));}diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod.rs b/crates/openhuman-core/src/inference/tokenjuice/mod.rsindex 33feccb25f..f83d260f65 100644--- a/crates/openhuman-core/src/inference/tokenjuice/mod.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/mod.rs@@ -278,33 +278,31 @@ pub async fn compact_tool_output(call: ToolOutputCompaction<'_>) -> CompactedToocontext_token,scope,};- let response: types::CompactResponse =- match proxy.call(methods::COMPACT_WITH, (request,)).await {- Ok(response) => response,- // A module released before contract 1.1 has no `CompactWith`.- // Fall back to the positional member it does have, without the- // focus or a summary.- Err(error) => {- log::debug!(- "[tokenjuice] CompactWith failed, retrying as Compact tool={tool_name}: {error}"- );- match proxy- .call(- methods::COMPACT,- (content.clone(), tool_name.to_string(), enabled, profile),- )- .await- {- Ok(response) => response,- Err(error) => {- log::debug!(- "[tokenjuice] module compaction failed, passing through: {error}"- );- return CompactedToolOutput::unchanged(content);- }+ let response: types::CompactResponse = match proxy.call(methods::COMPACT_WITH, (request,)).await+ {+ Ok(response) => response,+ // A module released before contract 1.1 has no `CompactWith`.+ // Fall back to the positional member it does have, without the+ // focus or a summary.+ Err(error) => {+ log::debug!(+ "[tokenjuice] CompactWith failed, retrying as Compact tool={tool_name}: {error}"+ );+ match proxy+ .call(+ methods::COMPACT,+ (content.clone(), tool_name.to_string(), enabled, profile),+ )+ .await+ {+ Ok(response) => response,+ Err(error) => {+ log::debug!("[tokenjuice] module compaction failed, passing through: {error}");+ return CompactedToolOutput::unchanged(content);}}- };+ }+ };record_savings(&response);compacted_from(response)}diff --git a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rsindex e904de5c79..18ceaf2c07 100644--- a/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs+++ b/crates/openhuman-core/src/inference/tokenjuice/mod_tests.rs@@ -65,13 +65,19 @@ async fn the_module_calls_back_for_a_summary_written_for_the_focus() {.await;assert_eq!(output.summarized_from_bytes, Some(content.len()));- assert!(output.text.starts_with("the rate limit is 60 requests a minute"));+ assert!(output+ .text+ .starts_with("the rate limit is 60 requests a minute"));assert!(output.text.contains(RETRIEVE_TOOL_NAME),"the original stays retrievable: {}",output.text);- let request = seen.lock().unwrap().clone().expect("the module called back");+ let request = seen+ .lock()+ .unwrap()+ .clone()+ .expect("the module called back");assert!(request.prompt.contains("Caller focus: the rate limits"));assert!(request.system.contains("caller focus"));}