Skip to content

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

Rust

fix(hooks): treat an exclamation mark as acknowledgment punctuation

Rudy Celekli763af289cf7f
diff --git a/crates/ai-memory-hooks/src/router.rs b/crates/ai-memory-hooks/src/router.rs
index 22a02fd1..b1fad4c3 100644
--- a/crates/ai-memory-hooks/src/router.rs
+++ b/crates/ai-memory-hooks/src/router.rs
@@ -4789,7 +4789,7 @@ fn is_acknowledgment(text: &str) -> bool {
}
let mut rest = trimmed;
loop {
- rest = rest.trim_start_matches([',', '.', ' ', ',', '。']);
+ rest = rest.trim_start_matches([',', '.', '!', ' ', ',', '。', '!']);
if rest.is_empty() {
return true;
}
@@ -20411,6 +20411,25 @@ pub(crate) mod tests {
assert!(!is_acknowledgment("what is the return type?"));
}
+ /// An exclamation mark is punctuation like a period: "thanks!" is the
+ /// same acknowledgment as "thanks.", not a prompt to continue from.
+ #[test]
+ fn is_acknowledgment_accepts_exclamation_marks() {
+ for ack in [
+ "thanks!",
+ "great!",
+ "ok, thanks!",
+ "perfect!!",
+ "好的!",
+ "谢谢!",
+ ] {
+ assert!(is_acknowledgment(ack), "{ack:?} is an acknowledgment");
+ }
+ for request in ["ok? now run it", "thanks! now run the tests"] {
+ assert!(!is_acknowledgment(request), "{request:?} is a request");
+ }
+ }
+
/// A compound acknowledgment is acknowledgment phrases and separators
/// only. The old check stripped every leading letter after a matching
/// prefix, so a short instruction that merely starts like an