Skip to content

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

chore(agent): reformat session host and orchestration call sites

Steven Enamakel3453622a4571
diff --git a/crates/openhuman-core/src/agent/attachments/mod.rs b/crates/openhuman-core/src/agent/attachments/mod.rs
index c2683bfb3f..678b3a6f28 100644
--- a/crates/openhuman-core/src/agent/attachments/mod.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod.rs
@@ -169,13 +169,9 @@ pub(crate) async fn thread_action_dir(
let Some(thread_id) = thread_id.filter(|id| !id.is_empty()) else {
return Ok(config.action_dir.clone());
};
- let bound = crate::threads::ops::thread_working_dir(
- ctx,
- threads_dir.to_path_buf(),
- thread_id,
- )
- .await
- .map_err(anyhow::Error::msg)?;
+ let bound = crate::threads::ops::thread_working_dir(ctx, threads_dir.to_path_buf(), thread_id)
+ .await
+ .map_err(anyhow::Error::msg)?;
Ok(bound.unwrap_or_else(|| config.action_dir.clone()))
}
diff --git a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
index 47fbf08d42..6a775b7fe5 100644
--- a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
+++ b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs
@@ -155,25 +155,38 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {
thread_in(&config, "gone", Some(&gone)).await;
std::fs::remove_dir(&gone).unwrap();
- let root = thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, Some("bound"))
- .await
- .unwrap();
+ let root = thread_action_dir(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &config.workspace_dir,
+ Some("bound"),
+ )
+ .await
+ .unwrap();
assert_eq!(root, folder);
for unbound in [Some("unbound"), Some("missing"), Some(""), None] {
assert_eq!(
- thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, unbound)
- .await
- .unwrap(),
+ thread_action_dir(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &config.workspace_dir,
+ unbound
+ )
+ .await
+ .unwrap(),
config.action_dir
);
}
// A folder that disappeared is an error, as in `run_task`, not a silent
// fallback to the global dir.
- assert!(
- thread_action_dir(&crate::core::runtime::DispatchCtx::ambient(), &config, &config.workspace_dir, Some("gone"))
- .await
- .is_err()
- );
+ assert!(thread_action_dir(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &config.workspace_dir,
+ Some("gone")
+ )
+ .await
+ .is_err());
// Stage the way `start_chat` does, then read the way the turn does: its
// request scope comes from a run context carrying the thread folder as its
diff --git a/crates/openhuman-core/src/agent/debug/mod.rs b/crates/openhuman-core/src/agent/debug/mod.rs
index 2c1b247b5e..0c086a2c54 100644
--- a/crates/openhuman-core/src/agent/debug/mod.rs
+++ b/crates/openhuman-core/src/agent/debug/mod.rs
@@ -175,8 +175,12 @@ async fn load_dump_config(
/// Build a real [`Agent`] via `from_config_for_agent`, populate live
/// connected integrations, and render the turn-1 system prompt.
async fn render_via_session(config: &Config, agent_id: &str) -> Result<DumpedPrompt> {
- let mut agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::host_default(), config, agent_id)
- .with_context(|| format!("building session agent for `{agent_id}`"))?;
+ let mut agent = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::host_default(),
+ config,
+ agent_id,
+ )
+ .with_context(|| format!("building session agent for `{agent_id}`"))?;
// Match turn-1 behaviour: fetch the user's active Composio
// connections so the rendered prompt mirrors what the LLM actually
diff --git a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs
index abd286fc3f..05cea7a6d7 100644
--- a/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs
+++ b/crates/openhuman-core/src/agent/debug/prompt_size_tests.rs
@@ -87,8 +87,12 @@ fn session_report_measures_the_visible_belt_not_the_registry() {
..crate::config::Config::default()
};
std::fs::create_dir_all(&config.workspace_dir).unwrap();
- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "critic")
- .expect("critic session build");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "critic",
+ )
+ .expect("critic session build");
let dumped = crate::agent::debug::session_dump(&agent, "critic", String::new());
let report = PromptSizeReport::from_dump(&dumped);
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index 4611221508..4ec8045ab3 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -72,8 +72,7 @@ impl HostAgent {
);
let dispatch = DispatchCtx::new(Arc::clone(&self.context));
let mut session = CoreContext::sync_scope(Arc::clone(&self.context), || {
- if crate::profiles::capabilities::ProfileCapabilities::in_ctx(&dispatch).is_some()
- {
+ if crate::profiles::capabilities::ProfileCapabilities::in_ctx(&dispatch).is_some() {
return OpenHumanSessionHost::from_config_host_only(
&dispatch,
config,
@@ -90,7 +89,11 @@ impl HostAgent {
host,
session_id,
),
- None => OpenHumanSessionHost::from_config_with_definition(&dispatch, config, &self.definition),
+ None => OpenHumanSessionHost::from_config_with_definition(
+ &dispatch,
+ config,
+ &self.definition,
+ ),
}
})?;
// The agent's own callbacks ride the session explicitly: its tool and
diff --git a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs
index 8946029591..33aabf834a 100644
--- a/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/agent_teams/runtime_tests.rs
@@ -266,7 +266,8 @@ async fn run_member_loop_drives_member_under_an_explicit_parent() {
output: "did the thing".into(),
fail: false,
});
- run_member_loop(&crate::core::runtime::DispatchCtx::ambient(),
+ run_member_loop(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
"team-1",
"m1",
@@ -372,9 +373,16 @@ async fn start_member_run_blocks_on_unmet_dependency() {
);
// Explicit task-b: its dep task-a is not done → Blocked, no spawn.
- let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("task-b"), None)
- .await
- .unwrap();
+ let outcome = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "m1",
+ Some("task-b"),
+ None,
+ )
+ .await
+ .unwrap();
match outcome {
StartMemberOutcome::Blocked { unmet } => assert_eq!(unmet, vec!["task-a".to_string()]),
other => panic!("expected Blocked, got {other:?}"),
@@ -399,9 +407,16 @@ async fn start_member_run_reports_already_claimed() {
run_ledger::claim_agent_team_task(&config.workspace_dir, "team-1", "task-a", "m2", "tok")
.unwrap();
- let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("task-a"), None)
- .await
- .unwrap();
+ let outcome = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "m1",
+ Some("task-a"),
+ None,
+ )
+ .await
+ .unwrap();
assert_eq!(outcome, StartMemberOutcome::AlreadyClaimed);
}
@@ -411,21 +426,42 @@ async fn start_member_run_no_claimable_and_unknown_task() {
seed_team(&config, "team-1");
seed_member(&config, "team-1", "m1", Some("task_manager_agent"));
// No tasks at all → nothing claimable.
- let none = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", None, None)
- .await
- .unwrap();
+ let none = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "m1",
+ None,
+ None,
+ )
+ .await
+ .unwrap();
assert_eq!(none, StartMemberOutcome::NoClaimableTask);
// Explicit unknown task id → UnknownTask.
- let unknown = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", Some("ghost"), None)
- .await
- .unwrap();
+ let unknown = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "m1",
+ Some("ghost"),
+ None,
+ )
+ .await
+ .unwrap();
assert_eq!(unknown, StartMemberOutcome::UnknownTask);
// Unknown member → typed error.
- let err = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "ghost", None, None)
- .await
- .unwrap_err();
+ let err = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "ghost",
+ None,
+ None,
+ )
+ .await
+ .unwrap_err();
assert_eq!(
err.downcast::<TeamError>().unwrap(),
TeamError::UnknownMember {
@@ -463,9 +499,16 @@ async fn start_member_run_rejects_already_active_member_without_side_effects() {
vec![],
);
- let outcome = start_member_run(&crate::core::runtime::DispatchCtx::ambient(), &config, "team-1", "m1", None, None)
- .await
- .unwrap();
+ let outcome = start_member_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "team-1",
+ "m1",
+ None,
+ None,
+ )
+ .await
+ .unwrap();
assert_eq!(outcome, StartMemberOutcome::AlreadyActive);
// No claim happened — the free task is untouched and the member still points
diff --git a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
index abd5aeaf0b..067d59d0b6 100644
--- a/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
+++ b/crates/openhuman-core/src/agent/orchestration/background_delivery.rs
@@ -101,14 +101,14 @@ impl EventHandler<DomainEvent> for BackgroundDeliveryHandler {
match drain.owner {
// Re-enter the owner's scope so the scheduled task inherits it.
Some(ctx) => {
- {
let dispatch = DispatchCtx::new(Arc::clone(&ctx));
CoreContext::sync_scope(ctx, || {
schedule_delivery(&dispatch, drain.thread_id, drain.delay)
})
}
+ None => {
+ schedule_delivery(&DispatchCtx::host_default(), drain.thread_id, drain.delay)
}
- None => schedule_delivery(&DispatchCtx::host_default(), drain.thread_id, drain.delay),
}
}
}
@@ -247,7 +247,13 @@ pub(super) fn drain_schedule_in(
/// Schedule a debounced delivery attempt for a thread, fenced by the calling
/// profile's lease ([`DrainFence::current`]).
fn schedule_delivery(ctx: &DispatchCtx, thread_id: String, delay: Duration) {
- schedule_delivery_inner(ctx.clone(), thread_id, delay, false, DrainFence::current(ctx));
+ schedule_delivery_inner(
+ ctx.clone(),
+ thread_id,
+ delay,
+ false,
+ DrainFence::current(ctx),
+ );
}
/// `wait_idle`: after the delay, keep waiting while the thread's user turn is in
@@ -328,7 +334,13 @@ fn recover_fenced(ctx: &DispatchCtx, workspace_dir: &Path, fence: DrainFence) ->
"[background_delivery] scheduling redelivery of undelivered completions after restart \
thread_id={thread_id}"
);
- schedule_delivery_inner(ctx.clone(), thread_id.clone(), RECOVERY_DELAY, true, fence.clone());
+ schedule_delivery_inner(
+ ctx.clone(),
+ thread_id.clone(),
+ RECOVERY_DELAY,
+ true,
+ fence.clone(),
+ );
}
threads.len()
}
@@ -456,7 +468,12 @@ fn retry_backoff(attempts: u32) -> Duration {
/// it is logged at error and the chain ends; that is the one path on which a
/// result is genuinely lost, and it requires the conversation store to be
/// failing as well as the agent.
-async fn persist_undelivered(ctx: DispatchCtx, workspace_dir: PathBuf, thread_id: String, notice: String) {
+async fn persist_undelivered(
+ ctx: DispatchCtx,
+ workspace_dir: PathBuf,
+ thread_id: String,
+ notice: String,
+) {
let run_id = format!("bgdeliver-undelivered-{}", uuid::Uuid::new_v4());
match persist_delivery_reply(&ctx, workspace_dir, &thread_id, &run_id, notice, false) {
Ok(()) => log::warn!(
diff --git a/crates/openhuman-core/src/agent/orchestration/parent_context/builder.rs b/crates/openhuman-core/src/agent/orchestration/parent_context/builder.rs
index 09beda1f66..e48ef30d44 100644
--- a/crates/openhuman-core/src/agent/orchestration/parent_context/builder.rs
+++ b/crates/openhuman-core/src/agent/orchestration/parent_context/builder.rs
@@ -157,7 +157,9 @@ where
{
let parent = match parent_override {
Some(parent) => parent,
- None => build_root_parent(ctx, config, agent_definition_id, channel, session_prefix).await?,
+ None => {
+ build_root_parent(ctx, config, agent_definition_id, channel, session_prefix).await?
+ }
};
Ok(run(parent).await)
}
diff --git a/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs b/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs
index bc51cea7e9..7e470420aa 100644
--- a/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/parent_context/builder_tests.rs
@@ -16,9 +16,15 @@ fn test_config() -> (tempfile::TempDir, Config) {
#[tokio::test]
async fn with_root_parent_hands_a_root_parent_to_the_closure() {
let (_dir, config) = test_config();
- let observed = with_root_parent(&crate::core::runtime::DispatchCtx::ambient(), None, &config, "cron", "cron", "cron", |parent| async move {
- parent.agent_definition_id
- })
+ let observed = with_root_parent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ None,
+ &config,
+ "cron",
+ "cron",
+ "cron",
+ |parent| async move { parent.agent_definition_id },
+ )
.await
.expect("root parent builds from config");
assert_eq!(
@@ -33,10 +39,17 @@ async fn with_root_parent_hands_a_root_parent_to_the_closure() {
#[tokio::test]
async fn with_root_parent_uses_an_explicit_parent_override() {
let (_dir, config) = test_config();
- let outer = build_root_parent(&crate::core::runtime::DispatchCtx::ambient(), &config, "outer", "outer", "outer")
- .await
- .expect("build explicit parent");
- let observed = with_root_parent(&crate::core::runtime::DispatchCtx::ambient(),
+ let outer = build_root_parent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "outer",
+ "outer",
+ "outer",
+ )
+ .await
+ .expect("build explicit parent");
+ let observed = with_root_parent(
+ &crate::core::runtime::DispatchCtx::ambient(),
Some(outer),
&config,
"inner",
@@ -60,14 +73,30 @@ async fn concurrent_root_parents_do_not_cross() {
let (_dir, config) = test_config();
let ctx = crate::core::runtime::DispatchCtx::ambient();
let (a, b) = tokio::join!(
- with_root_parent(&ctx, None, &config, "surface_a", "a", "a", |parent| async move {
- tokio::task::yield_now().await;
- parent.agent_definition_id
- }),
- with_root_parent(&ctx, None, &config, "surface_b", "b", "b", |parent| async move {
- tokio::task::yield_now().await;
- parent.agent_definition_id
- }),
+ with_root_parent(
+ &ctx,
+ None,
+ &config,
+ "surface_a",
+ "a",
+ "a",
+ |parent| async move {
+ tokio::task::yield_now().await;
+ parent.agent_definition_id
+ }
+ ),
+ with_root_parent(
+ &ctx,
+ None,
+ &config,
+ "surface_b",
+ "b",
+ "b",
+ |parent| async move {
+ tokio::task::yield_now().await;
+ parent.agent_definition_id
+ }
+ ),
);
assert_eq!(a.expect("a"), "surface_a");
assert_eq!(b.expect("b"), "surface_b");
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
index 8860228807..17f5c48577 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
@@ -115,7 +115,8 @@ impl SpawnAsyncSubagentTool {
workspace.root.clone()
})
.or_else(|| {
- crate::security::live_policy::effective_in(&dispatch).map(|policy| policy.action_dir.clone())
+ crate::security::live_policy::effective_in(&dispatch)
+ .map(|policy| policy.action_dir.clone())
});
let selector = SubagentSessionSelector {
parent_session: parent_session.clone(),
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs
index 8112983bfa..75a5947c5d 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs
@@ -414,7 +414,8 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {
let history = vec![TranscriptMessage::tool(
r#"{"type":"workflow_proposal","persisted":false,"name":"Daily X Trending Email","graph":{"nodes":[],"edges":[]}}"#,
)];
- let summary = attach_workflow_proposal(&crate::core::runtime::DispatchCtx::ambient(),
+ let summary = attach_workflow_proposal(
+ &crate::core::runtime::DispatchCtx::ambient(),
temp.path(),
Some("thread-parent"),
"sub-task-1",
@@ -454,7 +455,8 @@ fn attach_workflow_proposal_persists_thread_message_and_extends_summary() {
#[test]
fn attach_workflow_proposal_without_proposal_returns_summary_unchanged() {
let temp = tempfile::tempdir().expect("tempdir");
- let summary = attach_workflow_proposal(&crate::core::runtime::DispatchCtx::ambient(),
+ let summary = attach_workflow_proposal(
+ &crate::core::runtime::DispatchCtx::ambient(),
temp.path(),
Some("thread-x"),
"sub-task-2",
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
index f8a635a26d..50d10575ff 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
@@ -95,7 +95,8 @@ fn render_worker_thread_result_carries_machine_readable_envelope() {
fn persist_worker_thread_creates_thread_with_tasks_label_and_messages() {
let temp = TempDir::new().expect("tempdir");
let outcome = sample_outcome("the answer is 42");
- let thread_id = persist_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),
+ let thread_id = persist_worker_thread(
+ &crate::core::runtime::DispatchCtx::ambient(),
temp.path(),
"task_manager_agent",
"draft a long research plan",
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
index 1e997a6c36..17498284aa 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
@@ -241,9 +241,8 @@ impl SpawnWorkerThreadTool {
"[spawn_worker_thread] invoked"
);
- let threads =
- conversations::list_threads(&dispatch, parent.workspace_dir.clone())
- .map_err(|e| anyhow::anyhow!(e))?;
+ let threads = conversations::list_threads(&dispatch, parent.workspace_dir.clone())
+ .map_err(|e| anyhow::anyhow!(e))?;
if let Some(current_thread) = threads.iter().find(|t| t.id == current_thread_id) {
let is_delegated_label = current_thread
.labels
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs
index b4e7682099..132f63730f 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/worker_thread_tests.rs
@@ -5,7 +5,8 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {
let dir = std::env::temp_dir().join(format!("wt-test-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&dir).unwrap();
- let id = create_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),
+ let id = create_worker_thread(
+ &crate::core::runtime::DispatchCtx::ambient(),
dir.clone(),
"parent-thread-1",
"researcher",
@@ -44,7 +45,8 @@ fn creates_child_thread_linked_to_parent_and_seeds_prompt() {
fn appends_follow_up_prompt_to_existing_worker_thread() {
let dir = std::env::temp_dir().join(format!("wt-test-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&dir).unwrap();
- let id = create_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),
+ let id = create_worker_thread(
+ &crate::core::runtime::DispatchCtx::ambient(),
dir.clone(),
"parent-thread-1",
"researcher",
@@ -53,8 +55,15 @@ fn appends_follow_up_prompt_to_existing_worker_thread() {
)
.unwrap();
- append_worker_user_message(&crate::core::runtime::DispatchCtx::ambient(), dir.clone(), &id, "researcher", "sub-2", "Follow-up prompt")
- .unwrap();
+ append_worker_user_message(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ dir.clone(),
+ &id,
+ "researcher",
+ "sub-2",
+ "Follow-up prompt",
+ )
+ .unwrap();
let messages = conversations::get_messages(
&crate::core::runtime::DispatchCtx::ambient(),
diff --git a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
index e969a2fe84..f1b1ae881a 100644
--- a/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/orchestration/workflow_runs/engine/lifecycle.rs
@@ -75,7 +75,14 @@ pub async fn start_workflow_run(
Ok(task_config) => {
crate::agent::turn_origin::with_inherited_origin(
inherited_origin,
- run_engine_loop(&task_ctx, &task_config, &task_run_id, definition, cancel, None),
+ run_engine_loop(
+ &task_ctx,
+ &task_config,
+ &task_run_id,
+ definition,
+ cancel,
+ None,
+ ),
)
.await;
}
@@ -219,7 +226,14 @@ pub async fn resume_workflow_run(
Ok(task_config) => {
crate::agent::turn_origin::with_inherited_origin(
inherited_origin,
- run_engine_loop(&task_ctx, &task_config, &task_run_id, definition, cancel, None),
+ run_engine_loop(
+ &task_ctx,
+ &task_config,
+ &task_run_id,
+ definition,
+ cancel,
+ None,
+ ),
)
.await;
}
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
index 5767e9207f..037eec33d1 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests.rs
@@ -335,8 +335,12 @@ async fn an_empty_named_scope_advertises_no_tools_at_all() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer")
- .expect("summarizer is a shipped agent definition");
+ let agent = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "summarizer",
+ )
+ .expect("summarizer is a shipped agent definition");
let visible = agent.visible_tool_names_for_test();
let real: Vec<&String> = visible
@@ -365,8 +369,12 @@ async fn a_zero_tool_agent_does_not_gain_the_compaction_recovery_tool() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "trigger_triage")
- .expect("trigger_triage is a shipped agent definition");
+ let agent = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "trigger_triage",
+ )
+ .expect("trigger_triage is a shipped agent definition");
assert!(
!agent
@@ -421,8 +429,12 @@ async fn a_summarized_agent_sees_the_recovery_tool_with_compaction_off() {
let mut config = test_config(&tmp);
config.context.compaction_enabled = false;
assert!(super::summarizes_tool_output("orchestrator", &config));
- let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator is a shipped agent definition");
+ let agent = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator is a shipped agent definition");
let visible = agent.visible_tool_names_for_test();
assert!(
visible.is_empty() || visible.contains(tinyjuice_bus::tools::RETRIEVE),
@@ -494,8 +506,12 @@ async fn a_curated_orchestrator_sees_and_holds_every_juice_tool_in_handle_mode()
config.tokenjuice.repl_handle_enabled = true;
assert!(crate::inference::tokenjuice::repl_handle_active(&config));
- let agent = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator is a shipped agent definition");
+ let agent = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator is a shipped agent definition");
let visible = agent.visible_tool_names_for_test();
assert!(
!visible.is_empty(),
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
index c67cc339d8..7873e38538 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_explicit_definition_tests.rs
@@ -29,8 +29,12 @@ async fn from_config_with_definition_stamps_the_definition_on_the_session() {
let config = test_config(&tmp);
let def = explicit_definition("embedded-alpha");
- let agent = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &def)
- .expect("build from an explicit definition");
+ let agent = OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &def,
+ )
+ .expect("build from an explicit definition");
assert_eq!(agent.agent_definition_id, "embedded-alpha");
let resolved = agent
@@ -60,8 +64,12 @@ async fn resolved_definition_prefers_the_sessions_own_over_a_same_id_registry_en
"the registry's orchestrator is not read-only, so a leak is observable"
);
- let agent = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &def)
- .expect("build from an explicit definition");
+ let agent = OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &def,
+ )
+ .expect("build from an explicit definition");
assert_eq!(
agent.resolved_definition().map(|d| d.sandbox_mode),
@@ -77,7 +85,9 @@ async fn registry_built_sessions_resolve_the_registry_definition() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = OpenHumanSessionHost::from_config(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("orchestrator session");
+ let agent =
+ OpenHumanSessionHost::from_config(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("orchestrator session");
let resolved = agent.resolved_definition().expect("registry definition");
assert_eq!(resolved.id, "orchestrator");
let registry_mode = AgentDefinitionRegistry::global()
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs
index 30dcfd4cc8..ef01754c11 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_only_tests.rs
@@ -75,7 +75,8 @@ fn a_host_only_session_registers_and_advertises_only_the_host_belt() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
Some(&host_belt()),
@@ -105,7 +106,8 @@ fn a_host_only_session_without_a_belt_has_no_tools() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
None,
@@ -122,7 +124,8 @@ fn a_host_only_session_runs_a_definition_that_cannot_delegate_or_act() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
Some(&host_belt()),
@@ -195,14 +198,16 @@ async fn the_host_only_policy_still_consults_the_hosts_own_gate() {
fn only_a_host_only_session_accepts_untrusted_input() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let mut host_only = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),
+ let mut host_only = crate::agent::OpenHumanSessionHost::from_config_host_only(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
Some(&host_belt()),
None,
)
.expect("host-only session");
- let mut normal = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let mut normal = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
&host_belt(),
@@ -222,7 +227,8 @@ fn only_a_host_only_session_accepts_untrusted_input() {
async fn a_host_only_session_enforces_the_deny_by_default_gate() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_host_only(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&orchestrator_def(),
Some(&host_belt()),
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
index d7445f02fc..cddb885cd3 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_host_tools_tests.rs
@@ -88,7 +88,8 @@ fn a_host_tool_is_on_the_belt_and_advertised() {
crate::agent::HostTurnTools::advertised(vec![Box::new(Marker("oc_marker_tool"))])
});
- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -111,13 +112,16 @@ fn a_host_tool_is_on_the_belt_and_advertised() {
fn a_host_can_withhold_a_config_tool_for_one_turn() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let normally_visible =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition())
- .expect("build a session without a host belt")
- .visible_tool_specs_arc()
- .first()
- .map(|spec| spec.name.clone())
- .expect("the config-derived belt advertises at least one tool");
+ let normally_visible = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition(),
+ )
+ .expect("build a session without a host belt")
+ .visible_tool_specs_arc()
+ .first()
+ .map(|spec| spec.name.clone())
+ .expect("the config-derived belt advertises at least one tool");
let host: crate::agent::HostTools = {
let normally_visible = normally_visible.clone();
@@ -129,7 +133,8 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {
..Default::default()
})
};
- let hidden_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let hidden_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -145,7 +150,8 @@ fn a_host_can_withhold_a_config_tool_for_one_turn() {
"a per-turn host withholding must remove a config-derived tool from the provider view"
);
- let visible_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let visible_turn = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -170,7 +176,8 @@ fn withholding_tool_search_disables_wildcard_discovery() {
..Default::default()
});
- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -203,7 +210,8 @@ fn the_factory_runs_once_per_session_build() {
};
for _ in 0..2 {
- crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -225,9 +233,12 @@ fn the_factory_runs_once_per_session_build() {
fn no_host_belt_leaves_the_advertised_set_alone() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition())
- .expect("build a plain session");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition(),
+ )
+ .expect("build a plain session");
assert!(
!agent
@@ -266,7 +277,8 @@ fn the_factory_is_told_the_session_it_is_building_for() {
})
};
- let desked = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let desked = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -282,7 +294,8 @@ fn the_factory_is_told_the_session_it_is_building_for() {
"the belt must be able to differ per conversation"
);
- let unnamed = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let unnamed = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -324,13 +337,16 @@ fn a_host_tool_overrides_a_config_tool_of_the_same_name() {
let config = test_config(&tmp);
// A name the config-derived belt already carries, so the two collide.
- let contested =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition())
- .expect("build a session without a host belt")
- .visible_tool_specs_arc()
- .first()
- .map(|spec| spec.name.clone())
- .expect("the config-derived belt advertises at least one tool");
+ let contested = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition(),
+ )
+ .expect("build a session without a host belt")
+ .visible_tool_specs_arc()
+ .first()
+ .map(|spec| spec.name.clone())
+ .expect("the config-derived belt advertises at least one tool");
let host: crate::agent::HostTools = {
let contested = contested.clone();
@@ -341,7 +357,8 @@ fn a_host_tool_overrides_a_config_tool_of_the_same_name() {
})
};
- let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
@@ -388,9 +405,12 @@ fn permanent_attachment_preserves_a_fresh_wildcard_belt() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
let definition = definition();
- let baseline =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition)
- .unwrap();
+ let baseline = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition,
+ )
+ .unwrap();
let original: std::collections::HashSet<_> = baseline
.visible_tool_specs_arc()
.iter()
@@ -403,7 +423,8 @@ fn permanent_attachment_preserves_a_fresh_wildcard_belt() {
tools.permanent.insert("attached_marker".into());
tools
});
- let attached = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let attached = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition,
&host,
@@ -431,7 +452,8 @@ fn permanent_metadata_without_a_source_is_rejected_before_build() {
permanent: std::collections::HashSet::from(["missing_source".into()]),
..Default::default()
});
- let error = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(&crate::core::runtime::DispatchCtx::ambient(),
+ let error = crate::agent::OpenHumanSessionHost::from_config_with_host_tools(
+ &crate::core::runtime::DispatchCtx::ambient(),
&config,
&definition(),
&host,
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
index 4a9a1e5c28..6d15783f48 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_exposure_tests.rs
@@ -14,9 +14,12 @@ fn visible_names_for(
) -> std::collections::HashSet<String> {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, definition)
- .unwrap_or_else(|e| panic!("{} session build: {e}", definition.id));
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ definition,
+ )
+ .unwrap_or_else(|e| panic!("{} session build: {e}", definition.id));
agent
.visible_tool_specs_arc()
.iter()
@@ -29,9 +32,12 @@ fn resetting_wildcard_visibility_keeps_collapsed_exposure() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
let definition = super::wildcard_probe_def();
- let mut agent =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition)
- .expect("build wildcard agent");
+ let mut agent = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition,
+ )
+ .expect("build wildcard agent");
agent.set_visible_tool_names(std::collections::HashSet::new());
@@ -45,9 +51,12 @@ fn hiding_and_reseeding_wildcard_visibility_keeps_collapsed_exposure() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
let definition = super::wildcard_probe_def();
- let mut agent =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition)
- .expect("build wildcard agent");
+ let mut agent = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition,
+ )
+ .expect("build wildcard agent");
agent.set_visible_tool_names(std::collections::HashSet::new());
agent.hide_tools(&["todo"]);
@@ -223,9 +232,12 @@ fn orchestrator_reaches_the_replaced_specialists_tools_through_discovery() {
.get("orchestrator")
.cloned()
.expect("orchestrator built-in definition");
- let agent =
- crate::agent::OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition)
- .expect("orchestrator session build");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition,
+ )
+ .expect("orchestrator session build");
let deferred = agent.deferred_tool_names_for_test();
let visible = agent.visible_tool_names_for_test();
let policy = agent.tool_policy_session_for_test();
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
index 945591aff8..6e978bc886 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
@@ -17,8 +17,12 @@ fn the_three_spec_views_share_their_leaf_schemas() {
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator session build");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator session build");
let durable = agent.durable_tool_specs_arc();
let all = agent.tool_specs_arc();
diff --git a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs b/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
index 4b095d96a4..eb055938ab 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/host_only.rs
@@ -42,13 +42,28 @@ use tinyagents_definition::{SandboxMode, ToolScope};
/// host's policy and never widens it.
pub struct HostOnlyToolPolicy {
allowed: HashSet<String>,
- host: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>>,
+ host: Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ >,
}
impl HostOnlyToolPolicy {
/// Admit exactly `allowed`, subject to `host`'s own decision.
#[must_use]
- pub fn new(allowed: HashSet<String>, host: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>>) -> Self {
+ pub fn new(
+ allowed: HashSet<String>,
+ host: Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ >,
+ ) -> Self {
Self { allowed, host }
}
}
@@ -59,7 +74,11 @@ impl ToolCallPolicy<OpenHumanRunContext> for HostOnlyToolPolicy {
"host_only"
}
- async fn check(&self, ctx: &RunContext<OpenHumanRunContext>, call: &ToolCall) -> PolicyDecision {
+ async fn check(
+ &self,
+ ctx: &RunContext<OpenHumanRunContext>,
+ call: &ToolCall,
+ ) -> PolicyDecision {
if !self.allowed.contains(&call.name) {
log::debug!(
"[agent::host_only] denied tool outside the host belt: {}",
@@ -90,8 +109,20 @@ pub(super) fn empty_belt() -> HashSet<String> {
pub(super) fn session_policy(
host_only: bool,
tools: &[Box<dyn tinytools::Tool>],
- host: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>>,
-) -> Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>> {
+ host: Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ >,
+) -> Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+> {
if !host_only {
return host;
}
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 4c42e0e46c..03aaa3ad19 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
@@ -61,7 +61,13 @@ pub struct HostTurnTools {
/// enforce one through the session's tool policy.
pub withheld: HashSet<String>,
/// The session's admission gate, if the host sets one.
- pub policy: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>>,
+ pub policy: Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ >,
}
impl HostTurnTools {
@@ -170,7 +176,14 @@ impl HostTurnTools {
/// session should keep an existing policy for calls the host does not own,
/// the host composes the two and passes the result here.
#[must_use]
- pub fn with_policy(mut self, policy: Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>) -> Self {
+ pub fn with_policy(
+ mut self,
+ policy: Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ ) -> Self {
self.policy = Some(policy);
self
}
@@ -189,7 +202,13 @@ impl HostTurnTools {
/// The parts of a host turn belt that the session builder applies after
/// expanding the agent's static scope.
pub(super) struct MergedHostTurnTools {
- pub policy: Option<Arc<dyn tinyagents_harness::middleware::ToolCallPolicy<crate::agent::tinyagents::host::OpenHumanRunContext>>>,
+ pub policy: Option<
+ Arc<
+ dyn tinyagents_harness::middleware::ToolCallPolicy<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
+ >,
+ >,
+ >,
pub withheld: HashSet<String>,
pub permanent: HashSet<String>,
pub scope_additions: HashSet<String>,
diff --git a/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs b/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
index 2f9860b534..385d3d3729 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/profile_factory.rs
@@ -17,14 +17,19 @@ impl OpenHumanSessionHost {
agent_id: &str,
session_id: Option<&str>,
) -> anyhow::Result<Self> {
- if let Some(capabilities) =
- crate::profiles::capabilities::ProfileCapabilities::in_ctx(ctx)
+ if let Some(capabilities) = crate::profiles::capabilities::ProfileCapabilities::in_ctx(ctx)
{
let mut definition = super::factory::resolve_target_definition(config, agent_id)?
.ok_or_else(|| anyhow::anyhow!("profile agent definition is unavailable"))?;
capabilities.apply_system_prompt(&mut definition);
let factory = capabilities.factory(config);
- return Self::from_config_host_only(ctx, config, &definition, Some(&factory), session_id);
+ return Self::from_config_host_only(
+ ctx,
+ config,
+ &definition,
+ Some(&factory),
+ session_id,
+ );
}
Self::from_config_for_agent(ctx, config, agent_id)
}
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 0a4c48a195..b1e024b2e5 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -84,9 +84,7 @@ impl SessionHostBuilder {
config: Arc<crate::config::Config>,
) -> Self {
self.turn_model_source = Some(crate::agent::tinyagents::TurnModelSource::new_crate_native(
- ctx,
- role,
- config,
+ ctx, role, config,
));
self
}
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
index 99f7b9e28c..ca9cb58a47 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_adapter_tests.rs
@@ -489,8 +489,12 @@ fn a_subagent_thread_binding_claims_no_session_identity() {
};
std::fs::create_dir_all(&config.workspace_dir).unwrap();
- let mut root =
- super::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").unwrap();
+ let mut root = super::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .unwrap();
root.set_thread_id(Some("thread-1"));
// The exact stem encoding (sanitisation, per-component digest, generation
// suffix) belongs to tinyagents and is pinned by its own tests. What
@@ -504,8 +508,12 @@ fn a_subagent_thread_binding_claims_no_session_identity() {
"a root chat session is addressed by its conversation, got {root_session}"
);
- let mut child =
- super::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator").unwrap();
+ let mut child = super::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .unwrap();
child.session_parent_prefix = Some("1713000000_orchestrator".into());
child.set_thread_id(Some("thread-1"));
assert_eq!(child.session_id(), None);
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs
index c3f552b685..2fb2867479 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session/tool_rules_tests.rs
@@ -22,8 +22,12 @@ fn a_session_composes_the_operator_and_definition_layers() {
.find(|def| def.id == "orchestrator")
.expect("orchestrator");
definition.disallowed_tools = vec!["web_*".to_string()];
- let host = OpenHumanSessionHost::from_config_with_definition(&crate::core::runtime::DispatchCtx::ambient(), &config, &definition)
- .expect("session builds");
+ let host = OpenHumanSessionHost::from_config_with_definition(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &definition,
+ )
+ .expect("session builds");
let rules = host.session_tool_rules();
let names: Vec<_> = rules
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs
index 323d1ec331..466e788eb2 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_juice_tests.rs
@@ -55,9 +55,12 @@ async fn a_resumed_thread_keeps_recorded_juice_specs_and_executors_when_repl_is_
current_config.tokenjuice.ccr_enabled = false;
current_config.tokenjuice.repl_handle_enabled = false;
assert!(repl_tools_for(&current_config).is_empty());
- let mut host =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &current_config, "summarizer")
- .expect("summarizer session");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &current_config,
+ "summarizer",
+ )
+ .expect("summarizer session");
host.ensure_runtime_session().expect("runtime session");
let prelude = host
.runtime_state
@@ -177,8 +180,12 @@ async fn resumed_juice_snapshot_does_not_add_live_repl_declarations() {
recorded_spec.parameters = serde_json::json!({"type":"object","frozen":true});
let recorded = ToolSnapshot::new(vec![recorded_spec.clone()]).expect("recorded snapshot");
- let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer")
- .expect("summarizer session");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "summarizer",
+ )
+ .expect("summarizer session");
host.ensure_runtime_session().expect("runtime session");
let prelude = host
.runtime_state
@@ -261,8 +268,12 @@ async fn juice_off_turn_loads_no_module_and_passes_tool_output_through() {
config.tokenjuice.router_enabled = true;
assert!(config.components.set("juice", false));
- let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "summarizer")
- .expect("summarizer session");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "summarizer",
+ )
+ .expect("summarizer session");
host.ensure_runtime_session().expect("runtime session");
let context_mw = host
.runtime_state
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
index b5e3890028..1be4076629 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_tests.rs
@@ -114,9 +114,12 @@ fn clearing_progress_releases_warm_prelude_sender() {
config_path: tmp.path().join("config.toml"),
..Default::default()
};
- let mut host =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator");
host.ensure_runtime_session().expect("warm runtime");
let (tx, mut rx) = tokio::sync::mpsc::channel(1);
@@ -202,9 +205,12 @@ fn connected_mcp_actions_enter_search_and_leave_on_disconnect() {
config_path: tmp.path().join("config.toml"),
..Default::default()
};
- let mut host =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator");
host.ensure_runtime_session().expect("runtime session");
let prelude = host
.runtime_state
@@ -268,9 +274,12 @@ async fn resumed_mcp_snapshot_survives_a_cold_catalog_and_keeps_its_frozen_spec(
config_path: tmp.path().join("config.toml"),
..Default::default()
};
- let mut host =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("orchestrator");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("orchestrator");
host.ensure_runtime_session().expect("runtime session");
let prelude = host
.runtime_state
@@ -368,9 +377,12 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa
};
config.browser.enabled = true;
config.http_request.allowed_domains = vec!["example.com".into()];
- let mut host =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("desktop orchestrator");
+ let mut host = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("desktop orchestrator");
for name in ["browser", "browser_open"] {
assert!(host.deferred_tool_names_for_test().contains(name), "{name}");
assert!(!host
@@ -408,9 +420,12 @@ async fn desktop_browser_setting_keeps_deferred_tools_in_fresh_and_resumed_surfa
}
config.browser.enabled = false;
- let disabled =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "orchestrator")
- .expect("browser-disabled orchestrator");
+ let disabled = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ )
+ .expect("browser-disabled orchestrator");
for name in ["browser", "browser_open"] {
assert!(
!disabled.deferred_tool_names_for_test().contains(name),
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph/worker_mirror.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph/worker_mirror.rs
index ebe43b2d41..ca8fb96aae 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph/worker_mirror.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph/worker_mirror.rs
@@ -52,12 +52,7 @@ fn append_worker_message(
sender: sender.to_string(),
created_at: chrono::Utc::now().to_rfc3339(),
};
- if let Err(err) = append_message(
- ctx,
- workspace_dir.to_path_buf(),
- thread_id,
- message,
- ) {
+ if let Err(err) = append_message(ctx, workspace_dir.to_path_buf(), thread_id, message) {
tracing::debug!(
agent_id,
thread_id,
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs
index ec3b6cff1d..7d5ce7e4a9 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/graph_policy_tests.rs
@@ -231,7 +231,8 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {
const RAW: &str = "{\"events\":[{\"title\":\"raw tool output the human never typed\"}]}";
// The typed path (`TranscriptEntry::ToolResults`), used on a normal run.
- mirror_worker_thread(&crate::core::runtime::DispatchCtx::ambient(),
+ mirror_worker_thread(
+ &crate::core::runtime::DispatchCtx::ambient(),
&dir,
"worker-typed",
"researcher",
@@ -258,7 +259,8 @@ fn mirrored_tool_results_are_hidden_from_the_worker_thread_chat() {
);
// The error-recovery path (`role: "tool"`), used when a run fails mid-turn.
- mirror_worker_thread_from_history(&crate::core::runtime::DispatchCtx::ambient(),
+ mirror_worker_thread_from_history(
+ &crate::core::runtime::DispatchCtx::ambient(),
&dir,
"worker-recovered",
"researcher",
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
index 09d2a75c6e..755577b988 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/bundle.rs
@@ -192,7 +192,9 @@ impl OpenHumanHostBundleFactory {
// stays registered as the host capability with an unconsumed channel;
// nothing OpenHuman renders depends on it.
let progress = Arc::new(OpenHumanProgressSink::new(tokio::sync::mpsc::channel(1).0));
- let learning = Arc::new(OpenHumanLearningSink::new(inputs.post_turn_hooks).with_dispatch(turn.dispatch_ctx()));
+ let learning = Arc::new(
+ OpenHumanLearningSink::new(inputs.post_turn_hooks).with_dispatch(turn.dispatch_ctx()),
+ );
let tool_outcomes = Arc::new(OpenHumanToolOutcomeClassifier::new());
let capabilities = HostCapabilities::new(
diff --git a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
index 969b85de6d..974df27bfb 100644
--- a/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/live_harness.rs
@@ -124,8 +124,7 @@ pub(crate) fn assemble_live_tool_harness(
route_session,
),
));
- let mut embedder_tool_hooks =
- crate::agent::hooks::embedder_tool_hooks_in(&dispatch);
+ let mut embedder_tool_hooks = crate::agent::hooks::embedder_tool_hooks_in(&dispatch);
embedder_tool_hooks.extend(tool_hooks);
if !embedder_tool_hooks.is_empty() {
harness.push_middleware(Arc::new(
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
index 2eff1bb300..9f7869eabe 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_middleware.rs
@@ -565,8 +565,7 @@ pub(super) fn install_turn_middleware(
// observation-only (never mutates the result), so running first in the
// reverse-order `after_tool` chain is safe — it cannot perturb the
// summarization/cap or tool-outcome capture layers.
- let mut embedder_tool_hooks =
- crate::agent::hooks::embedder_tool_hooks_in(&dispatch);
+ let mut embedder_tool_hooks = crate::agent::hooks::embedder_tool_hooks_in(&dispatch);
embedder_tool_hooks.extend(scoped_tool_hooks);
if !embedder_tool_hooks.is_empty() {
harness.push_middleware(Arc::new(
diff --git a/crates/openhuman-core/src/agent/triage/escalation_tests.rs b/crates/openhuman-core/src/agent/triage/escalation_tests.rs
index cab29fa83f..5f9150a3cd 100644
--- a/crates/openhuman-core/src/agent/triage/escalation_tests.rs
+++ b/crates/openhuman-core/src/agent/triage/escalation_tests.rs
@@ -16,9 +16,13 @@ async fn build_triage_parent_scopes_allowed_subagents_to_target() {
};
let _ = AgentDefinitionRegistry::init_global_builtins();
- let ctx = build_triage_parent(&crate::core::runtime::DispatchCtx::ambient(), &config, "researcher")
- .await
- .expect("build triage parent");
+ let ctx = build_triage_parent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "researcher",
+ )
+ .await
+ .expect("build triage parent");
assert_eq!(ctx.agent_definition_id, "triage");
assert_eq!(ctx.channel, "triage");
diff --git a/crates/openhuman-core/src/agent/triage/routing_tests.rs b/crates/openhuman-core/src/agent/triage/routing_tests.rs
index fc64dae411..3a9aa33425 100644
--- a/crates/openhuman-core/src/agent/triage/routing_tests.rs
+++ b/crates/openhuman-core/src/agent/triage/routing_tests.rs
@@ -21,7 +21,8 @@ fn build_remote_provider_managed_uses_backend_id_and_default_model() {
// Default config → chat workload resolves to the managed backend →
// the managed default model.
let config = test_config();
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
assert_eq!(resolved.model, crate::config::MODEL_MANAGED_DEFAULT);
assert!(!resolved.used_local, "used_local is always false");
@@ -33,12 +34,14 @@ fn build_remote_provider_managed_follows_the_pinned_default_model() {
// slug in `default_model` is not a pin, a catalog id is.
let mut config = test_config();
config.default_model = Some("reasoning-v1".to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
assert_eq!(resolved.model, crate::config::MODEL_MANAGED_DEFAULT);
config.default_model = Some("openrouter/deepseek/deepseek-v4-pro".to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.model, "openrouter/deepseek/deepseek-v4-pro");
assert!(!resolved.used_local);
}
@@ -50,7 +53,8 @@ fn build_remote_provider_falls_back_to_managed_when_chat_local() {
// never errors because Ollama is down.
let mut config = test_config();
config.chat_provider = Some("ollama:llama3.2:3b".to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
assert_eq!(resolved.model, crate::config::MODEL_MANAGED_DEFAULT);
assert!(!resolved.used_local, "triage never goes local");
@@ -68,8 +72,9 @@ fn build_remote_provider_forces_managed_for_local_cli_routes() {
] {
let mut config = test_config();
config.chat_provider = Some(route.to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
- .unwrap_or_else(|e| panic!("route {route} should build, got {e}"));
+ let resolved =
+ build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .unwrap_or_else(|e| panic!("route {route} should build, got {e}"));
assert_eq!(
resolved.provider_name, INFERENCE_BACKEND_ID,
"route {route} must force managed backend"
@@ -99,7 +104,8 @@ fn build_remote_provider_routes_through_byok_chat() {
let mut config = test_config();
config.cloud_providers.push(openai_entry("p_oai", "openai"));
config.chat_provider = Some("openai:gpt-4o-mini".to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.provider_name, "openai");
assert_eq!(resolved.model, "gpt-4o-mini");
assert!(!resolved.used_local);
@@ -112,7 +118,8 @@ fn build_remote_provider_falls_back_when_byok_build_fails() {
// backend rather than erroring the turn.
let mut config = test_config();
config.chat_provider = Some("groq:llama3".to_string());
- let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config).expect("remote provider should build");
+ let resolved = build_remote_provider(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .expect("remote provider should build");
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
assert_eq!(resolved.model, crate::config::MODEL_MANAGED_DEFAULT);
assert!(!resolved.used_local);
@@ -123,9 +130,10 @@ async fn resolve_provider_with_config_always_returns_remote() {
// Even when runtime_enabled is true, triage must always use remote.
let mut config = test_config();
config.local_ai.runtime_enabled = true;
- let resolved = resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config)
- .await
- .expect("resolve should succeed");
+ let resolved =
+ resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .await
+ .expect("resolve should succeed");
assert!(!resolved.used_local, "triage must never use local AI");
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
}
@@ -134,9 +142,10 @@ async fn resolve_provider_with_config_always_returns_remote() {
async fn resolve_provider_with_config_returns_remote_when_local_disabled() {
let mut config = test_config();
config.local_ai.runtime_enabled = false;
- let resolved = resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config)
- .await
- .expect("resolve should succeed");
+ let resolved =
+ resolve_provider_with_config(&crate::core::runtime::DispatchCtx::ambient(), &config)
+ .await
+ .expect("resolve should succeed");
assert!(!resolved.used_local);
assert_eq!(resolved.provider_name, INFERENCE_BACKEND_ID);
}
diff --git a/crates/openhuman-core/src/cron/scheduler/agent_run.rs b/crates/openhuman-core/src/cron/scheduler/agent_run.rs
index 2c6e176008..16a7479ddc 100644
--- a/crates/openhuman-core/src/cron/scheduler/agent_run.rs
+++ b/crates/openhuman-core/src/cron/scheduler/agent_run.rs
@@ -152,7 +152,11 @@ pub(super) async fn run_agent_job_for_run(
target = ?job.session_target,
"[cron] building isolated agent for scheduled job"
);
- match build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &effective, job) {
+ match build_agent_for_cron_job(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &effective,
+ job,
+ ) {
Ok(BuiltCronAgent { mut agent, context }) => {
// Tag events so downstream subscribers can correlate
// cron-triggered turns. `cron` is the channel so the
diff --git a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
index 8261d3fb8b..7eb8ff0ea8 100644
--- a/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
@@ -341,7 +341,9 @@ async fn cron_agent_job_uses_agent_definition_tool_scope() {
job.name = Some("morning_briefing".into());
job.agent_id = Some("morning_briefing".into());
- let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &job).expect("build cron agent");
+ let built =
+ build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &job)
+ .expect("build cron agent");
let visible = built.agent.visible_tool_names_for_test();
assert!(
diff --git a/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs b/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs
index 77d75edb54..f043e64c3d 100644
--- a/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_host_agent_tests.rs
@@ -93,7 +93,11 @@ fn a_cron_job_for_a_host_agent_builds_with_its_host_tools_and_context() {
});
host_agents::install(Arc::clone(&installed));
- let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &agent_job("cron-host-agent"));
+ let built = build_agent_for_cron_job(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &agent_job("cron-host-agent"),
+ );
host_agents::clear_if(&installed);
let built = built.expect("the host agent builds");
@@ -122,7 +126,11 @@ fn an_id_the_host_does_not_know_falls_back_to_the_registries() {
belt_builds: Arc::new(AtomicUsize::new(0)),
});
host_agents::install(Arc::clone(&installed));
- let built = build_agent_for_cron_job(&crate::core::runtime::DispatchCtx::ambient(), &config, &agent_job("orchestrator"));
+ let built = build_agent_for_cron_job(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &agent_job("orchestrator"),
+ );
host_agents::clear_if(&installed);
let built = built.expect("the orchestrator builds from the registries");
assert!(built.context.is_none());
diff --git a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
index ed4fcf3844..ed1e888790 100644
--- a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
@@ -26,9 +26,12 @@ async fn flows_discover_applies_the_flow_discovery_definitions_effective_iterati
let expected = def.effective_max_iterations();
assert_eq!(expected, 50);
- let agent =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "flow_discovery")
- .expect("build flow_discovery agent");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "flow_discovery",
+ )
+ .expect("build flow_discovery agent");
assert_eq!(agent.agent_config().max_tool_iterations, expected);
}
diff --git a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
index ac7b3bf944..9e99213316 100644
--- a/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_run_status_and_prompt_binding_tests.rs
@@ -150,9 +150,12 @@ async fn flows_build_hides_the_live_run_tool_from_the_builder_belt() {
&config.workspace_dir,
)
.expect("agent registry init");
- let mut agent =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder")
- .expect("build workflow_builder agent");
+ let mut agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "workflow_builder",
+ )
+ .expect("build workflow_builder agent");
agent.set_agent_definition_name("workflow_builder".to_string());
// Precondition: the builder advertises all four run-advancing tools on its
@@ -250,9 +253,12 @@ async fn flows_build_copilot_toolset_unhides_the_live_run_tools() {
&config.workspace_dir,
)
.expect("agent registry init");
- let mut agent =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder")
- .expect("build workflow_builder agent");
+ let mut agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "workflow_builder",
+ )
+ .expect("build workflow_builder agent");
agent.set_agent_definition_name("workflow_builder".to_string());
restrict_builder_toolset_for_copilot(&mut agent);
@@ -328,9 +334,12 @@ async fn flows_build_applies_the_builder_definitions_effective_iteration_cap() {
// End-to-end: the agent actually built for this path carries the
// definition's cap straight off the unmodified `config` — the session
// builder resolves it internally now, no `flows_build`-side override.
- let agent =
- crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "workflow_builder")
- .expect("build workflow_builder agent");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "workflow_builder",
+ )
+ .expect("build workflow_builder agent");
assert_eq!(agent.agent_config().max_tool_iterations, expected);
assert_ne!(
agent.agent_config().max_tool_iterations,
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs
index 429543979c..c37b2dec8c 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_tier_gate_and_timeouts_tests.rs
@@ -412,8 +412,12 @@ fn agent_node_runtime_resolves_to_the_definitions_effective_iteration_cap() {
let expected = def.effective_max_iterations();
assert_eq!(expected, 50);
- let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), &config, "planner")
- .expect("build planner agent");
+ let agent = crate::agent::OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "planner",
+ )
+ .expect("build planner agent");
assert_eq!(agent.agent_config().max_tool_iterations, expected);
// And the timeout scaling this cap feeds into actually widens the
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 eb990d17c1..58cfe40ab6 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
@@ -449,7 +449,8 @@ pub async fn agent_chat_reply_for(
"[inference] agent_chat rooting turn tools at cwd={}",
root.display()
);
- let mut agent = build_turn_agent(&turn_ctx, &scoped, &target, turn_session_id, temperature)?;
+ let mut agent =
+ build_turn_agent(&turn_ctx, &scoped, &target, turn_session_id, temperature)?;
// 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.
diff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
index d0d081c7f7..c6a1b569c5 100644
--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
@@ -209,7 +209,9 @@ async fn enforce_act_policy(ctx: &DispatchCtx, tool_name: &str) -> Result<(), To
.map_err(ToolCallError::InvalidParams)
}
-async fn load_config_and_init_registry(ctx: &DispatchCtx) -> Result<crate::config::Config, ToolCallError> {
+async fn load_config_and_init_registry(
+ ctx: &DispatchCtx,
+) -> Result<crate::config::Config, ToolCallError> {
let config = ctx
.load_config()
.await
@@ -222,10 +224,12 @@ async fn load_config_and_init_registry(ctx: &DispatchCtx) -> Result<crate::confi
Ok(config)
}
-async fn build_orchestrator_agent(ctx: &DispatchCtx) -> Result<OpenHumanSessionHost, ToolCallError> {
+async fn build_orchestrator_agent(
+ ctx: &DispatchCtx,
+) -> Result<OpenHumanSessionHost, ToolCallError> {
let config = load_config_and_init_registry(ctx).await?;
- let mut agent =
- OpenHumanSessionHost::from_config_for_agent(ctx, &config, "orchestrator").map_err(|err| {
+ let mut agent = OpenHumanSessionHost::from_config_for_agent(ctx, &config, "orchestrator")
+ .map_err(|err| {
ToolCallError::Internal(format!("failed to build orchestrator agent: {err}"))
})?;
agent.fetch_connected_integrations().await;
@@ -319,7 +323,10 @@ async fn list_subagents(ctx: &DispatchCtx) -> Result<Value, ToolCallError> {
}))
}
-async fn run_subagent_tool(ctx: &DispatchCtx, params: &Map<String, Value>) -> Result<Value, ToolCallError> {
+async fn run_subagent_tool(
+ ctx: &DispatchCtx,
+ params: &Map<String, Value>,
+) -> Result<Value, ToolCallError> {
use super::super::subagent_depth;
let agent_id = validated_param(params, "agent_id")?;
diff --git a/crates/openhuman-core/src/skills/runtime/run_machinery.rs b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
index f0b6cb2f51..d17fb2f301 100644
--- a/crates/openhuman-core/src/skills/runtime/run_machinery.rs
+++ b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
@@ -182,24 +182,23 @@ pub async fn spawn_workflow_run_background(
if config.http_request.allowed_domains.is_empty() {
config.http_request.allowed_domains = vec!["*".to_string()];
}
- let mut agent =
- match OpenHumanSessionHost::from_config_for_agent(
- &crate::core::runtime::DispatchCtx::ambient(),
- &config,
- "orchestrator",
- ) {
- Ok(a) => a,
- Err(e) => {
- let _ = run_log::write_footer(
- &log_path,
- "FAILED",
- 0,
- &format!("build agent: {e:#}"),
- )
- .await;
- return;
- }
- };
+ let mut agent = match OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ "orchestrator",
+ ) {
+ Ok(a) => a,
+ Err(e) => {
+ let _ = run_log::write_footer(
+ &log_path,
+ "FAILED",
+ 0,
+ &format!("build agent: {e:#}"),
+ )
+ .await;
+ return;
+ }
+ };
// Issue #4868 — apply the workflow-run iteration budget AFTER
// construction. The session builder now stamps `orchestrator`'s
// definition cap (15) onto the agent; a full workflow run
diff --git a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
index 313866b7eb..cc38a08422 100644
--- a/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
+++ b/crates/openhuman-core/src/web_chat/session_checkout_tests.rs
@@ -88,7 +88,12 @@ fn prose(history: &[TranscriptEntry]) -> Vec<String> {
}
pub(super) fn host_seeded_with(config: &Config, marker: &str) -> OpenHumanSessionHost {
- let mut host = OpenHumanSessionHost::from_config_for_agent(&crate::core::runtime::DispatchCtx::ambient(), config, "orchestrator").unwrap();
+ let mut host = OpenHumanSessionHost::from_config_for_agent(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ config,
+ "orchestrator",
+ )
+ .unwrap();
host.seed_resume_from_messages(
vec![
("user".to_string(), marker.to_string()),