From 74a18794a0441ca4c0b524eb632bf0c88768eb1d Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Sun, 11 Jan 2026 16:15:58 +0530 Subject: [PATCH] fix: load AGENTS.md and memory in agent mode Agent mode was only loading README.md but not AGENTS.md or project memory (.g3/memory.md). This meant agents were missing important context that normal mode had access to. Now agent mode uses the same read_agents_config(), read_project_readme(), and read_project_memory() functions as normal mode, combining all three into the agent context. --- crates/g3-cli/src/lib.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/crates/g3-cli/src/lib.rs b/crates/g3-cli/src/lib.rs index 841c05a..6f3ad90 100644 --- a/crates/g3-cli/src/lib.rs +++ b/crates/g3-cli/src/lib.rs @@ -797,11 +797,29 @@ async fn run_agent_mode( // Note: allow_multiple_tool_calls parameter is deprecated but kept for API compatibility let system_prompt = get_agent_system_prompt(&agent_prompt, true); - // Read README if present - let readme_content = std::fs::read_to_string(workspace_dir.join("README.md")).ok(); - let readme_for_prompt = readme_content.map(|content| { - format!("📚 Project README (from README.md):\n\n{}", content) - }); + // Load AGENTS.md, README, and memory - same as normal mode + let agents_content = read_agents_config(&workspace_dir); + let readme_content = read_project_readme(&workspace_dir); + let memory_content = read_project_memory(&workspace_dir); + + // Combine all content for the agent's context + let combined_content = { + let mut parts = Vec::new(); + if let Some(agents) = agents_content { + parts.push(agents); + } + if let Some(readme) = readme_content { + parts.push(readme); + } + if let Some(memory) = memory_content { + parts.push(memory); + } + if parts.is_empty() { + None + } else { + Some(parts.join("\n\n")) + } + }; // Create agent with custom system prompt let ui_writer = ConsoleUiWriter::new(); @@ -811,7 +829,7 @@ async fn run_agent_mode( config, ui_writer, system_prompt, - readme_for_prompt, + combined_content, ).await?; // Set agent mode for session tracking