Agent Zero AI framework
Detach memory and update config
Alessandro505128c384c8
diff --git a/agent.py b/agent.pyindex 58a4531f5..0633005ea 100644--- a/agent.py+++ b/agent.py@@ -303,7 +303,6 @@ class AgentConfig:browser_model: models.ModelConfigmcp_servers: strprofile: str = ""- memory_subdir: str = ""knowledge_subdirs: list[str] = field(default_factory=lambda: ["default", "custom"])browser_http_headers: dict[str, str] = field(default_factory=dictdiff --git a/initialize.py b/initialize.pyindex 7dd85b7f5..9b48a2684 100644--- a/initialize.py+++ b/initialize.py@@ -78,7 +78,6 @@ def initialize_agent(override_settings: dict | None = None):embeddings_model=embedding_llm,browser_model=browser_llm,profile=current_settings["agent_profile"],- memory_subdir=current_settings["agent_memory_subdir"],knowledge_subdirs=[current_settings["agent_knowledge_subdir"], "default"],mcp_servers=current_settings["mcp_servers"],browser_http_headers=current_settings["browser_http_headers"],diff --git a/plugins/memory/config.default.json b/plugins/memory/config.default.jsonindex 71c2025cc..5df46feb1 100644--- a/plugins/memory/config.default.json+++ b/plugins/memory/config.default.json@@ -13,5 +13,5 @@"memory_memorize_enabled": true,"memory_memorize_consolidation": true,"memory_memorize_replace_threshold": 0.9,- "agent_memory_subdir": "default"+ "agent_memory_subdir": ""}diff --git a/plugins/memory/config.json b/plugins/memory/config.jsonnew file mode 100644index 000000000..13cc223b9--- /dev/null+++ b/plugins/memory/config.json@@ -0,0 +1,18 @@+{+ "project_memory_isolation": true,+ "memory_recall_enabled": true,+ "memory_recall_delayed": false,+ "memory_recall_interval": 3,+ "memory_recall_history_len": 10000,+ "memory_recall_memories_max_search": 12,+ "memory_recall_solutions_max_search": 8,+ "memory_recall_memories_max_result": 5,+ "memory_recall_solutions_max_result": 3,+ "memory_recall_similarity_threshold": 0.7,+ "memory_recall_query_prep": false,+ "memory_recall_post_filter": false,+ "memory_memorize_enabled": true,+ "memory_memorize_consolidation": true,+ "memory_memorize_replace_threshold": 0.9,+ "agent_memory_subdir": "default"+}diff --git a/plugins/memory/helpers/memory.py b/plugins/memory/helpers/memory.pyindex c73ec538c..4744c3ab7 100644--- a/plugins/memory/helpers/memory.py+++ b/plugins/memory/helpers/memory.py@@ -23,7 +23,7 @@ import os, jsonimport numpy as npfrom python.helpers.print_style import PrintStyle-from python.helpers import files, plugins+from python.helpers import files, plugins, projectsfrom langchain_core.documents import Documentfrom . import knowledge_importfrom python.helpers.log import Log, LogItem@@ -520,17 +520,16 @@ def get_agent_memory_subdir(agent: Agent) -> str:def get_context_memory_subdir(context: AgentContext) -> str:- # if project is active, use project memory subdir- from python.helpers.projects import (- get_context_memory_subdir as get_project_memory_subdir,- )-- memory_subdir = get_project_memory_subdir(context)- if memory_subdir:- return memory_subdir-- # no project, regular memory subdir- return plugins.get_plugin_config("memory").get("agent_memory_subdir", "default")+ config = plugins.get_plugin_config("memory")++ # Check if project isolation is enabled and we are in a project+ if config.get("project_memory_isolation", True):+ project_name = projects.get_context_project_name(context)+ if project_name:+ return "projects/" + project_name++ # Fallback to configured subdir or default+ return config.get("agent_memory_subdir", "") or "default"def get_existing_memory_subdirs() -> list[str]:diff --git a/plugins/memory/webui/config.html b/plugins/memory/webui/config.htmlindex af05f3cce..2d6b92cf9 100644--- a/plugins/memory/webui/config.html+++ b/plugins/memory/webui/config.html@@ -13,16 +13,30 @@context awareness.</div>+ <div class="field" x-show="$store.pluginSettings.projectName">+ <div class="field-label">+ <div class="field-title">Project Isolation</div>+ <div class="field-description">+ If enabled, this project uses its own memory folder (projects/NAME). If disabled, it shares the global memory (default or custom subdir).+ </div>+ </div>+ <div class="field-control">+ <label class="toggle">+ <input type="checkbox" x-model="$store.pluginSettings.settings.project_memory_isolation" />+ <span class="toggler"></span>+ </label>+ </div>+ </div>+<div class="field"><div class="field-label"><div class="field-title">Memory Subdirectory</div><div class="field-description">- Subdirectory of /memory folder to use for agent memory storage. Used to separate memory- storage between different instances.+ Subdirectory of /memory folder.</div></div><div class="field-control">- <input type="text" x-model="$store.pluginSettings.settings.agent_memory_subdir" />+ <input type="text" x-model="$store.pluginSettings.settings.agent_memory_subdir" placeholder="Auto (Project-isolated)" /></div></div>diff --git a/python/extensions/agent_init/_15_load_profile_settings.py b/python/extensions/agent_init/_15_load_profile_settings.pyindex e3572a008..2b87f93d7 100644--- a/python/extensions/agent_init/_15_load_profile_settings.py+++ b/python/extensions/agent_init/_15_load_profile_settings.py@@ -38,7 +38,6 @@ class LoadProfileSettings(Extension):for override_key, config_attr in (("agent_profile", "profile"),- ("agent_memory_subdir", "memory_subdir"),("mcp_servers", "mcp_servers"),("browser_http_headers", "browser_http_headers"),):diff --git a/python/helpers/projects.py b/python/helpers/projects.pyindex d40a7ab2f..19031807a 100644--- a/python/helpers/projects.py+++ b/python/helpers/projects.py@@ -34,9 +34,6 @@ class BasicProjectData(TypedDict):instructions: strcolor: strgit_url: str- memory: Literal[- "own", "global"- ] # in the future we can add cutom and point to another existing folderfile_structure: FileStructureInjectionSettingsclass GitStatusData(TypedDict, total=False):@@ -158,7 +155,6 @@ def _normalizeBasicData(data: BasicProjectData) -> BasicProjectData:"instructions": data.get("instructions", ""),"color": data.get("color", ""),"git_url": data.get("git_url", ""),- "memory": data.get("memory", "own"),"file_structure": data.get("file_structure",_default_file_structure_settings(),@@ -179,7 +175,6 @@ def _normalizeEditData(data: EditProjectData) -> EditProjectData:"instruction_files_count": data.get("instruction_files_count", 0),"knowledge_files_count": data.get("knowledge_files_count", 0),"secrets": data.get("secrets", ""),- "memory": data.get("memory", "own"),"file_structure": data.get("file_structure",_default_file_structure_settings(),@@ -463,16 +458,6 @@ def save_project_secrets(name: str, secrets: str):secrets_manager.save_secrets_with_merge(secrets)-def get_context_memory_subdir(context: "AgentContext") -> str | None:- # if a project is active and has memory isolation set, return the project memory subdir- project_name = get_context_project_name(context)- if project_name:- project_data = load_basic_project_data(project_name)- if project_data["memory"] == "own":- return "projects/" + project_name- return None # no memory override--def create_project_meta_folders(name: str):# create instructions folderfiles.create_dir(get_project_meta(name, PROJECT_INSTRUCTIONS_DIR))diff --git a/python/helpers/settings.py b/python/helpers/settings.pyindex 2f5944c8b..b7f1fb5f9 100644--- a/python/helpers/settings.py+++ b/python/helpers/settings.py@@ -92,7 +92,6 @@ class Settings(TypedDict):browser_http_headers: dict[str, Any]agent_profile: str- agent_memory_subdir: stragent_knowledge_subdir: strworkdir_path: str@@ -103,21 +102,6 @@ class Settings(TypedDict):workdir_max_lines: intworkdir_gitignore: str- memory_recall_enabled: bool- memory_recall_delayed: bool- memory_recall_interval: int- memory_recall_history_len: int- memory_recall_memories_max_search: int- memory_recall_solutions_max_search: int- memory_recall_memories_max_result: int- memory_recall_solutions_max_result: int- memory_recall_similarity_threshold: float- memory_recall_query_prep: bool- memory_recall_post_filter: bool- memory_memorize_enabled: bool- memory_memorize_consolidation: bool- memory_memorize_replace_threshold: float-api_keys: dict[str, str]auth_login: str@@ -547,26 +531,11 @@ def get_default_settings() -> Settings:browser_model_rl_output=get_default_value("browser_model_rl_output", 0),browser_model_kwargs=get_default_value("browser_model_kwargs", {}),browser_http_headers=get_default_value("browser_http_headers", {}),- memory_recall_enabled=get_default_value("memory_recall_enabled", True),- memory_recall_delayed=get_default_value("memory_recall_delayed", False),- memory_recall_interval=get_default_value("memory_recall_interval", 3),- memory_recall_history_len=get_default_value("memory_recall_history_len", 10000),- memory_recall_memories_max_search=get_default_value("memory_recall_memories_max_search", 12),- memory_recall_solutions_max_search=get_default_value("memory_recall_solutions_max_search", 8),- memory_recall_memories_max_result=get_default_value("memory_recall_memories_max_result", 5),- memory_recall_solutions_max_result=get_default_value("memory_recall_solutions_max_result", 3),- memory_recall_similarity_threshold=get_default_value("memory_recall_similarity_threshold", 0.7),- memory_recall_query_prep=get_default_value("memory_recall_query_prep", False),- memory_recall_post_filter=get_default_value("memory_recall_post_filter", False),- memory_memorize_enabled=get_default_value("memory_memorize_enabled", True),- memory_memorize_consolidation=get_default_value("memory_memorize_consolidation", True),- memory_memorize_replace_threshold=get_default_value("memory_memorize_replace_threshold", 0.9),api_keys={},auth_login="",auth_password="",root_password="",agent_profile=get_default_value("agent_profile", "agent0"),- agent_memory_subdir=get_default_value("agent_memory_subdir", "default"),agent_knowledge_subdir=get_default_value("agent_knowledge_subdir", "custom"),workdir_path=get_default_value("workdir_path", files.get_abs_path_dockerized("usr/workdir")),workdir_show=get_default_value("workdir_show", True),diff --git a/webui/components/plugins/list/pluginListStore.js b/webui/components/plugins/list/pluginListStore.jsindex 18a7cc269..62558a20e 100644--- a/webui/components/plugins/list/pluginListStore.js+++ b/webui/components/plugins/list/pluginListStore.js@@ -14,6 +14,7 @@ const model = {activeTab: "custom",async init() {+ this.loading = false;await this.setTab('custom');if (this.plugins.length === 0) {await this.setTab('builtin');diff --git a/webui/components/plugins/plugin-settings-store.js b/webui/components/plugins/plugin-settings-store.jsindex a055aea2f..6aa1e1c1b 100644--- a/webui/components/plugins/plugin-settings-store.js+++ b/webui/components/plugins/plugin-settings-store.js@@ -301,6 +301,11 @@ const model = {this.loadedProjectName = "";this.loadedAgentProfile = "";this.error = null;+ this.isLoading = false;+ this.isSaving = false;+ this.isListingConfigs = false;+ this.configsError = null;+ this.configs = [];},// Reactive URL for the plugin's settings component (used with x-html injection)diff --git a/webui/components/projects/project-edit-memory.html b/webui/components/projects/project-edit-memory.htmldeleted file mode 100644index 6a58b7d46..000000000--- a/webui/components/projects/project-edit-memory.html+++ /dev/null@@ -1,81 +0,0 @@-<html>--<head>- <title>Create a new project</title>- <script type="module">- import { store } from "/components/projects/projects-store.js";- </script>-</head>--<body>- <div x-data>- <template x-if="$store.projects && $store.projects.selectedProject">- <div>-- <div class="projects-setting-row" style="padding: 1rem 0;">- <div class="projects-setting-text">- <label class="projects-form-label">Project-specific memory</label>- <span class="projects-form-description">When turned on, the agent's memory while working on this- project will be isolated from the global memory. The memory will be stored in <strong><span- x-text="$store.projects.getSelectedAbsPath('.a0proj','memory')"></span></strong>.- <br>- Project-specific knowledge files can be used only when project-specific memory is turned on.</span>- </div>- <div class="projects-setting-control">- <label class="toggle">- <input type="checkbox" x-model="$store.projects.selectedProject._ownMemory">- <span class="toggler"></span>- </label>- </div>- </div>-- <div class="projects-form-group" x-show="$store.projects.selectedProject._ownMemory">- <label class="projects-form-label">Knowledge files</label>- <div class="projects-input-with-button-wrapper">- <span class="projects-form-description">Additional knowledge files in <strong><span- x-text="$store.projects.getSelectedAbsPath('.a0proj','knowledge')"></span></strong>.- Knowledge files are imported into memory and are used when relevant based on the context of the conversation.</span>- <span class="projects-form-description">Currently there are <strong><span- x-text="$store.projects.selectedProject.knowledge_files_count || 0"></span></strong>- knowledge files.</span>- <button class="button icon-button" x-on:click="$store.projects.browseKnowledgeFiles()">- <span class="icon material-symbols-outlined">folder</span>- <span>Browse</span>- </button>- </div>- </div>-- <style>- .projects-setting-row {- display: flex;- align-items: center;- justify-content: space-between;- gap: 2rem;- }-- .projects-setting-text {- flex-grow: 1;- flex-shrink: 1;- min-width: 0;- }-- .projects-setting-control {- flex-grow: 0;- flex-shrink: 0;- }-- .projects-form-label {- display: block;- }- </style>-- </div>--- </template>- </div>-</body>-<style>-</style>--</html>\ No newline at end of filediff --git a/webui/components/projects/project-edit.html b/webui/components/projects/project-edit.htmlindex e67153fa3..0c18d2da1 100644--- a/webui/components/projects/project-edit.html+++ b/webui/components/projects/project-edit.html@@ -42,14 +42,6 @@</x-component></div>- <div class="project-detail">- <div class="project-detail-header">- <span class="projects-project-card-title">Memory</span>- </div>- <x-component path="projects/project-edit-memory.html">- </x-component>- </div>-<div class="project-detail"><div class="project-detail-header"><span class="projects-project-card-title">File structure</span>diff --git a/webui/components/projects/projects-store.js b/webui/components/projects/projects-store.jsindex 88188da2d..a13f5a2c3 100644--- a/webui/components/projects/projects-store.js+++ b/webui/components/projects/projects-store.js@@ -297,7 +297,7 @@ const model = {const response = await api.callJsonApi("projects", {action: "delete",name: name,- });+ });if (response.ok) {notifications.toastFrontendSuccess("Project deleted successfully",@@ -350,7 +350,6 @@ const model = {// prepare dataconst data = {...this.selectedProject,- memory: this.selectedProject._ownMemory ? "own" : "global",};// remove internal fieldsfor (const kvp of Object.entries(data))@@ -402,7 +401,6 @@ const model = {_meta: {creating: true,},- _ownMemory: true,_cloning: false,name: ``,title: `Project #${this.projectList.length + 1}`,@@ -425,7 +423,6 @@ const model = {creating: false,},...projectData,- _ownMemory: projectData.memory == "own",};},