From 3620572207eb421fb40d91dfa36fac81e59322b9 Mon Sep 17 00:00:00 2001 From: Sihyeon Jang Date: Mon, 29 Dec 2025 15:10:04 +0900 Subject: [PATCH] fix: use minute-level granularity for MOIM timestamps Prevents agent infinite loop by using minute-level timestamps (:00) instead of second-level timestamps. This keeps conversation stable within a 1-minute window, preventing agents from repeatedly updating timestamp comments in files. Fixes the reported issue where agents would edit files every 5-7 seconds to update datetime comments like: # Datetime: 2025-12-29 09:06:51 # Datetime: 2025-12-29 09:06:58 (7s later) # Datetime: 2025-12-29 09:07:03 (5s later) ... continuing indefinitely Signed-off-by: Sihyeon Jang --- crates/goose/src/agents/extension_manager.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/agents/extension_manager.rs b/crates/goose/src/agents/extension_manager.rs index abee7d7a2443..0bc242e2f7d6 100644 --- a/crates/goose/src/agents/extension_manager.rs +++ b/crates/goose/src/agents/extension_manager.rs @@ -1268,7 +1268,8 @@ impl ExtensionManager { } pub async fn collect_moim(&self) -> Option { - let timestamp = chrono::Local::now().format("%Y-%m-%d %H:%M:%S").to_string(); + // Use minute-level granularity to prevent conversation changes every second + let timestamp = chrono::Local::now().format("%Y-%m-%d %H:%M:00").to_string(); let mut content = format!("\nIt is currently {}\n", timestamp); let platform_clients: Vec<(String, McpClientBox)> = { @@ -1779,4 +1780,17 @@ mod tests { ); assert_eq!(result, "Authorization: Bearer secret123 and API key456"); } + + #[tokio::test] + async fn test_collect_moim_uses_minute_granularity() { + let em = ExtensionManager::new_without_provider(); + + if let Some(moim) = em.collect_moim().await { + // Timestamp should end with :00 (seconds fixed to 00) + assert!( + moim.contains(":00\n"), + "Timestamp should use minute granularity" + ); + } + } }