Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(serve): count a handshake that completes as a signal arrives as connected

AkitaOnRailsdc0cbfd1a924
diff --git a/crates/ai-memory-cli/src/commands/serve.rs b/crates/ai-memory-cli/src/commands/serve.rs
index 40c98ec6..cf69c5c0 100644
--- a/crates/ai-memory-cli/src/commands/serve.rs
+++ b/crates/ai-memory-cli/src/commands/serve.rs
@@ -1199,6 +1199,10 @@ pub async fn run(config: &Config, args: ServeArgs) -> Result<()> {
// connected is the exact state a launched-but-unused server sits
// in, and until #699 nothing here listened for one at all.
let service = tokio::select! {
+ // A handshake that completes in the same poll a signal
+ // arrives in counts as connected: an unbiased select would
+ // pick either branch at random.
+ biased;
service = server.serve(stdio()) => Some(service?),
signal = shutdown.recv() => {
info!(signal, "shutdown signal received before a client connected; stopping");