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(local): add tests for agent_chat unknown agent and agent_id schema
Steven Enamakel3e5340a9a257
diff --git a/crates/openhuman-core/src/inference/local/ops_tests.rs b/crates/openhuman-core/src/inference/local/ops_tests.rsindex a43359f9bf..040886f607 100644--- a/crates/openhuman-core/src/inference/local/ops_tests.rs+++ b/crates/openhuman-core/src/inference/local/ops_tests.rs@@ -360,3 +360,46 @@ async fn effective_origin_keeps_an_embedder_scoped_label() {}));}++// ── `agent_chat_for`: explicit targets and thread-scoped resume ───────────++/// An unknown `agent_id` is a caller error surfaced before any provider is+/// touched, not a silent fall-through to the orchestrator.+#[tokio::test]+async fn agent_chat_for_rejects_an_unknown_agent_id() {+ use crate::inference::local::ops::{agent_chat_for, AgentChatTarget};+ let tmp = tempfile::tempdir().unwrap();+ let mut config = test_config(&tmp);+ std::fs::create_dir_all(&config.workspace_dir).unwrap();++ let err = agent_chat_for(+ &mut config,+ AgentChatTarget::AgentId("no-such-agent-xyz"),+ "hello",+ None,+ None,+ None,+ None,+ None,+ )+ .await+ .expect_err("an unknown agent id must be refused");+ assert!(+ err.to_lowercase().contains("no-such-agent-xyz") || err.to_lowercase().contains("unknown"),+ "error names the id or says unknown: {err}"+ );+}++/// `AgentChatTarget` is `Copy` and the orchestrator arm is the historical+/// `agent_chat`, so the delegating wrapper and the explicit call agree.+#[test]+fn agent_chat_target_default_is_the_orchestrator() {+ use crate::inference::local::ops::AgentChatTarget;+ let target = AgentChatTarget::Orchestrator;+ let copy = target;+ assert!(matches!(copy, AgentChatTarget::Orchestrator));+ assert!(matches!(+ AgentChatTarget::AgentId("x"),+ AgentChatTarget::AgentId("x")+ ));+}diff --git a/crates/openhuman-core/src/inference/local/schemas_tests.rs b/crates/openhuman-core/src/inference/local/schemas_tests.rsindex d21d7d1969..63cf765c2d 100644--- a/crates/openhuman-core/src/inference/local/schemas_tests.rs+++ b/crates/openhuman-core/src/inference/local/schemas_tests.rs@@ -160,3 +160,30 @@ async fn install_piper_handler_serializes_concurrent_calls() {);}}++/// `agent_id` is a declared, optional input of `inference.agent_chat` — the+/// embed crate pins its `TurnRequest` field names against this schema, so a+/// param the controller accepts but never declares would be unreachable.+#[test]+fn agent_chat_declares_an_optional_agent_id() {+ let schema = schemas("agent_chat");+ let field = schema+ .inputs+ .iter()+ .find(|f| f.name == "agent_id")+ .expect("agent_chat declares agent_id");+ assert!(!field.required, "agent_id must stay optional");+}++/// The params struct accepts the field and, absent, defaults it to `None`, so+/// every existing caller keeps running the orchestrator.+#[test]+fn agent_chat_params_default_agent_id_to_none() {+ let without: AgentChatParams =+ serde_json::from_value(serde_json::json!({ "message": "hi" })).expect("decodes");+ assert!(without.agent_id.is_none());+ let with: AgentChatParams =+ serde_json::from_value(serde_json::json!({ "message": "hi", "agent_id": "alpha" }))+ .expect("decodes");+ assert_eq!(with.agent_id.as_deref(), Some("alpha"));+}