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(mcp): cover omitted vs null tool arguments
Steven Enamakelda77b57cad2c
diff --git a/crates/openhuman-core/src/mcp/registry/tools_tests.rs b/crates/openhuman-core/src/mcp/registry/tools_tests.rsindex 62d064f812..032e7fc560 100644--- a/crates/openhuman-core/src/mcp/registry/tools_tests.rs+++ b/crates/openhuman-core/src/mcp/registry/tools_tests.rs@@ -248,6 +248,7 @@ fn workspace_config(dir: &std::path::Path) -> Arc<Config> {#[derive(Clone, Default)]struct ToolCallPort {arguments: SharedArc<Mutex<Vec<Value>>>,+ normalized_arguments: SharedArc<Mutex<Vec<Option<Value>>>>,connected: bool,}@@ -350,6 +351,10 @@ impl crate::mcp::module_client::McpModulePort for ToolCallPort {&self,arguments: Option<Value>,) -> Result<serde_json::Map<String, Value>, crate::modules::client::ModuleCallError> {+ self.normalized_arguments+ .lock()+ .unwrap()+ .push(arguments.clone());match arguments.unwrap_or(Value::Null) {Value::Null => Ok(serde_json::Map::new()),Value::Object(arguments) => Ok(arguments),@@ -399,3 +404,32 @@ async fn tool_call_with_string_arguments_reaches_the_module_as_an_object() {&[json!({ "city": "Paris" })]);}++#[tokio::test]+async fn tool_call_preserves_missing_arguments_as_distinct_from_json_null() {+ let dir = tempfile::tempdir().expect("temp workspace");+ let config = workspace_config(dir.path());+ let port = ToolCallPort {+ connected: true,+ ..ToolCallPort::default()+ };+ let normalized_arguments = SharedArc::clone(&port.normalized_arguments);+ crate::mcp::module_client::McpConfiguredClient::install_test_port(&config, Box::new(port))+ .expect("test module port");+ let tool = McpRegistryToolCallTool::new(Arc::clone(&config));++ for args in [+ json!({"server_id":"srv-1", "tool_name":"forecast"}),+ json!({"server_id":"srv-1", "tool_name":"forecast", "arguments":null}),+ ] {+ tool.execute(args)+ .await+ .expect("missing and null arguments normalize successfully");+ }++ assert_eq!(+ normalized_arguments.lock().unwrap().as_slice(),+ &[None, Some(Value::Null)],+ "the host must preserve the bus distinction between omitted arguments and JSON null"+ );+}