Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(hooks): spool transient 4xx deliveries in the TypeScript integrations
Vinícius DS Andrade7c5cb70a9055
diff --git a/crates/ai-memory-cli/src/commands/install_hooks.rs b/crates/ai-memory-cli/src/commands/install_hooks.rsindex 87d2f12d..9a23682c 100644--- a/crates/ai-memory-cli/src/commands/install_hooks.rs+++ b/crates/ai-memory-cli/src/commands/install_hooks.rs@@ -4574,10 +4574,10 @@ fn add_hook_spooling(source: String) -> Result<String> {body: JSON.stringify(item.payload),signal: timeoutSignal(HOOK_REQUEST_TIMEOUT_MS),}).catch(() => undefined);- // Unreachable server or 5xx: keep the event on disk for a later- // drain (#580). 4xx is permanent - spooling it would retry a- // rejection forever.- if (!resp || resp.status >= 500) spoolFailedHook(item.url, item.payload);+ // Unreachable server, 5xx or a transient 4xx (408, 425, 429): keep the+ // event on disk for a later drain (#580). Any other 4xx is permanent -+ // spooling it would retry a rejection forever.+ if (!resp || hookStatusRetryable(resp.status)) spoolFailedHook(item.url, item.payload);} catch (_e) {try { spoolFailedHook(item.url, item.payload); } catch (_e2) {}}"#;@@ -9950,10 +9950,10 @@ model = "gpt-5"!source.contains("}).catch(() => undefined);\n } catch (_e) {"),"{name}: still fire-and-forgets failed deliveries");- // ...replaced by capture + spool of network failures and 5xx.+ // ...replaced by capture + spool of network failures, 5xx and transient 4xx.assert!(source.contains(- "if (!resp || resp.status >= 500) spoolFailedHook(item.url, item.payload);"+ "if (!resp || hookStatusRetryable(resp.status)) spoolFailedHook(item.url, item.payload);"),"{name}: missing spool-on-failure");diff --git a/crates/ai-memory-cli/src/commands/openclaw_plugin.rs b/crates/ai-memory-cli/src/commands/openclaw_plugin.rsindex d1dfd78c..e7256569 100644--- a/crates/ai-memory-cli/src/commands/openclaw_plugin.rs+++ b/crates/ai-memory-cli/src/commands/openclaw_plugin.rs@@ -381,9 +381,10 @@ function postPreCompact(event: any, ctx: any): void {{const policy = capturePolicy(body, typeof body.cwd === "string" ? body.cwd : undefined);if (policy.disposition === "drop") return;try {{- // Fire-and-forget, but never silent loss: an unreachable server or- // 5xx spools the event in the CLI hook-spool format for a later- // drain (#580); a delivered post opportunistically drains backlog.+ // Fire-and-forget, but never silent loss: an unreachable server, a+ // 5xx or a transient 4xx spools the event in the CLI hook-spool format+ // for a later drain (#580); a delivered post opportunistically drains+ // backlog.// Tracked in pendingHookRequests so session_end can await a bounded// flush instead of letting teardown kill the in-flight fetch (#676).const request = fetch(url, {{@@ -394,7 +395,7 @@ function postPreCompact(event: any, ctx: any): void {{}}).catch(() => undefined).then((resp) => {{- if (!resp || resp.status >= 500) spoolFailedHook(url, policy.payload);+ if (!resp || hookStatusRetryable(resp.status)) spoolFailedHook(url, policy.payload);else requestSpoolDrain();}}).catch(() => undefined);@@ -506,10 +507,9 @@ mod tests {let plugin = build_plugin("http://127.0.0.1:49374", Some("tok"), None, "denylist");assert!(plugin.contains("function spoolFailedHook("));assert!(plugin.contains("async function drainHookSpool()"));- assert!(- plugin- .contains("if (!resp || resp.status >= 500) spoolFailedHook(url, policy.payload);")- );+ assert!(plugin.contains(+ "if (!resp || hookStatusRetryable(resp.status)) spoolFailedHook(url, policy.payload);"+ ));assert!(plugin.contains("else requestSpoolDrain();"));crate::commands::render_shared::assert_shared_ts_delivery_runtime("openclaw", &plugin);assert!(plugin.contains(r#"return join(env, "hook-spool");"#));