From 539977dbfdefa1cf9eb95b77d4a29ebecf2071ff Mon Sep 17 00:00:00 2001 From: "alexyao2019@gmail.com" Date: Tue, 7 Oct 2025 12:25:00 +0000 Subject: [PATCH] Fix mcp large response race condition When multiple subagents are running in parallel and they call an mcp tool that returns a large response, these responses may all be returned at the exact same second which can result in subagents receiving paths containing the incorrect information. We fix this by adding microseconds to the filename so that this is very unlikely to occur anymore. Maybe a better solution is to check if the file exists, but I think this is sufficient for now. Signed-off-by: alexyao2015 --- crates/goose/src/agents/large_response_handler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/goose/src/agents/large_response_handler.rs b/crates/goose/src/agents/large_response_handler.rs index f0b9c176136b..f45dc01abcbd 100644 --- a/crates/goose/src/agents/large_response_handler.rs +++ b/crates/goose/src/agents/large_response_handler.rs @@ -64,7 +64,7 @@ fn write_large_text_to_file(content: &str) -> Result { std::fs::create_dir_all(&temp_dir)?; // Generate a unique filename with timestamp - let timestamp = Utc::now().format("%Y%m%d_%H%M%S"); + let timestamp = Utc::now().format("%Y%m%d_%H%M%S%.6f"); let filename = format!("mcp_response_{}.txt", timestamp); let file_path = temp_dir.join(&filename);