diff --git a/src/apps/desktop/src/api/storage_commands.rs b/src/apps/desktop/src/api/storage_commands.rs index fa1277415..cfbdf77fa 100644 --- a/src/apps/desktop/src/api/storage_commands.rs +++ b/src/apps/desktop/src/api/storage_commands.rs @@ -55,7 +55,6 @@ pub async fn get_project_storage_paths( runtime_root: path_manager.project_runtime_root(&workspace_path), agents_dir: path_manager.project_agents_dir(&workspace_path), sessions_dir: path_manager.project_sessions_dir(&workspace_path), - memory_dir: path_manager.project_memory_dir(&workspace_path), plans_dir: path_manager.project_plans_dir(&workspace_path), }) } @@ -67,7 +66,6 @@ pub struct ProjectStoragePathsInfo { pub runtime_root: PathBuf, pub agents_dir: PathBuf, pub sessions_dir: PathBuf, - pub memory_dir: PathBuf, pub plans_dir: PathBuf, } diff --git a/src/crates/assembly/core/src/agentic/agents/definitions/modes/claw.rs b/src/crates/assembly/core/src/agentic/agents/definitions/modes/claw.rs index 3c3801f39..8f70c56fa 100644 --- a/src/crates/assembly/core/src/agentic/agents/definitions/modes/claw.rs +++ b/src/crates/assembly/core/src/agentic/agents/definitions/modes/claw.rs @@ -74,7 +74,6 @@ impl Agent for ClawMode { UserContextPolicy::empty() .with_workspace_context() .with_workspace_instructions() - .with_workspace_memory_files() } fn is_readonly(&self) -> bool { diff --git a/src/crates/assembly/core/src/agentic/agents/prompt_builder/prompt_builder_impl.rs b/src/crates/assembly/core/src/agentic/agents/prompt_builder/prompt_builder_impl.rs index c0a574589..fd6dcd14a 100644 --- a/src/crates/assembly/core/src/agentic/agents/prompt_builder/prompt_builder_impl.rs +++ b/src/crates/assembly/core/src/agentic/agents/prompt_builder/prompt_builder_impl.rs @@ -3,15 +3,12 @@ use crate::agentic::tools::implementations::ExecCommandTool; use crate::agentic::util::remote_workspace_layout::build_remote_workspace_layout_preview; use crate::agentic::workspace::WorkspaceBackend; use crate::agentic::WorkspaceBinding; -use crate::service::agent_memory::{ - build_workspace_agent_memory_prompt, build_workspace_instruction_files_context, - build_workspace_memory_files_context, -}; use crate::service::bootstrap::build_workspace_persona_prompt; use crate::service::config::get_app_language_code; use crate::service::config::global::GlobalConfigManager; use crate::service::filesystem::get_formatted_directory_listing; use crate::service::i18n::LocaleId; +use crate::service::instruction_context::build_workspace_instruction_files_context; use crate::service::remote_ssh::workspace_state::get_remote_workspace_manager; use crate::service::workspace::get_global_workspace_service; use crate::service::workspace::RelatedPath; @@ -29,7 +26,6 @@ use std::path::Path; /// Placeholder constants const PLACEHOLDER_PERSONA: &str = "{PERSONA}"; const PLACEHOLDER_LANGUAGE_PREFERENCE: &str = "{LANGUAGE_PREFERENCE}"; -const PLACEHOLDER_AGENT_MEMORY: &str = "{AGENT_MEMORY}"; const PLACEHOLDER_CLAW_WORKSPACE: &str = "{CLAW_WORKSPACE}"; const PLACEHOLDER_VISUAL_MODE: &str = "{VISUAL_MODE}"; const PLACEHOLDER_SESSION_ID: &str = "{SESSION_ID}"; @@ -328,17 +324,6 @@ impl PromptBuilder { ), } } - if policy.includes(UserContextSection::WorkspaceMemoryFiles) { - match build_workspace_memory_files_context(workspace).await { - Ok(Some(prompt)) => additional_sections.push(prompt), - Ok(None) => {} - Err(e) => warn!( - "Failed to build workspace memory context: path={} error={}", - workspace.display(), - e - ), - } - } } if policy.includes(UserContextSection::ProjectLayout) { @@ -424,7 +409,6 @@ Do not read from, modify, create, move, or delete files outside this workspace u /// Supported placeholders: /// - `{PERSONA}` - Workspace persona files (BOOTSTRAP.md, SOUL.md, USER.md, IDENTITY.md) /// - `{LANGUAGE_PREFERENCE}` - User language preference (read from global config) - /// - `{AGENT_MEMORY}` - Agent memory instructions + auto-loaded memory index /// - `{CLAW_WORKSPACE}` - Claw-specific workspace ownership and boundary rules /// - `{VISUAL_MODE}` - Visual mode instruction (Mermaid diagrams, read from global config) /// @@ -466,28 +450,6 @@ Do not read from, modify, create, move, or delete files outside this workspace u result = result.replace(PLACEHOLDER_CLAW_WORKSPACE, &claw_workspace); } - // Replace {AGENT_MEMORY} - if result.contains(PLACEHOLDER_AGENT_MEMORY) { - let agent_memory = if self.context.remote_execution.is_some() { - "# Agent memory\nSession memory under `.bitfun/` is stored on the **remote** host for this workspace. Use file tools with POSIX paths under the workspace root if you need to read it.\n\n" - .to_string() - } else { - let workspace = Path::new(&self.context.workspace_path); - match build_workspace_agent_memory_prompt(workspace).await { - Ok(prompt) => prompt, - Err(e) => { - warn!( - "Failed to build workspace agent memory prompt: path={} error={}", - workspace.display(), - e - ); - String::new() - } - } - }; - result = result.replace(PLACEHOLDER_AGENT_MEMORY, &agent_memory); - } - // Replace {VISUAL_MODE} if result.contains(PLACEHOLDER_VISUAL_MODE) { let visual_mode = self.get_visual_mode_instruction().await; diff --git a/src/crates/assembly/core/src/agentic/agents/prompts/claw_mode.md b/src/crates/assembly/core/src/agentic/agents/prompts/claw_mode.md index f3725d7b8..e25f05eda 100644 --- a/src/crates/assembly/core/src/agentic/agents/prompts/claw_mode.md +++ b/src/crates/assembly/core/src/agentic/agents/prompts/claw_mode.md @@ -65,4 +65,3 @@ Keep narration brief and value-dense. For multi-step work, state the near-term p {CLAW_WORKSPACE} {PERSONA} -{AGENT_MEMORY} diff --git a/src/crates/assembly/core/src/agentic/agents/registry/custom.rs b/src/crates/assembly/core/src/agentic/agents/registry/custom.rs index 414ab0198..97de6d35c 100644 --- a/src/crates/assembly/core/src/agentic/agents/registry/custom.rs +++ b/src/crates/assembly/core/src/agentic/agents/registry/custom.rs @@ -482,9 +482,6 @@ impl AgentRegistry { bitfun_agent_runtime::prompt::UserContextSection::WorkspaceInstructions => { "workspace_instructions" } - bitfun_agent_runtime::prompt::UserContextSection::WorkspaceMemoryFiles => { - "workspace_memory_files" - } bitfun_agent_runtime::prompt::UserContextSection::ProjectLayout => { "project_layout" } diff --git a/src/crates/assembly/core/src/agentic/agents/registry/tests.rs b/src/crates/assembly/core/src/agentic/agents/registry/tests.rs index 35e47b6f5..c6f5375c2 100644 --- a/src/crates/assembly/core/src/agentic/agents/registry/tests.rs +++ b/src/crates/assembly/core/src/agentic/agents/registry/tests.rs @@ -583,9 +583,7 @@ async fn explicit_custom_mode_load_exposes_user_mode_metadata_in_modes_info() { "PlannerPlus", "Planner Plus", vec!["Read".to_string(), "Grep".to_string()], - UserContextPolicy::empty() - .with_workspace_instructions() - .with_workspace_memory_files(), + UserContextPolicy::empty().with_workspace_instructions(), "primary", true, ); @@ -674,9 +672,7 @@ async fn custom_mode_detail_reports_kind_level_model_path_and_policy() { "PlannerPlus", "Planner Plus", vec!["Read".to_string(), "Grep".to_string()], - UserContextPolicy::empty() - .with_workspace_instructions() - .with_workspace_memory_files(), + UserContextPolicy::empty().with_workspace_instructions(), "primary", true, ); @@ -696,10 +692,7 @@ async fn custom_mode_detail_reports_kind_level_model_path_and_policy() { assert_eq!(detail.path, mode_path.to_string_lossy().to_string()); assert_eq!( detail.user_context_policy, - vec![ - "workspace_instructions".to_string(), - "workspace_memory_files".to_string(), - ] + vec!["workspace_instructions".to_string()] ); assert_eq!(detail.tools, vec!["Read".to_string(), "Grep".to_string()]); assert!(detail.readonly); @@ -778,8 +771,7 @@ async fn updating_custom_mode_definition_rewrites_file_and_preserves_mode_kind() None, Some( UserContextPolicy::empty() - .with_workspace_context() - .with_workspace_memory_files(), + .with_workspace_context(), ), Some("primary".to_string()), ) @@ -800,16 +792,12 @@ async fn updating_custom_mode_definition_rewrites_file_and_preserves_mode_kind() assert_eq!(detail.tools, vec!["Read".to_string(), "Grep".to_string()]); assert_eq!( detail.user_context_policy, - vec![ - "workspace_context".to_string(), - "workspace_memory_files".to_string(), - ] + vec!["workspace_context".to_string()] ); assert!(saved.contains("kind: mode")); assert!(saved.contains("name: Planner Pro")); assert!(saved.contains("model: primary")); assert!(saved.contains("- workspace_context")); - assert!(saved.contains("- workspace_memory_files")); } struct CustomAgentTestEnv { diff --git a/src/crates/assembly/core/src/agentic/session/session_manager.rs b/src/crates/assembly/core/src/agentic/session/session_manager.rs index ad5290425..772058ced 100644 --- a/src/crates/assembly/core/src/agentic/session/session_manager.rs +++ b/src/crates/assembly/core/src/agentic/session/session_manager.rs @@ -6063,7 +6063,7 @@ mod tests { .expect("session should be created"); let identity = SystemPromptCacheIdentity::new("template:agentic_mode"); let user_context_identity = UserContextCacheIdentity::new( - "workspace_context|workspace_instructions|workspace_memory_files|project_layout", + "workspace_context|workspace_instructions|project_layout", ); manager @@ -6278,7 +6278,7 @@ mod tests { .expect("session should be created"); let identity = SystemPromptCacheIdentity::new("template:agentic_mode"); let user_context_identity = UserContextCacheIdentity::new( - "workspace_context|workspace_instructions|workspace_memory_files|project_layout", + "workspace_context|workspace_instructions|project_layout", ); manager @@ -6358,7 +6358,7 @@ mod tests { .expect("target session should be created"); let identity = SystemPromptCacheIdentity::new("template:agentic_mode"); let user_context_identity = UserContextCacheIdentity::new( - "workspace_context|workspace_instructions|workspace_memory_files|project_layout", + "workspace_context|workspace_instructions|project_layout", ); manager @@ -6439,7 +6439,7 @@ mod tests { .expect("session should be created"); let identity = SystemPromptCacheIdentity::new("template:agentic_mode"); let user_context_identity = UserContextCacheIdentity::new( - "workspace_context|workspace_instructions|workspace_memory_files|project_layout", + "workspace_context|workspace_instructions|project_layout", ); manager diff --git a/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs b/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs index 45c7251f7..f9c2506cb 100644 --- a/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs +++ b/src/crates/assembly/core/src/infrastructure/app_paths/path_manager.rs @@ -386,11 +386,6 @@ impl PathManager { self.project_runtime_root(workspace_path).join("plans") } - /// Get project memory directory: ~/.bitfun/projects//memory/ - pub fn project_memory_dir(&self, workspace_path: &Path) -> PathBuf { - self.project_runtime_root(workspace_path).join("memory") - } - fn project_runtime_slug(&self, workspace_path: &Path) -> String { let requested_path = workspace_path.to_path_buf(); if let Some(slug) = self.cached_project_runtime_slug(&requested_path) { diff --git a/src/crates/assembly/core/src/service/agent_memory/auto_memory.rs b/src/crates/assembly/core/src/service/agent_memory/auto_memory.rs deleted file mode 100644 index cb9ed2dab..000000000 --- a/src/crates/assembly/core/src/service/agent_memory/auto_memory.rs +++ /dev/null @@ -1,317 +0,0 @@ -use crate::infrastructure::get_path_manager_arc; -use crate::util::errors::*; -use log::debug; -use std::path::{Path, PathBuf}; -use tokio::fs; - -const MEMORY_DIR_NAME: &str = "memory"; -const MEMORY_INDEX_FILE: &str = "memory.md"; -const MEMORY_INDEX_TEMPLATE: &str = "# Memory Index\n"; -const MEMORY_INDEX_MAX_LINES: usize = 200; -const TOPIC_MEMORY_MAX_FILES: usize = 30; - -fn memory_dir_path(workspace_root: &Path) -> PathBuf { - let path_manager = get_path_manager_arc(); - let path = path_manager.project_memory_dir(workspace_root); - debug!( - "Resolved workspace memory directory: workspace={} memory_dir={} storage_subdir={}", - workspace_root.display(), - path.display(), - MEMORY_DIR_NAME - ); - path -} - -fn format_path_for_prompt(path: &Path) -> String { - path.to_string_lossy().replace('\\', "/") -} - -async fn ensure_markdown_placeholder(path: &Path, content: &str) -> BitFunResult { - if path.exists() { - return Ok(false); - } - - fs::write(path, content) - .await - .map_err(|e| BitFunError::service(format!("Failed to create {}: {}", path.display(), e)))?; - - Ok(true) -} - -async fn list_memory_files(memory_dir: &Path) -> BitFunResult> { - let mut memory_files = Vec::new(); - let mut entries = fs::read_dir(memory_dir).await.map_err(|e| { - BitFunError::service(format!( - "Failed to read memory directory {}: {}", - memory_dir.display(), - e - )) - })?; - - while let Some(entry) = entries.next_entry().await.map_err(|e| { - BitFunError::service(format!( - "Failed to iterate memory directory {}: {}", - memory_dir.display(), - e - )) - })? { - let file_type = entry.file_type().await.map_err(|e| { - BitFunError::service(format!( - "Failed to inspect memory entry {}: {}", - entry.path().display(), - e - )) - })?; - if !file_type.is_file() { - continue; - } - - let file_name = entry.file_name().to_string_lossy().into_owned(); - if file_name.ends_with(".md") { - memory_files.push(file_name); - } - } - - memory_files.sort(); - - Ok(memory_files) -} - -pub(crate) async fn ensure_workspace_memory_files_for_prompt( - workspace_root: &Path, -) -> BitFunResult<()> { - let memory_dir = memory_dir_path(workspace_root); - if !memory_dir.exists() { - fs::create_dir_all(&memory_dir).await.map_err(|e| { - BitFunError::service(format!( - "Failed to create memory directory {}: {}", - memory_dir.display(), - e - )) - })?; - } - let created_memory_index = - ensure_markdown_placeholder(&memory_dir.join(MEMORY_INDEX_FILE), MEMORY_INDEX_TEMPLATE) - .await?; - - debug!( - "Ensured workspace agent memory files: path={}, created_memory_index={}", - workspace_root.display(), - created_memory_index - ); - - Ok(()) -} - -pub(crate) async fn build_workspace_agent_memory_prompt( - workspace_root: &Path, -) -> BitFunResult { - ensure_workspace_memory_files_for_prompt(workspace_root).await?; - - let memory_dir = memory_dir_path(workspace_root); - let memory_dir_display = format_path_for_prompt(&memory_dir); - - Ok(format!( - r#"# auto memory - -You have a persistent, file-based memory system at `{memory_dir_display}`. This directory already exists — write to it directly with the Write/Edit tool (do not run mkdir or check for its existence). - -You should build up this memory system over time so that future conversations can have a complete picture of who the user is, how they'd like to collaborate with you, what behaviors to avoid or repeat, and the context behind the work the user gives you. - -If the user explicitly asks you to remember something, save it immediately as whichever type fits best. If they ask you to forget something, find and remove the relevant entry. - -## Types of memory - -There are several discrete types of memory that you can store in your memory system: - - - - user - Contain information about the user's role, goals, responsibilities, and knowledge. Great user memories help you tailor your future behavior to the user's preferences and perspective. Your goal in reading and writing these memories is to build up an understanding of who the user is and how you can be most helpful to them specifically. For example, you should collaborate with a senior software engineer differently than a student who is coding for the very first time. Keep in mind, that the aim here is to be helpful to the user. Avoid writing memories about the user that could be viewed as a negative judgement or that are not relevant to the work you're trying to accomplish together. - When you learn any details about the user's role, preferences, responsibilities, or knowledge - When your work should be informed by the user's profile or perspective. For example, if the user is asking you to explain a part of the code, you should answer that question in a way that is tailored to the specific details that they will find most valuable or that helps them build their mental model in relation to domain knowledge they already have. - - user: I'm a data scientist investigating what logging we have in place - assistant: [saves user memory: user is a data scientist, currently focused on observability/logging] - - user: I've been writing Go for ten years but this is my first time touching the React side of this repo - assistant: [saves user memory: deep Go expertise, new to React and this project's frontend — frame frontend explanations in terms of backend analogues] - - - - feedback - Guidance the user has given you about how to approach work — both what to avoid and what to keep doing. These are a very important type of memory to read and write as they allow you to remain coherent and responsive to the way you should approach work in the project. Record from failure AND success: if you only save corrections, you will avoid past mistakes but drift away from approaches the user has already validated, and may grow overly cautious. - Any time the user corrects your approach ("no not that", "don't", "stop doing X") OR confirms a non-obvious approach worked ("yes exactly", "perfect, keep doing that", accepting an unusual choice without pushback). Corrections are easy to notice; confirmations are quieter — watch for them. In both cases, save what is applicable to future conversations, especially if surprising or not obvious from the code. Include *why* so you can judge edge cases later. - Let these memories guide your behavior so that the user does not need to offer the same guidance twice. - Lead with the rule itself, then a **Why:** line (the reason the user gave — often a past incident or strong preference) and a **How to apply:** line (when/where this guidance kicks in). Knowing *why* lets you judge edge cases instead of blindly following the rule. - - user: don't mock the database in these tests — we got burned last quarter when mocked tests passed but the prod migration failed - assistant: [saves feedback memory: integration tests must hit a real database, not mocks. Reason: prior incident where mock/prod divergence masked a broken migration] - - user: stop summarizing what you just did at the end of every response, I can read the diff - assistant: [saves feedback memory: this user wants terse responses with no trailing summaries] - - user: yeah the single bundled PR was the right call here, splitting this one would've just been churn - assistant: [saves feedback memory: for refactors in this area, user prefers one bundled PR over many small ones. Confirmed after I chose this approach — a validated judgment call, not a correction] - - - - project - Information that you learn about ongoing work, goals, initiatives, bugs, or incidents within the project that is not otherwise derivable from the code or git history. Project memories help you understand the broader context and motivation behind the work the user is doing within this working directory. - When you learn who is doing what, why, or by when. These states change relatively quickly so try to keep your understanding of this up to date. Always convert relative dates in user messages to absolute dates when saving (e.g., "Thursday" → "2026-03-05"), so the memory remains interpretable after time passes. - Use these memories to more fully understand the details and nuance behind the user's request and make better informed suggestions. - Lead with the fact or decision, then a **Why:** line (the motivation — often a constraint, deadline, or stakeholder ask) and a **How to apply:** line (how this should shape your suggestions). Project memories decay fast, so the why helps future-you judge whether the memory is still load-bearing. - - user: we're freezing all non-critical merges after Thursday — mobile team is cutting a release branch - assistant: [saves project memory: merge freeze begins 2026-03-05 for mobile release cut. Flag any non-critical PR work scheduled after that date] - - user: the reason we're ripping out the old auth middleware is that legal flagged it for storing session tokens in a way that doesn't meet the new compliance requirements - assistant: [saves project memory: auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup — scope decisions should favor compliance over ergonomics] - - - - reference - Stores pointers to where information can be found in external systems. These memories allow you to remember where to look to find up-to-date information outside of the project directory. - When you learn about resources in external systems and their purpose. For example, that bugs are tracked in a specific project in Linear or that feedback can be found in a specific Slack channel. - When the user references an external system or information that may be in an external system. - - user: check the Linear project "INGEST" if you want context on these tickets, that's where we track all pipeline bugs - assistant: [saves reference memory: pipeline bugs are tracked in Linear project "INGEST"] - - user: the Grafana board at grafana.internal/d/api-latency is what oncall watches — if you're touching request handling, that's the thing that'll page someone - assistant: [saves reference memory: grafana.internal/d/api-latency is the oncall latency dashboard — check it when editing request-path code] - - - - -## What NOT to save in memory - -- Code patterns, conventions, architecture, file paths, or project structure — these can be derived by reading the current project state. -- Git history, recent changes, or who-changed-what — `git log` / `git blame` are authoritative. -- Debugging solutions or fix recipes — the fix is in the code; the commit message has the context. -- Anything already documented in AGENTS.md files. -- Ephemeral task details: in-progress work, temporary state, current conversation context. - -These exclusions apply even when the user explicitly asks you to save. If they ask you to save a PR list or activity summary, ask what was *surprising* or *non-obvious* about it — that is the part worth keeping. - -## How to save memories - -Saving a memory is a two-step process: - -**Step 1** — write the memory to its own file (e.g., `user_role.md`, `feedback_testing.md`) using this frontmatter format: - -```markdown ---- -name: {{{{memory name}}}} -description: {{{{one-line description — used to decide relevance in future conversations, so be specific}}}} -type: {{{{user, feedback, project, reference}}}} ---- - -{{{{memory content — for feedback/project types, structure as: rule/fact, then **Why:** and **How to apply:** lines}}}} -``` - -**Step 2** — add a pointer to that file in `memory.md`. `memory.md` is an index, not a memory — each entry should be one line, under ~150 characters: `- [Title](file.md) — one-line hook`. It has no frontmatter. Never write memory content directly into `memory.md`. - -- `memory.md` is always loaded into your conversation context — lines after 200 will be truncated, so keep the index concise -- Keep the name, description, and type fields in memory files up-to-date with the content -- Organize memory semantically by topic, not chronologically -- Update or remove memories that turn out to be wrong or outdated -- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one. - -## When to access memories -- When memories seem relevant, or the user references prior-conversation work. -- You MUST access memory when the user explicitly asks you to check, recall, or remember. -- If the user says to *ignore* or *not use* memory: Do not apply remembered facts, cite, compare against, or mention memory content. -- Memory records can become stale over time. Use memory as context for what was true at a given point in time. Before answering the user or building assumptions based solely on information in memory records, verify that the memory is still correct and up-to-date by reading the current state of the files or resources. If a recalled memory conflicts with current information, trust what you observe now — and update or remove the stale memory rather than acting on it. - -## Before recommending from memory - -A memory that names a specific function, file, or flag is a claim that it existed *when the memory was written*. It may have been renamed, removed, or never merged. Before recommending it: - -- If the memory names a file path: check the file exists. -- If the memory names a function or flag: grep for it. -- If the user is about to act on your recommendation (not just asking about history), verify first. - -"The memory says X exists" is not the same as "X exists now." - -A memory that summarizes repo state (activity logs, architecture snapshots) is frozen in time. If the user asks about *recent* or *current* state, prefer `git log` or reading the code over recalling the snapshot. - -## Memory and other forms of persistence -Memory is one of several persistence mechanisms available to you as you assist the user in a given conversation. The distinction is often that memory can be recalled in future conversations and should not be used for persisting information that is only useful within the scope of the current conversation. -- When to use or update a plan instead of memory: If you are about to start a non-trivial implementation task and would like to reach alignment with the user on your approach you should use a Plan rather than saving this information to memory. Similarly, if you already have a plan within the conversation and you have changed your approach persist that change by updating the plan rather than saving a memory. -- When to use or update tasks instead of memory: When you need to break your work in current conversation into discrete steps or keep track of your progress use tasks instead of saving to memory. Tasks are great for persisting information about the work that needs to be done in the current conversation, but memory should be reserved for information that will be useful in future conversations. -"# - )) -} - -pub(crate) async fn build_workspace_memory_files_context( - workspace_root: &Path, -) -> BitFunResult> { - let memory_dir = memory_dir_path(workspace_root); - let memory_files_section = build_memory_space_files_section(&memory_dir).await?; - if memory_files_section.trim().is_empty() { - Ok(None) - } else { - Ok(Some(memory_files_section)) - } -} - -async fn build_memory_space_files_section(memory_dir: &Path) -> BitFunResult { - let index_path = memory_dir.join(MEMORY_INDEX_FILE); - let memory_dir_display = format_path_for_prompt(memory_dir); - let (index_content, index_description_suffix) = match fs::read_to_string(&index_path).await { - Ok(content) if !content.trim().is_empty() => { - let lines = content.lines().collect::>(); - let was_truncated = lines.len() > MEMORY_INDEX_MAX_LINES; - ( - lines - .into_iter() - .take(MEMORY_INDEX_MAX_LINES) - .collect::>() - .join("\n"), - if was_truncated { - format!(" Showing up to {MEMORY_INDEX_MAX_LINES} lines.") - } else { - String::new() - }, - ) - } - _ => (String::new(), String::new()), - }; - let index_body = if index_content.trim().is_empty() { - "(memory.md is empty)".to_string() - } else { - index_content - }; - - let memory_files = list_memory_files(memory_dir).await?; - - let topic_description_suffix = if memory_files.len() > TOPIC_MEMORY_MAX_FILES { - format!(" Showing up to {TOPIC_MEMORY_MAX_FILES} entries.") - } else { - String::new() - }; - let topic_files_content = if memory_files.is_empty() { - "(no topic memory files yet)".to_string() - } else { - memory_files - .into_iter() - .take(TOPIC_MEMORY_MAX_FILES) - .map(|file_name| format!("- `{}`", file_name)) - .collect::>() - .join("\n") - }; - - Ok(format!( - r#"## memory_files -Persistent memory files currently available in `{memory_dir_display}`. - -### memory.md -High-level index for the durable workspace memory space.{index_description_suffix} -{index_body} - -### topic_memory_files -Topic-oriented durable memory files available in this workspace.{topic_description_suffix} -{topic_files_content}"# - )) -} diff --git a/src/crates/assembly/core/src/service/agent_memory/mod.rs b/src/crates/assembly/core/src/service/agent_memory/mod.rs deleted file mode 100644 index 7e8b484c2..000000000 --- a/src/crates/assembly/core/src/service/agent_memory/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod auto_memory; -mod instruction_context; - -pub(crate) use auto_memory::build_workspace_agent_memory_prompt; -pub(crate) use auto_memory::build_workspace_memory_files_context; -pub(crate) use instruction_context::build_workspace_instruction_files_context; diff --git a/src/crates/assembly/core/src/service/agent_memory/instruction_context.rs b/src/crates/assembly/core/src/service/instruction_context.rs similarity index 100% rename from src/crates/assembly/core/src/service/agent_memory/instruction_context.rs rename to src/crates/assembly/core/src/service/instruction_context.rs diff --git a/src/crates/assembly/core/src/service/mod.rs b/src/crates/assembly/core/src/service/mod.rs index 55661e4c4..bac4920ff 100644 --- a/src/crates/assembly/core/src/service/mod.rs +++ b/src/crates/assembly/core/src/service/mod.rs @@ -4,8 +4,6 @@ //! isolated. High-coupling runtime services stay here until their port //! contracts and equivalence tests are explicit. -#[cfg(feature = "product-full")] -pub(crate) mod agent_memory; // Agent memory prompt helpers #[cfg(feature = "service-integrations")] pub mod announcement; // Announcement / feature-demo / tips system pub(crate) mod bootstrap; // Workspace persona bootstrap helpers @@ -16,6 +14,8 @@ pub mod filesystem; // FileSystem management #[cfg(feature = "service-integrations")] pub mod git; // Git service pub mod i18n; // I18n service +#[cfg(feature = "product-full")] +pub(crate) mod instruction_context; // Workspace instruction file prompt helpers pub mod lsp; // LSP (Language Server Protocol) system #[cfg(feature = "service-integrations")] pub mod mcp; // MCP (Model Context Protocol) system diff --git a/src/crates/assembly/core/src/service/workspace_runtime/service.rs b/src/crates/assembly/core/src/service/workspace_runtime/service.rs index db82dbad2..ec39debaa 100644 --- a/src/crates/assembly/core/src/service/workspace_runtime/service.rs +++ b/src/crates/assembly/core/src/service/workspace_runtime/service.rs @@ -295,11 +295,6 @@ impl WorkspaceRuntimeService { target: context.sessions_dir.clone(), strategy: RuntimeMigrationStrategy::MoveIfTargetMissing, }, - RuntimeMigrationSpec { - source: legacy_project_root.join("memory"), - target: context.memory_dir.clone(), - strategy: RuntimeMigrationStrategy::MoveIfTargetMissing, - }, RuntimeMigrationSpec { source: legacy_project_root.join("plans"), target: context.plans_dir.clone(), diff --git a/src/crates/assembly/core/src/service/workspace_runtime/types.rs b/src/crates/assembly/core/src/service/workspace_runtime/types.rs index b2c6fc2c4..88c946c40 100644 --- a/src/crates/assembly/core/src/service/workspace_runtime/types.rs +++ b/src/crates/assembly/core/src/service/workspace_runtime/types.rs @@ -34,7 +34,6 @@ pub struct WorkspaceRuntimeContext { pub snapshot_metadata_dir: PathBuf, pub snapshot_baselines_dir: PathBuf, pub snapshot_operations_dir: PathBuf, - pub memory_dir: PathBuf, pub plans_dir: PathBuf, pub locks_dir: PathBuf, pub config_dir: PathBuf, @@ -55,7 +54,6 @@ impl WorkspaceRuntimeContext { snapshot_metadata_dir: snapshots_dir.join("metadata"), snapshot_baselines_dir: snapshots_dir.join("baselines"), snapshot_operations_dir: snapshots_dir.join("operations"), - memory_dir: runtime_root.join("memory"), plans_dir: runtime_root.join("plans"), locks_dir: runtime_root.join("locks"), isolation_status_file: config_dir.join("isolation_status.json"), @@ -76,7 +74,6 @@ impl WorkspaceRuntimeContext { self.snapshot_metadata_dir.as_path(), self.snapshot_baselines_dir.as_path(), self.snapshot_operations_dir.as_path(), - self.memory_dir.as_path(), self.plans_dir.as_path(), self.locks_dir.as_path(), self.config_dir.as_path(), diff --git a/src/crates/execution/agent-runtime/src/agents.rs b/src/crates/execution/agent-runtime/src/agents.rs index eed4a17e4..8cdfffad6 100644 --- a/src/crates/execution/agent-runtime/src/agents.rs +++ b/src/crates/execution/agent-runtime/src/agents.rs @@ -51,7 +51,6 @@ pub fn shared_coding_mode_user_context_policy() -> UserContextPolicy { UserContextPolicy::empty() .with_workspace_context() .with_workspace_instructions() - .with_workspace_memory_files() .with_project_layout() } diff --git a/src/crates/execution/agent-runtime/src/custom_agent.rs b/src/crates/execution/agent-runtime/src/custom_agent.rs index 6d060d6ed..9cce2f91d 100644 --- a/src/crates/execution/agent-runtime/src/custom_agent.rs +++ b/src/crates/execution/agent-runtime/src/custom_agent.rs @@ -667,7 +667,6 @@ fn metadata_user_context_policy(metadata: &Value) -> Result UserContextSection::WorkspaceContext, "workspace_instructions" => UserContextSection::WorkspaceInstructions, - "workspace_memory_files" => UserContextSection::WorkspaceMemoryFiles, "project_layout" => UserContextSection::ProjectLayout, _ => { return Err(CustomAgentDefinitionError::InvalidUserContextPolicy @@ -753,9 +752,6 @@ fn custom_agent_markdown_metadata(definition: &CustomAgentDefinition) -> Value { UserContextSection::WorkspaceInstructions => { "workspace_instructions" } - UserContextSection::WorkspaceMemoryFiles => { - "workspace_memory_files" - } UserContextSection::ProjectLayout => "project_layout", } .to_string(), diff --git a/src/crates/execution/agent-runtime/src/prompt.rs b/src/crates/execution/agent-runtime/src/prompt.rs index df7e93148..cec0a5e80 100644 --- a/src/crates/execution/agent-runtime/src/prompt.rs +++ b/src/crates/execution/agent-runtime/src/prompt.rs @@ -450,7 +450,6 @@ fn computer_use_key_chord_guidance(host_os: &str) -> &'static str { pub enum UserContextSection { WorkspaceContext, WorkspaceInstructions, - WorkspaceMemoryFiles, ProjectLayout, } @@ -486,10 +485,6 @@ impl UserContextPolicy { self.with_section(UserContextSection::WorkspaceInstructions) } - pub fn with_workspace_memory_files(self) -> Self { - self.with_section(UserContextSection::WorkspaceMemoryFiles) - } - pub fn with_project_layout(self) -> Self { self.with_section(UserContextSection::ProjectLayout) } @@ -522,7 +517,6 @@ impl UserContextSection { match self { Self::WorkspaceContext => "workspace_context", Self::WorkspaceInstructions => "workspace_instructions", - Self::WorkspaceMemoryFiles => "workspace_memory_files", Self::ProjectLayout => "project_layout", } } diff --git a/src/crates/execution/agent-runtime/tests/agent_registry_contracts.rs b/src/crates/execution/agent-runtime/tests/agent_registry_contracts.rs index 5e3c426bc..3d4d803c8 100644 --- a/src/crates/execution/agent-runtime/tests/agent_registry_contracts.rs +++ b/src/crates/execution/agent-runtime/tests/agent_registry_contracts.rs @@ -162,7 +162,7 @@ fn mode_presentation_and_shared_context_policy_match_existing_mode_contract() { assert_eq!( shared_coding_mode_user_context_policy().cache_scope_key(), - "workspace_context|workspace_instructions|workspace_memory_files|project_layout" + "workspace_context|workspace_instructions|project_layout" ); } diff --git a/src/crates/execution/agent-runtime/tests/custom_agent_mode_contracts.rs b/src/crates/execution/agent-runtime/tests/custom_agent_mode_contracts.rs index 388dfac8c..77323e266 100644 --- a/src/crates/execution/agent-runtime/tests/custom_agent_mode_contracts.rs +++ b/src/crates/execution/agent-runtime/tests/custom_agent_mode_contracts.rs @@ -131,9 +131,7 @@ fn custom_mode_markdown_save_omits_default_fields() { fn custom_mode_markdown_save_round_trips_custom_policy_and_model() { let dir = TestTempDir::new("bitfun-runtime-custom-mode-custom"); let path = dir.join("planner.md"); - let policy = UserContextPolicy::empty() - .with_workspace_instructions() - .with_workspace_memory_files(); + let policy = UserContextPolicy::empty().with_workspace_instructions(); let definition = build_mode_definition( Some("PlannerPlus"), Some("PlannerPlus"), @@ -154,7 +152,6 @@ fn custom_mode_markdown_save_round_trips_custom_policy_and_model() { assert!(saved.contains("model: primary")); assert!(saved.contains("user_context_policy:")); assert!(saved.contains("- workspace_instructions")); - assert!(saved.contains("- workspace_memory_files")); assert!(saved.contains("- Read")); assert!(saved.contains("- Grep")); diff --git a/src/crates/execution/agent-runtime/tests/prompt_contracts.rs b/src/crates/execution/agent-runtime/tests/prompt_contracts.rs index 26f63a2d1..c50fbf1b7 100644 --- a/src/crates/execution/agent-runtime/tests/prompt_contracts.rs +++ b/src/crates/execution/agent-runtime/tests/prompt_contracts.rs @@ -13,20 +13,18 @@ fn user_context_policy_preserves_order_and_deduplicates_sections() { .with_workspace_instructions() .with_workspace_context() .with_project_layout() - .without_section(UserContextSection::ProjectLayout) - .with_workspace_memory_files(); + .without_section(UserContextSection::ProjectLayout); assert_eq!( policy.sections, vec![ UserContextSection::WorkspaceContext, UserContextSection::WorkspaceInstructions, - UserContextSection::WorkspaceMemoryFiles, ] ); assert_eq!( policy.cache_scope_key(), - "workspace_context|workspace_instructions|workspace_memory_files" + "workspace_context|workspace_instructions" ); } diff --git a/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx b/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx index 3ba61ce0d..81d4c90dc 100644 --- a/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx +++ b/src/web-ui/src/app/scenes/agents/components/CreateAgentPage.tsx @@ -293,13 +293,11 @@ const CreateAgentPage: React.FC = () => { const contextSectionLabels: Record = { workspace_context: t('agentsOverview.form.contextWorkspaceContext'), workspace_instructions: t('agentsOverview.form.contextWorkspaceInstructions'), - workspace_memory_files: t('agentsOverview.form.contextWorkspaceMemoryFiles'), project_layout: t('agentsOverview.form.contextProjectLayout'), }; const contextSectionTooltips: Record = { workspace_context: t('agentsOverview.form.contextWorkspaceContextTooltip'), workspace_instructions: t('agentsOverview.form.contextWorkspaceInstructionsTooltip'), - workspace_memory_files: t('agentsOverview.form.contextWorkspaceMemoryFilesTooltip'), project_layout: t('agentsOverview.form.contextProjectLayoutTooltip'), }; diff --git a/src/web-ui/src/infrastructure/api/service-api/CustomAgentAPI.ts b/src/web-ui/src/infrastructure/api/service-api/CustomAgentAPI.ts index 53d80fde2..585defab0 100644 --- a/src/web-ui/src/infrastructure/api/service-api/CustomAgentAPI.ts +++ b/src/web-ui/src/infrastructure/api/service-api/CustomAgentAPI.ts @@ -7,7 +7,6 @@ export type CustomAgentLevel = 'user' | 'project'; export type UserContextSection = | 'workspace_context' | 'workspace_instructions' - | 'workspace_memory_files' | 'project_layout'; export interface CustomAgentDetail { diff --git a/src/web-ui/src/locales/en-US/scenes/agents.json b/src/web-ui/src/locales/en-US/scenes/agents.json index c009a6853..ad00b223d 100644 --- a/src/web-ui/src/locales/en-US/scenes/agents.json +++ b/src/web-ui/src/locales/en-US/scenes/agents.json @@ -173,8 +173,6 @@ "contextWorkspaceContextTooltip": "Adds the current workspace identity and high-level session context, helping the agent understand where it is working.", "contextWorkspaceInstructions": "Workspace instructions", "contextWorkspaceInstructionsTooltip": "Adds project guidance such as AGENTS.md instructions, so the agent follows repository conventions and local rules.", - "contextWorkspaceMemoryFiles": "Workspace memory files", - "contextWorkspaceMemoryFilesTooltip": "Adds persisted workspace memory notes when available, helping the agent reuse long-lived project knowledge.", "contextProjectLayout": "Project layout", "contextProjectLayoutTooltip": "Adds a compact project structure summary, helping the agent choose relevant files and directories faster.", "noWorkspace": "Open a workspace first", diff --git a/src/web-ui/src/locales/zh-CN/scenes/agents.json b/src/web-ui/src/locales/zh-CN/scenes/agents.json index 800313d77..cbd575aed 100644 --- a/src/web-ui/src/locales/zh-CN/scenes/agents.json +++ b/src/web-ui/src/locales/zh-CN/scenes/agents.json @@ -173,8 +173,6 @@ "contextWorkspaceContextTooltip": "加入当前工作区身份和会话级概况,帮助 Agent 知道自己正在处理哪个项目。", "contextWorkspaceInstructions": "工作区说明", "contextWorkspaceInstructionsTooltip": "加入 AGENTS.md 等项目指导,让 Agent 遵循仓库约定和本地规则。", - "contextWorkspaceMemoryFiles": "工作区记忆文件", - "contextWorkspaceMemoryFilesTooltip": "在可用时加入持久化的工作区记忆,帮助 Agent 复用长期项目知识。", "contextProjectLayout": "项目结构", "contextProjectLayoutTooltip": "加入精简的项目结构摘要,帮助 Agent 更快判断相关文件和目录。", "noWorkspace": "需要先打开项目", diff --git a/src/web-ui/src/locales/zh-TW/scenes/agents.json b/src/web-ui/src/locales/zh-TW/scenes/agents.json index f0ac4535e..a1c1118bc 100644 --- a/src/web-ui/src/locales/zh-TW/scenes/agents.json +++ b/src/web-ui/src/locales/zh-TW/scenes/agents.json @@ -168,8 +168,6 @@ "contextWorkspaceContextTooltip": "加入目前工作區身分和會話級概況,幫助 Agent 知道自己正在處理哪個專案。", "contextWorkspaceInstructions": "工作區說明", "contextWorkspaceInstructionsTooltip": "加入 AGENTS.md 等專案指引,讓 Agent 遵循倉庫約定和本地規則。", - "contextWorkspaceMemoryFiles": "工作區記憶檔案", - "contextWorkspaceMemoryFilesTooltip": "在可用時加入持久化的工作區記憶,幫助 Agent 重用長期專案知識。", "contextProjectLayout": "專案結構", "contextProjectLayoutTooltip": "加入精簡的專案結構摘要,幫助 Agent 更快判斷相關檔案和目錄。", "noWorkspace": "需要先開啟項目",