Skip to content

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

refactor(session_host): update tool policy type definitions

Steven Enamakelf1a0de3b6484
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 904a541c45..f0e1488e54 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -271,7 +271,9 @@ impl OpenHumanSessionHost {
Some((source, model_name)) => {
let models = source.build(
model_name,
- target_def.map_or(config.default_temperature, |definition| definition.temperature),
+ target_def.map_or(config.default_temperature, |definition| {
+ definition.temperature
+ }),
None,
None,
)?;
diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
index b508ee7a39..f3148ababf 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/host_tools.rs
@@ -64,8 +64,8 @@ pub struct HostTurnTools {
pub policy: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
}
@@ -180,8 +180,8 @@ impl HostTurnTools {
mut self,
policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
) -> Self {
self.policy = Some(policy);
@@ -205,8 +205,8 @@ pub(super) struct MergedHostTurnTools {
pub policy: Option<
Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
>,
pub withheld: HashSet<String>,
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index f1ecef0693..c83c3d1148 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -386,8 +386,8 @@ impl SessionHostBuilder {
mut self,
policy: Arc<
dyn tinyagents_harness::middleware::ToolCallPolicy<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
>,
) -> Self {
self.tool_policy = Some(policy);
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
index c2b2ea60af..e2c557ca00 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat.rs
@@ -297,18 +297,24 @@ fn build_turn_agent(
match (host, turn_model_source) {
(None, Some((source, model))) => {
OpenHumanSessionHost::from_config_with_definition_and_turn_model_source(
- ctx, config, &definition, source, model,
+ ctx,
+ config,
+ &definition,
+ source,
+ model,
)
}
(host, None) => match host {
- Some(host) => OpenHumanSessionHost::from_config_with_host_tools(
- ctx,
- config,
- &definition,
- host,
- session_id,
- ),
- None => OpenHumanSessionHost::from_config_with_definition(ctx, config, &definition),
+ Some(host) => OpenHumanSessionHost::from_config_with_host_tools(
+ ctx,
+ config,
+ &definition,
+ host,
+ session_id,
+ ),
+ None => {
+ OpenHumanSessionHost::from_config_with_definition(ctx, config, &definition)
+ }
},
(Some(host), Some(_)) => Err(anyhow::anyhow!(
"explicit turn model source cannot be combined with host tools"
@@ -349,7 +355,16 @@ pub fn agent_chat_for<'a>(
env: AgentChatEnv,
) -> futures::future::BoxFuture<'a, Result<Outcome<String>, String>> {
agent_chat_for_with_turn_model_source(
- config, target, message, model_override, temperature, thread_id, cwd, route, env, None,
+ config,
+ target,
+ message,
+ model_override,
+ temperature,
+ thread_id,
+ cwd,
+ route,
+ env,
+ None,
)
}
@@ -424,7 +439,16 @@ pub async fn agent_chat_reply_for(
env: AgentChatEnv,
) -> Result<AgentChatReply, String> {
agent_chat_reply_for_inner(
- config, target, message, model_override, temperature, thread_id, cwd, route, env, None,
+ config,
+ target,
+ message,
+ model_override,
+ temperature,
+ thread_id,
+ cwd,
+ route,
+ env,
+ None,
)
.await
}
@@ -500,15 +524,28 @@ async fn agent_chat_reply_for_inner(
"[inference] agent_chat rooting turn tools at cwd={}",
root.display()
);
- let mut agent =
- build_turn_agent(&turn_ctx, &scoped, &target, turn_session_id, temperature, turn_model_source.clone())?;
+ let mut agent = build_turn_agent(
+ &turn_ctx,
+ &scoped,
+ &target,
+ turn_session_id,
+ temperature,
+ turn_model_source.clone(),
+ )?;
// Also thread it as the turn's workspace descriptor so acting tools
// that read `ToolExecutionContext::workspace` (shell) resolve their
// default cwd here, and so spawned sub-agents inherit the same root.
agent.set_workspace_descriptor(Some(tinytools::WorkspaceDescriptor::new(root.clone())));
agent
}
- None => build_turn_agent(&turn_ctx, config, &target, turn_session_id, temperature, turn_model_source)?,
+ None => build_turn_agent(
+ &turn_ctx,
+ config,
+ &target,
+ turn_session_id,
+ temperature,
+ turn_model_source,
+ )?,
};
// Thread-correct resume. `OpenHumanSessionHost::turn` would otherwise auto-load the
// newest transcript for the agent *name*, which is another thread's
diff --git a/crates/openhuman-core/src/triage/escalation.rs b/crates/openhuman-core/src/triage/escalation.rs
index 9c5f58d3fa..7a150a3aef 100644
--- a/crates/openhuman-core/src/triage/escalation.rs
+++ b/crates/openhuman-core/src/triage/escalation.rs
@@ -14,7 +14,7 @@
//! creating child-task lifecycle records.
use crate::core::runtime::DispatchCtx;
-use anyhow::{anyhow, Context};
+use anyhow::{Context, anyhow};
use crate::agent::harness::fork_context::ParentExecutionContext;
use crate::agent::orchestration::parent_context::build_root_parent;
diff --git a/crates/openhuman-core/src/triage/escalation_tests.rs b/crates/openhuman-core/src/triage/escalation_tests.rs
index dedfa13dde..2714df509b 100644
--- a/crates/openhuman-core/src/triage/escalation_tests.rs
+++ b/crates/openhuman-core/src/triage/escalation_tests.rs
@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
use tinyinference_llm::model::{
ChatModel, ModelProfile, ModelRequest, ModelResponse, ModelStream, ModelStreamItem,
};
-use tokio::time::{sleep, timeout, Duration};
+use tokio::time::{Duration, sleep, timeout};
struct TriageReplyModel {
requests: Arc<Mutex<Vec<(String, String, ModelRequest)>>>,
@@ -170,9 +170,11 @@ async fn react_dispatch_keeps_routing_without_creating_child_lifecycle_records()
.map(|tool| tool.name.as_str())
.collect();
assert!(tool_names.contains(&"read_workspace_state"));
- assert!(!tool_names
- .iter()
- .any(|name| { *name == "spawn_subagent" || name.starts_with("delegate_") }));
+ assert!(
+ !tool_names
+ .iter()
+ .any(|name| { *name == "spawn_subagent" || name.starts_with("delegate_") })
+ );
assert!(!tool_names.contains(&"shell"));
assert!(!tool_names.contains(&"file_write"));
drop(requests);