Skip to content

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

Rust

fix(run): forward a bind-derived server URL into the ai-jail re-exec

AkitaOnRails458290e3413d
diff --git a/crates/ai-memory-cli/src/commands/run.rs b/crates/ai-memory-cli/src/commands/run.rs
index 131cbcec..51de8cf1 100644
--- a/crates/ai-memory-cli/src/commands/run.rs
+++ b/crates/ai-memory-cli/src/commands/run.rs
@@ -2598,7 +2598,9 @@ fn jail_forwarded_names(config: &Config, resolved: &[(&'static str, String)]) ->
/// same value.
fn jail_resolved_env(config: &Config) -> Vec<(&'static str, String)> {
let mut env = Vec::new();
- if config.server_url_configured() {
+ // A URL derived from a custom `bind` counts: the jail's private home has
+ // no config, so without it the hooks inside would dial the default port.
+ if config.server_url_configured() || config.server_url_derived_from_bind {
env.push(("AI_MEMORY_SERVER_URL", config.server_url.clone()));
}
if let Some(token) = config
@@ -4722,6 +4724,20 @@ mod tests {
assert!(jail_forwarded_names(&Config::default(), &[]).is_empty());
}
+ /// A URL derived from a custom `bind` (#1269) is forwarded too.
+ #[test]
+ fn jail_resolved_env_carries_a_bind_derived_url() {
+ let config = Config {
+ server_url: "http://127.0.0.1:49921".into(),
+ server_url_derived_from_bind: true,
+ ..Config::default()
+ };
+ assert_eq!(
+ jail_resolved_env(&config),
+ [("AI_MEMORY_SERVER_URL", "http://127.0.0.1:49921".to_owned())]
+ );
+ }
+
#[test]
fn jail_resolved_env_is_empty_for_a_default_unauthenticated_install() {
let mut config = Config::default();