From 133c0aba9be482de846da8934f3c73e6aad85a57 Mon Sep 17 00:00:00 2001 From: sprooty Date: Sat, 17 Oct 2026 07:42:05 +0000 Subject: [PATCH] fix(core): leave an empty account or companion off the session wire (WI-1064) The Python client skips falsy account and companion strings when it creates a session; the Rust client sent them as "". Match Python by filtering empty values, and pin it with a test. Co-Authored-By: Claude Haiku 5.5 Signed-off-by: sprooty --- engine/core/src/adapters/engine.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engine/core/src/adapters/engine.rs b/engine/core/src/adapters/engine.rs index 54f14394d..ffccce5cb 100644 --- a/engine/core/src/adapters/engine.rs +++ b/engine/core/src/adapters/engine.rs @@ -145,10 +145,11 @@ impl EngineClient { if let Some(work_item) = &spec.work_item { body.insert("work_item".to_string(), Value::String(work_item.clone())); } - if let Some(account) = &spec.account { + // An empty account or companion is left off, as the Python client does. + if let Some(account) = spec.account.as_ref().filter(|text| !text.is_empty()) { body.insert("account".to_string(), Value::String(account.clone())); } - if let Some(companion) = &spec.companion { + if let Some(companion) = spec.companion.as_ref().filter(|text| !text.is_empty()) { body.insert("companion".to_string(), Value::String(companion.clone())); } // Policy and worktree are sent only when they carry something, as the @@ -2434,6 +2435,18 @@ mod tests { assert!(!sent.contains("worktree")); } + #[test] + fn create_session_leaves_out_an_empty_account_or_companion() { + let (seen, transport) = scripted(200, r#"{"id":"s","name":"n","cwd":"/proj"}"#); + let mut spec = CreateSession::new("n", "/proj"); + spec.account = Some(String::new()); + spec.companion = Some(String::new()); + client(transport).create_session(&spec).unwrap(); + let sent = &seen.lock().unwrap()[0]; + assert!(!sent.contains("account")); + assert!(!sent.contains("companion")); + } + #[test] fn create_session_sends_a_policy_and_worktree_that_carry_something() { let (seen, transport) = scripted(200, r#"{"id":"s","name":"n","cwd":"/proj"}"#);