The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(agent_chat): cover param decoding and guard visibility
Steven Enamakel70f4dfaad1af
diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs b/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rsindex 7676e6bf7a..445c93b45b 100644--- a/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs+++ b/crates/openhuman-core/src/agent_runs/agent_chat/controllers_tests.rs@@ -27,6 +27,37 @@ fn ordinary_agent_chat_still_ignores_inference_only_fields() {assert!(params.cwd.is_none());}+#[test]+fn common_agent_chat_params_preserve_success_and_invalid_message_errors() {+ let success = serde_json::json!({+ "message": "hello",+ "model_override": "gpt",+ "temperature": 0.2+ });+ let params: AgentChatParams =+ deserialize_params(success.as_object().unwrap().clone()).expect("valid common params");+ assert_eq!(params.message, "hello");+ assert_eq!(params.model_override.as_deref(), Some("gpt"));+ assert_eq!(params.temperature, Some(0.2));++ let invalid = serde_json::json!({ "message": true });+ let error = deserialize_params::<AgentChatParams>(invalid.as_object().unwrap().clone())+ .expect_err("message must remain a string");+ assert!(error.starts_with("invalid params:"));+}++#[test]+fn inference_agent_chat_agent_id_defaults_to_none() {+ let without: InferenceAgentChatParams =+ serde_json::from_value(serde_json::json!({ "message": "hello" })).expect("decodes");+ assert!(without.agent_id.is_none());+ let with: InferenceAgentChatParams = serde_json::from_value(+ serde_json::json!({ "message": "hello", "agent_id": "alpha" }),+ )+ .expect("decodes with agent id");+ assert_eq!(with.agent_id.as_deref(), Some("alpha"));+}+#[test]fn inference_agent_chat_parses_its_route_fields() {let params: InferenceAgentChatParams = serde_json::from_value(serde_json::json!({diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs b/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rsindex 7e0e8fb183..57f0af124c 100644--- a/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs+++ b/crates/openhuman-core/src/agent_runs/agent_chat/envelope.rs@@ -44,3 +44,7 @@ impl AgentChatReply {Ok(value)}}++#[cfg(test)]+#[path = "envelope_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs b/crates/openhuman-core/src/agent_runs/agent_chat/guards.rsindex a159c9762a..eee1185201 100644--- a/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs+++ b/crates/openhuman-core/src/agent_runs/agent_chat/guards.rs@@ -7,7 +7,7 @@ use crate::security::prompt_injection::{enforce_prompt_input, PromptEnforcementAction, PromptEnforcementContext,};-pub(crate) fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'static str {+fn prompt_guard_user_message(action: PromptEnforcementAction) -> &'static str {match action {PromptEnforcementAction::Allow => "Message accepted.",PromptEnforcementAction::Blocked => {@@ -72,7 +72,7 @@ pub(crate) fn enforce_user_prompt_or_reject(/// it a cwd every shell and file call fails against, so this rejects loudly/// instead. The path is canonicalized so symlinked and `..`-containing inputs/// compare equal to the paths the security policy derives from it.-pub(crate) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::PathBuf>, String> {+pub(super) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::PathBuf>, String> {let Some(raw) = cwd else { return Ok(None) };let trimmed = raw.trim();if trimmed.is_empty() {@@ -98,7 +98,7 @@ pub(crate) fn resolve_turn_cwd(cwd: Option<String>) -> Result<Option<std::path::////// Only ever called on a *clone* of the config, on the `cwd`-present branch —/// the no-`cwd` path is untouched, and nothing process-global is mutated.-pub(crate) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {+pub(super) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {let path = root.to_string_lossy().to_string();if config.autonomy.trusted_roots.iter().any(|r| r.path == path) {return;@@ -130,9 +130,13 @@ pub(crate) fn grant_turn_cwd(config: &mut Config, root: &std::path::Path) {/// [`is_user_authored`](crate::security::turn_origin::AgentTurnOrigin::is_user_authored)/// reads `false` for it and the conversation autosave would silently drop a/// real user message.-pub(crate) fn effective_agent_chat_origin(+pub(super) fn effective_agent_chat_origin(ctx: &crate::core::runtime::DispatchCtx,) -> crate::security::turn_origin::AgentTurnOrigin {ctx.turn_origin_or_scoped().unwrap_or(crate::security::turn_origin::AgentTurnOrigin::DirectChat)}++#[cfg(test)]+#[path = "guards_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent_runs/mod.rs b/crates/openhuman-core/src/agent_runs/mod.rsindex 6b2aabfa68..70da6d69ad 100644--- a/crates/openhuman-core/src/agent_runs/mod.rs+++ b/crates/openhuman-core/src/agent_runs/mod.rs@@ -15,6 +15,10 @@ pub(crate) use agent_chat::all_inference_agent_chat_registered_controllers;pub(crate) use agent_teams::{all_agent_team_controller_schemas, all_agent_team_registered_controllers,};+/// Canonical RPC method name for the `inference.agent_chat` controller.+///+/// Hosts reference this value so their dispatch string stays aligned with the+/// registered controller's namespace and function.pub const INFERENCE_AGENT_CHAT: &str = "openhuman.inference_agent_chat";pub(crate) use command_center::{all_command_center_controller_schemas, all_command_center_registered_controllers,diff --git a/crates/openhuman-core/src/inference/host_runtime/ops.rs b/crates/openhuman-core/src/inference/host_runtime/ops.rsindex 26ed3469fe..e044fde5db 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops.rs@@ -19,9 +19,5 @@ pub use runtime_ops::{local_ai_transcribe_bytes, local_ai_tts, local_ai_vision_prompt,};-#[cfg(test)]-use crate::agent_runs::agent_chat::guards::{- effective_agent_chat_origin, grant_turn_cwd, normalize_model_override, resolve_turn_cwd,-};#[cfg(test)]use crate::config::Config;diff --git a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rsindex 77732e8eb6..03e7e765e3 100644--- a/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs+++ b/crates/openhuman-core/src/inference/host_runtime/ops_tests.rs@@ -1,6 +1,4 @@use super::*;-use crate::agent_runs::agent_chat::guards::effective_agent_chat_origin;-use crate::agent_runs::agent_chat::{agent_chat_for, AgentChatEnv, AgentChatTarget};// ── Op-level validation / error paths (no hardware) ───────────