Skip to content

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

chore: reformat long lines and adjust import ordering across multiple crates

Steven Enamakel72052adfc877
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
index e731aaa747..d74ec241b6 100644
--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
@@ -39,7 +39,9 @@ async fn from_config_with_definition_stamps_the_definition_on_the_session() {
.expect("the explicit definition is stamped");
assert_eq!(resolved.id, "embedded-alpha");
assert_eq!(resolved.sandbox_mode, SandboxMode::ReadOnly);
- assert!(matches!(resolved.system_prompt, PromptSource::Inline(ref p) if p == "You are explicit."));
+ assert!(
+ matches!(resolved.system_prompt, PromptSource::Inline(ref p) if p == "You are explicit.")
+ );
}
#[tokio::test]
diff --git a/crates/openhuman-core/src/agent/harness/session/turn/tools.rs b/crates/openhuman-core/src/agent/harness/session/turn/tools.rs
index b51ee9342d..ae3914e5d5 100644
--- a/crates/openhuman-core/src/agent/harness/session/turn/tools.rs
+++ b/crates/openhuman-core/src/agent/harness/session/turn/tools.rs
@@ -45,23 +45,23 @@ impl Agent {
let allowed_subagent_ids = self
.resolved_definition()
.map(|definition| {
- definition
- .subagents
- .iter()
- .filter_map(|entry| match entry {
- crate::agent::harness::definition::SubagentEntry::AgentId(id) => {
- Some(id.clone())
- }
- crate::agent::harness::definition::SubagentEntry::Skills(wildcard)
- if wildcard.matches_all() =>
- {
- Some("integrations_agent".to_string())
- }
- crate::agent::harness::definition::SubagentEntry::Skills(_) => None,
- })
- .collect()
- })
- .unwrap_or_default();
+ definition
+ .subagents
+ .iter()
+ .filter_map(|entry| match entry {
+ crate::agent::harness::definition::SubagentEntry::AgentId(id) => {
+ Some(id.clone())
+ }
+ crate::agent::harness::definition::SubagentEntry::Skills(wildcard)
+ if wildcard.matches_all() =>
+ {
+ Some("integrations_agent".to_string())
+ }
+ crate::agent::harness::definition::SubagentEntry::Skills(_) => None,
+ })
+ .collect()
+ })
+ .unwrap_or_default();
harness::ParentExecutionContext {
agent_definition_id: self.agent_definition_id.clone(),
diff --git a/crates/openhuman-core/src/core/runtime/context_tests.rs b/crates/openhuman-core/src/core/runtime/context_tests.rs
index 5de4b3c6e5..4e3b3ee329 100644
--- a/crates/openhuman-core/src/core/runtime/context_tests.rs
+++ b/crates/openhuman-core/src/core/runtime/context_tests.rs
@@ -106,7 +106,10 @@ fn derive_with_keeps_the_host_and_overrides_the_per_agent_fields() {
assert_eq!(child.host_kind(), parent.host_kind());
assert_eq!(child.domains(), crate::core::runtime::DomainSet::kernel());
- assert_eq!(child.tool_groups(), crate::tools::toolpacks::ToolGroups::none());
+ assert_eq!(
+ child.tool_groups(),
+ crate::tools::toolpacks::ToolGroups::none()
+ );
assert!(!child.user_skill_roots());
assert_eq!(
child.workspace_dir().expect("child workspace"),
diff --git a/crates/openhuman-core/src/inference/local/schemas.rs b/crates/openhuman-core/src/inference/local/schemas.rs
index aab16d7e40..51f97f033f 100644
--- a/crates/openhuman-core/src/inference/local/schemas.rs
+++ b/crates/openhuman-core/src/inference/local/schemas.rs
@@ -299,7 +299,9 @@ fn handle_agent_chat(params: Map<String, Value>) -> ControllerFuture {
let p = deserialize_params::<AgentChatParams>(params)?;
let mut config = config_rpc::load_config_with_timeout().await?;
let target = match p.agent_id.as_deref().map(str::trim) {
- Some(id) if !id.is_empty() => crate::inference::local::ops::AgentChatTarget::AgentId(id),
+ Some(id) if !id.is_empty() => {
+ crate::inference::local::ops::AgentChatTarget::AgentId(id)
+ }
_ => crate::inference::local::ops::AgentChatTarget::Orchestrator,
};
to_json(
diff --git a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
index bd454fc032..9699201a78 100644
--- a/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/access_gates.rs
@@ -164,7 +164,9 @@ pub(crate) fn verify_backend_session_active(config: &Config) -> anyhow::Result<(
// An API key is a standing credential: no session to be active, nothing
// for the scheduler gate to have expired.
if crate::security::credentials::api_key::has_api_key_in(&state_dir, config.secrets.encrypt) {
- log::debug!("[providers][access-gate] api-key credential satisfies the backend session gate");
+ log::debug!(
+ "[providers][access-gate] api-key credential satisfies the backend session gate"
+ );
return Ok(());
}
// Fast path: the scheduler gate already knows the session is dead.
diff --git a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
index 7f7f9a620a..ecae289017 100644
--- a/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
+++ b/crates/openhuman-core/src/inference/provider/openhuman_backend_model.rs
@@ -118,7 +118,9 @@ impl OpenHumanBackendModel {
&self.state_dir(),
self.options.secrets_encrypt,
)? {
- log::debug!("[providers][openhuman-backend] authenticating managed inference with api-key");
+ log::debug!(
+ "[providers][openhuman-backend] authenticating managed inference with api-key"
+ );
return Ok(key);
}
if crate::cron::scheduler_gate::is_signed_out() {
diff --git a/crates/openhuman-core/src/security/credentials/api_key_tests.rs b/crates/openhuman-core/src/security/credentials/api_key_tests.rs
index ba43d8223e..bf77d8f073 100644
--- a/crates/openhuman-core/src/security/credentials/api_key_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/api_key_tests.rs
@@ -21,7 +21,10 @@ fn store_then_get_round_trips_and_marks_kind() {
profile.metadata.get(API_KEY_KIND_META).map(String::as_str),
Some(API_KEY_KIND)
);
- assert_eq!(get_api_key(&config).expect("get").as_deref(), Some("th_live_abc"));
+ assert_eq!(
+ get_api_key(&config).expect("get").as_deref(),
+ Some("th_live_abc")
+ );
assert!(has_api_key(&config));
}
@@ -47,7 +50,9 @@ fn clear_removes_the_profile() {
#[test]
fn api_key_wins_over_an_expired_session() {
use crate::security::credentials::session_support::SESSION_EXPIRES_AT_META;
- use crate::security::credentials::{AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME};
+ use crate::security::credentials::{
+ AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME,
+ };
let dir = tempfile::tempdir().expect("tempdir");
let config = config_in(dir.path());
@@ -57,7 +62,13 @@ fn api_key_wins_over_an_expired_session() {
(chrono::Utc::now() - chrono::Duration::hours(1)).to_rfc3339(),
);
AuthService::from_config(&config)
- .store_provider_token(APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME, "jwt", meta, true)
+ .store_provider_token(
+ APP_SESSION_PROVIDER,
+ DEFAULT_AUTH_PROFILE_NAME,
+ "jwt",
+ meta,
+ true,
+ )
.expect("store session");
assert!(matches!(
resolve_backend_credential(&config),
diff --git a/crates/openhuman-core/src/security/credentials/ops/session_query.rs b/crates/openhuman-core/src/security/credentials/ops/session_query.rs
index 2e0acf59f0..0255bd6a1d 100644
--- a/crates/openhuman-core/src/security/credentials/ops/session_query.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/session_query.rs
@@ -118,9 +118,7 @@ pub async fn auth_store_api_key(
/// Remove the stored TinyHumans API key. The scheduler gate follows whatever
/// credential remains.
-pub async fn auth_clear_api_key(
- config: &Config,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
+pub async fn auth_clear_api_key(config: &Config) -> Result<RpcOutcome<serde_json::Value>, String> {
let removed = super::super::api_key::clear_api_key(config).map_err(|e| e.to_string())?;
if !super::super::session_support::has_backend_credential(config) {
crate::cron::scheduler_gate::set_signed_out(true);
diff --git a/crates/openhuman-core/src/skills/ops_discovery_tests.rs b/crates/openhuman-core/src/skills/ops_discovery_tests.rs
index f042831dcd..731e988825 100644
--- a/crates/openhuman-core/src/skills/ops_discovery_tests.rs
+++ b/crates/openhuman-core/src/skills/ops_discovery_tests.rs
@@ -650,8 +650,11 @@ async fn discovery_home_dir_is_hidden_by_a_context_without_user_skill_roots() {
ContextOverlay::new(config.clone(), DomainSet::full(), Default::default())
.without_user_skill_roots(),
);
- let visible =
- parent.derive_with(ContextOverlay::new(config, DomainSet::full(), Default::default()));
+ let visible = parent.derive_with(ContextOverlay::new(
+ config,
+ DomainSet::full(),
+ Default::default(),
+ ));
let under_hidden = CoreContext::scope(hidden, async { discovery_home_dir() }).await;
assert_eq!(under_hidden, None, "user-scope roots must be hidden");
diff --git a/crates/openhuman-embed/examples/two_agents.rs b/crates/openhuman-embed/examples/two_agents.rs
index 8ef808ca84..2facf0d739 100644
--- a/crates/openhuman-embed/examples/two_agents.rs
+++ b/crates/openhuman-embed/examples/two_agents.rs
@@ -112,7 +112,10 @@ async fn run() -> anyhow::Result<()> {
println!("fixer action dir: {}", fixer.action_dir().display());
let review = reviewer.run(&prompt).await?;
- println!("\n[reviewer] session {}\n{}", review.session_id, review.reply);
+ println!(
+ "\n[reviewer] session {}\n{}",
+ review.session_id, review.reply
+ );
let fix = fixer
.turn(format!(
diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rs
index f5181e1dc4..012c0ac88f 100644
--- a/crates/openhuman-embed/src/agent/build.rs
+++ b/crates/openhuman-embed/src/agent/build.rs
@@ -88,12 +88,12 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn
{
profile.allowed_mcp_servers = None;
}
- ensure_profile_home(&config.workspace_dir, &config.action_dir, &profile).map_err(
- |source| AgentError::Workspace {
+ ensure_profile_home(&config.workspace_dir, &config.action_dir, &profile).map_err(|source| {
+ AgentError::Workspace {
what: "create the agent's profile home",
source,
- },
- )?;
+ }
+ })?;
let layout = AgentLayout::resolve(&config.workspace_dir, &profile, action_dir);
// ── skills ───────────────────────────────────────────────────────────
@@ -158,7 +158,10 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn
}
/// Every family the agent asks for must be one the runtime registered.
-pub(crate) fn check_domains_narrow(requested: DomainSet, runtime: DomainSet) -> Result<(), AgentError> {
+pub(crate) fn check_domains_narrow(
+ requested: DomainSet,
+ runtime: DomainSet,
+) -> Result<(), AgentError> {
let widened: Vec<String> = DomainGroup::ALL
.iter()
.filter(|group| requested.allows(**group) && !runtime.allows(**group))
diff --git a/crates/openhuman-embed/src/agent/definition.rs b/crates/openhuman-embed/src/agent/definition.rs
index c6f4d6e6b0..c748e2b38b 100644
--- a/crates/openhuman-embed/src/agent/definition.rs
+++ b/crates/openhuman-embed/src/agent/definition.rs
@@ -79,7 +79,8 @@ impl AgentDefinitionSpec {
I: IntoIterator<Item = S>,
S: Into<String>,
{
- self.disallowed_tools.extend(tools.into_iter().map(Into::into));
+ self.disallowed_tools
+ .extend(tools.into_iter().map(Into::into));
self
}
@@ -116,12 +117,9 @@ impl AgentDefinitionSpec {
/// Materialize the core definition for agent `id`.
pub(crate) fn into_core(self, id: &str) -> Result<AgentDefinition, AgentError> {
let registry = AgentDefinitionRegistry::builtins_only();
- let mut def = registry
- .get(ORCHESTRATOR_ID)
- .cloned()
- .ok_or_else(|| {
- AgentError::Invalid("built-in orchestrator definition is missing".to_string())
- })?;
+ let mut def = registry.get(ORCHESTRATOR_ID).cloned().ok_or_else(|| {
+ AgentError::Invalid("built-in orchestrator definition is missing".to_string())
+ })?;
def.id = id.to_string();
def.display_name = Some(self.display_name.unwrap_or_else(|| id.to_string()));
if let Some(text) = self.when_to_use {
diff --git a/crates/openhuman-embed/src/agent/definition_tests.rs b/crates/openhuman-embed/src/agent/definition_tests.rs
index 98eb5f70c9..adbbf034cb 100644
--- a/crates/openhuman-embed/src/agent/definition_tests.rs
+++ b/crates/openhuman-embed/src/agent/definition_tests.rs
@@ -2,7 +2,9 @@ use super::*;
#[test]
fn default_is_the_orchestrator_under_the_agents_id() {
- let def = AgentDefinitionSpec::new().into_core("alpha").expect("definition");
+ let def = AgentDefinitionSpec::new()
+ .into_core("alpha")
+ .expect("definition");
assert_eq!(def.id, "alpha");
assert_eq!(def.display_name(), "alpha");
assert!(matches!(def.system_prompt, PromptSource::Dynamic(_)));
@@ -23,7 +25,9 @@ fn setters_override_one_aspect_each() {
.into_core("alpha")
.expect("definition");
assert!(matches!(def.system_prompt, PromptSource::Inline(ref p) if p == "Be terse."));
- assert!(matches!(def.tools, ToolScope::Named(ref names) if names == &["read_file".to_string()]));
+ assert!(
+ matches!(def.tools, ToolScope::Named(ref names) if names == &["read_file".to_string()])
+ );
assert!(def.disallowed_tools.iter().any(|t| t == "shell"));
assert_eq!(def.sandbox_mode, SandboxMode::Sandboxed);
assert_eq!(def.max_iterations, 3);
diff --git a/crates/openhuman-embed/src/agent/layout_tests.rs b/crates/openhuman-embed/src/agent/layout_tests.rs
index 41965c0c97..478cd46f7d 100644
--- a/crates/openhuman-embed/src/agent/layout_tests.rs
+++ b/crates/openhuman-embed/src/agent/layout_tests.rs
@@ -15,7 +15,10 @@ fn dedicated_memory_keys_transcripts_by_agent_id() {
layout.skills,
Path::new("/r/workspace/personalities/alpha/skills")
);
- assert_eq!(layout.transcripts, Path::new("/r/workspace/session_raw-alpha"));
+ assert_eq!(
+ layout.transcripts,
+ Path::new("/r/workspace/session_raw-alpha")
+ );
assert_eq!(layout.action_dir, Path::new("/r/a"));
}
@@ -33,7 +36,12 @@ fn default_action_dir_is_a_workspace_sibling_or_a_profile_dir() {
Path::new("/r/agents/a/action")
);
assert_eq!(
- AgentLayout::default_action_dir(Path::new("/home/u/.openhuman"), Path::new("/home/u/OpenHuman/projects"), true, "a"),
+ AgentLayout::default_action_dir(
+ Path::new("/home/u/.openhuman"),
+ Path::new("/home/u/OpenHuman/projects"),
+ true,
+ "a"
+ ),
Path::new("/home/u/OpenHuman/projects/profiles/a")
);
}
diff --git a/crates/openhuman-embed/src/agent/mod.rs b/crates/openhuman-embed/src/agent/mod.rs
index 0ea32701e6..287ad6df7f 100644
--- a/crates/openhuman-embed/src/agent/mod.rs
+++ b/crates/openhuman-embed/src/agent/mod.rs
@@ -126,8 +126,8 @@ impl Agent {
/// anything set on the returned [`Turn`] overrides them for that turn
/// alone.
pub fn turn(&self, message: impl Into<String>) -> Turn {
- let mut turn =
- Turn::new(TurnTarget::Agent(Arc::clone(&self.inner)), message).with_agent_id(&self.inner.id);
+ let mut turn = Turn::new(TurnTarget::Agent(Arc::clone(&self.inner)), message)
+ .with_agent_id(&self.inner.id);
if let Some(route) = self.inner.provider.route() {
turn = turn.route(route.clone());
}
diff --git a/crates/openhuman-embed/src/agent/spec_tests.rs b/crates/openhuman-embed/src/agent/spec_tests.rs
index 61203ab5bd..beffcb335a 100644
--- a/crates/openhuman-embed/src/agent/spec_tests.rs
+++ b/crates/openhuman-embed/src/agent/spec_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::AgentError;
use crate::agent::build::{check_domains_narrow, check_tool_groups_narrow};
+use crate::AgentError;
use openhuman_core::tools::toolpacks::GroupMode;
#[test]
@@ -15,7 +15,10 @@ fn model_without_a_route_pins_the_model_on_an_inherited_provider() {
#[test]
fn debug_omits_the_provider_and_closure() {
let spec = AgentSpec::new("alpha")
- .provider(Provider::openai_compatible("https://x.example", "sk-secret"))
+ .provider(Provider::openai_compatible(
+ "https://x.example",
+ "sk-secret",
+ ))
.config(|_| {});
let debug = format!("{spec:?}");
assert!(debug.contains("alpha"));
diff --git a/crates/openhuman-embed/src/harness/skills_tests.rs b/crates/openhuman-embed/src/harness/skills_tests.rs
index 37b93b641a..3e8b0b06a8 100644
--- a/crates/openhuman-embed/src/harness/skills_tests.rs
+++ b/crates/openhuman-embed/src/harness/skills_tests.rs
@@ -57,7 +57,10 @@ fn a_directory_without_a_manifest_is_not_a_bundle() {
std::fs::create_dir_all(src.path().join("notaskill")).expect("mkdir");
std::fs::write(src.path().join("notaskill/readme.txt"), "hi").expect("write");
- assert_eq!(install(src.path(), &ws.path().join("skills")).expect("install"), 0);
+ assert_eq!(
+ install(src.path(), &ws.path().join("skills")).expect("install"),
+ 0
+ );
assert!(!ws.path().join("skills/notaskill").exists());
}
@@ -76,7 +79,10 @@ fn a_symlinked_bundle_is_skipped_not_followed() {
std::os::unix::fs::symlink(outside.path().join("evil"), src.path().join("evil"))
.expect("symlink");
- assert_eq!(install(src.path(), &ws.path().join("skills")).expect("install"), 0);
+ assert_eq!(
+ install(src.path(), &ws.path().join("skills")).expect("install"),
+ 0
+ );
assert!(!ws.path().join("skills/evil").exists());
}
@@ -126,8 +132,11 @@ fn a_symlinked_manifest_does_not_make_a_directory_a_bundle() {
#[test]
fn a_missing_skills_dir_is_a_clear_error_not_a_silent_skip() {
let ws = tempfile::tempdir().expect("ws");
- let err = install(std::path::Path::new("/nonexistent/skills"), &ws.path().join("skills"))
- .expect_err("a missing directory is a caller mistake");
+ let err = install(
+ std::path::Path::new("/nonexistent/skills"),
+ &ws.path().join("skills"),
+ )
+ .expect_err("a missing directory is a caller mistake");
assert!(matches!(err, HarnessError::Invalid(_)));
}
@@ -135,5 +144,8 @@ fn a_missing_skills_dir_is_a_clear_error_not_a_silent_skip() {
fn an_empty_skills_dir_is_allowed() {
let src = tempfile::tempdir().expect("src");
let ws = tempfile::tempdir().expect("ws");
- assert_eq!(install(src.path(), &ws.path().join("skills")).expect("install"), 0);
+ assert_eq!(
+ install(src.path(), &ws.path().join("skills")).expect("install"),
+ 0
+ );
}
diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rs
index c882e08ac3..f1dacc3286 100644
--- a/crates/openhuman-embed/src/lib.rs
+++ b/crates/openhuman-embed/src/lib.rs
@@ -88,8 +88,7 @@ mod runtime;
mod turn;
pub use agent::{
- Agent, AgentDefinitionSpec, AgentError, AgentLayout, AgentSpec, SandboxModeSpec,
- ToolScopeSpec,
+ Agent, AgentDefinitionSpec, AgentError, AgentLayout, AgentSpec, SandboxModeSpec, ToolScopeSpec,
};
pub use auth::{Auth, AuthState, Session};
pub use config::{Config, RuntimeFlags};
@@ -98,8 +97,6 @@ pub use error::CoreError;
pub use harness::{
Access, Harness, HarnessBuilder, HarnessCore, HarnessError, Provider, Workspace,
};
-pub use runtime::{ApiKey, Runtime, RuntimeBuilder, RuntimeError};
-pub use turn::{absolute, Route, Turn, TurnOutcome, TurnRequest};
#[cfg(feature = "mcp")]
pub use harness::{HttpHeader, McpAuthConfig, McpServer};
#[cfg(feature = "medulla")]
@@ -107,6 +104,8 @@ pub use medulla::{
AbortResult, Medulla, MedullaStatus, Message, RosterWorker, SendResult, SessionCreated,
SessionDetail, SessionSummary, WireEventEnvelope,
};
+pub use runtime::{ApiKey, Runtime, RuntimeBuilder, RuntimeError};
+pub use turn::{absolute, Route, Turn, TurnOutcome, TurnRequest};
use std::sync::Arc;
diff --git a/crates/openhuman-embed/src/runtime/builder.rs b/crates/openhuman-embed/src/runtime/builder.rs
index 538076724b..e4de572f93 100644
--- a/crates/openhuman-embed/src/runtime/builder.rs
+++ b/crates/openhuman-embed/src/runtime/builder.rs
@@ -195,9 +195,9 @@ impl RuntimeBuilder {
// knobs (access tier, backend URL, API key) are applied *on top* of it.
let mut config = match (&self.workspace, self.config) {
(Workspace::Inherit, Some(config)) => config,
- (Workspace::Inherit, None) => Config::load_or_init()
- .await
- .map_err(RuntimeError::Build)?,
+ (Workspace::Inherit, None) => {
+ Config::load_or_init().await.map_err(RuntimeError::Build)?
+ }
(_, supplied) => {
let mut config = supplied.unwrap_or_default();
config.workspace_dir = resolved.workspace_dir.clone();
diff --git a/crates/openhuman-embed/src/turn.rs b/crates/openhuman-embed/src/turn.rs
index a0146e91a4..c0ee10bcb9 100644
--- a/crates/openhuman-embed/src/turn.rs
+++ b/crates/openhuman-embed/src/turn.rs
@@ -429,30 +429,30 @@ async fn dispatch(target: TurnTarget, request: TurnRequest) -> Result<String, Co
let turn: std::pin::Pin<
Box<dyn std::future::Future<Output = Result<String, CoreError>> + Send>,
> = Box::pin(async move {
- use openhuman_core::inference::local::ops::{agent_chat_for, AgentChatTarget};
- let mut config = inner.config.clone();
- let route = openhuman_core::config::schema::EphemeralRoute::from_params(
- request.inference_url,
- request.api_key,
- );
- let target = AgentChatTarget::Definition {
- definition: &inner.definition,
- profile: Some(&inner.profile),
- profile_prompt_suffix: inner.profile.system_prompt_suffix.as_deref(),
- };
- agent_chat_for(
- &mut config,
- target,
- &request.message,
- request.model_override,
- request.temperature,
- request.thread_id,
- request.cwd,
- route,
- )
- .await
- .map(|outcome| outcome.value)
- .map_err(|raw| CoreError::from_rpc_string(AGENT_CHAT, raw))
+ use openhuman_core::inference::local::ops::{agent_chat_for, AgentChatTarget};
+ let mut config = inner.config.clone();
+ let route = openhuman_core::config::schema::EphemeralRoute::from_params(
+ request.inference_url,
+ request.api_key,
+ );
+ let target = AgentChatTarget::Definition {
+ definition: &inner.definition,
+ profile: Some(&inner.profile),
+ profile_prompt_suffix: inner.profile.system_prompt_suffix.as_deref(),
+ };
+ agent_chat_for(
+ &mut config,
+ target,
+ &request.message,
+ request.model_override,
+ request.temperature,
+ request.thread_id,
+ request.cwd,
+ route,
+ )
+ .await
+ .map(|outcome| outcome.value)
+ .map_err(|raw| CoreError::from_rpc_string(AGENT_CHAT, raw))
});
runtime.run_in(ctx, turn).await
}
diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rs
index b489caf819..adc32bd4f5 100644
--- a/crates/openhuman-embed/tests/runtime_agents.rs
+++ b/crates/openhuman-embed/tests/runtime_agents.rs
@@ -48,7 +48,10 @@ fn one_runtime_hosts_independently_configured_agents() {
// runtime's API key must arrive as a bearer, and nothing else.
Mock::given(method("POST"))
.and(path("/openai/v1/chat/completions"))
- .and(header("authorization", format!("Bearer {API_KEY}").as_str()))
+ .and(header(
+ "authorization",
+ format!("Bearer {API_KEY}").as_str(),
+ ))
.respond_with(
ResponseTemplate::new(200).set_body_json(chat_completion("managed-ok")),
)
@@ -118,7 +121,13 @@ fn one_runtime_hosts_independently_configured_agents() {
assert!(state.is_authenticated, "api key must count as signed in");
assert!(state.user_id.is_none(), "an api key carries no user");
assert!(
- runtime.core().auth().token().await.expect("token").is_none(),
+ runtime
+ .core()
+ .auth()
+ .token()
+ .await
+ .expect("token")
+ .is_none(),
"no session token exists"
);
@@ -150,11 +159,8 @@ fn one_runtime_hosts_independently_configured_agents() {
.agent(
AgentSpec::new("beta")
.provider(
- Provider::openai_compatible(
- format!("{}/v1", provider_b.uri()),
- "sk-b",
- )
- .model("beta-model"),
+ Provider::openai_compatible(format!("{}/v1", provider_b.uri()), "sk-b")
+ .model("beta-model"),
)
.access(Access::full())
.action_dir(beta_action.path()),
@@ -280,9 +286,9 @@ fn one_runtime_hosts_independently_configured_agents() {
let a2_body: serde_json::Value = serde_json::from_slice(&a2_req.body).unwrap();
let a2_messages = a2_body["messages"].as_array().cloned().unwrap_or_default();
assert!(
- a2_messages
- .iter()
- .any(|m| m["content"].as_str().is_some_and(|c| c.contains("hello from alpha"))),
+ a2_messages.iter().any(|m| m["content"]
+ .as_str()
+ .is_some_and(|c| c.contains("hello from alpha"))),
"the second turn on a thread must carry the first exchange: {a2_messages:?}"
);
@@ -298,7 +304,10 @@ fn one_runtime_hosts_independently_configured_agents() {
.collect();
assert_eq!(managed.len(), 1, "one managed completion");
assert_eq!(
- managed[0].headers.get("authorization").map(|v| v.to_str().unwrap()),
+ managed[0]
+ .headers
+ .get("authorization")
+ .map(|v| v.to_str().unwrap()),
Some(format!("Bearer {API_KEY}").as_str())
);
assert!(
@@ -334,7 +343,10 @@ fn one_runtime_hosts_independently_configured_agents() {
let err = runtime
.agent(AgentSpec::new("alpha"))
.expect_err("duplicate id");
- assert!(matches!(err, AgentError::DuplicateId(ref id) if id == "alpha"), "{err:?}");
+ assert!(
+ matches!(err, AgentError::DuplicateId(ref id) if id == "alpha"),
+ "{err:?}"
+ );
let err = runtime
.agent(AgentSpec::new("Not Valid!"))
.expect_err("invalid id");
@@ -346,7 +358,10 @@ fn one_runtime_hosts_independently_configured_agents() {
// Dropping every handle releases the id.
drop(gamma);
- assert_eq!(runtime.agent_ids(), vec!["alpha".to_string(), "beta".to_string()]);
+ assert_eq!(
+ runtime.agent_ids(),
+ vec!["alpha".to_string(), "beta".to_string()]
+ );
let _gamma_again = runtime
.agent(AgentSpec::new("gamma"))
.expect("id reusable after drop");
@@ -354,7 +369,9 @@ fn one_runtime_hosts_independently_configured_agents() {
drop(alpha);
drop(beta);
drop(_gamma_again);
- let runtime = std::sync::Arc::try_unwrap(runtime).ok().expect("sole owner");
+ let runtime = std::sync::Arc::try_unwrap(runtime)
+ .ok()
+ .expect("sole owner");
drop(runtime);
assert!(
!workspace_dir.exists(),