进阶 zcode.z.ai 2026-11-25 14:51:22 · 0 阅读
第28章 Memory
Core FeaturesMemory
Memory gives ZCode Agent project-level long-term context. It can save development preferences, project conventions, and feedback for reuse in later sessions of the same project. Examples include your package manager, commit message format, and team review guidelines.
When enabled, ZCode reviews recent exchanges in the background after each conversation round completes successfully. It identifies information worth retaining, such as preferences, corrections to the Agent's approach, project goals and constraints, or external references you have shared. Saved memory is included in the context of later sessions in the same project.
You can also manage memory in conversation. For example, ask “Remember that this project uses pnpm for dependencies” to save a convention, or “Forget the package manager convention” to remove it.
Enable Memory
Open Settings → Memory and enable Workspace Memory.
Memory has its own settings page under Agent capabilities. When enabled, the page lists workspace memory files. You can select a workspace, search by file name, refresh the list, and use the open-with control beside a file to view it.
Before enabling Memory, note the following:
It applies to new sessions. Changes affect newly created sessions and sessions restored after restarting the app. Conversations already in progress retain their original setting.
It may increase token usage. Extracting and recalling memory can require additional model requests. Review consumption in Usage Stats.
What Gets Remembered
Memory focuses on four types of information:
TypeScopeExampleUserYour identity, expertise, and preferences“Use pnpm and Conventional Commits”FeedbackCorrections or confirmations about the Agent's approach“Do not fix lint errors in unrelated files”ProjectProject goals, constraints, and progress“The site must remain compatible with Node 20”ReferenceExternal resources you have shared“The design guidelines are in the team wiki”
Memory is intended for reusable information. It generally avoids duplicating code structure and Git history that can be read from the project, instructions already present in project instruction files, and temporary details relevant only to the current conversation.
How It Works
After a conversation round completes successfully, a background process reviews the recent exchange. When it identifies information worth retaining, it writes a short Markdown file and updates the MEMORY.md index. If no suitable information is found, no new memory is created. When a similar memory already exists, the existing file is updated instead of adding a duplicate; a memory that turns out to be wrong is deleted.
In later sessions of the same project, the index is loaded into the Agent's context automatically. Memory is scoped to each project: information saved in one workspace is not carried into another workspace.
This turnAlways use pnpm for dependencies in this projectTurn completedBackground extractionUserFeedbackProjectReferenceMemory folderMEMORY.mdIndex, one line eachpnpm-only.mdNew factNew session, same projectMEMORY.md loaded automaticallyUses pnpm as agreedWhere it appliesSame projectloaded in new sessionsOther projectsnever see it
Memory reflects things as they were when it was written. Before relying on a file, function, or setting named in a memory, ZCode Agent checks that it still exists.
Where Memories Are Stored
Memories are stored as Markdown files on your machine:
~/.zcode/cli/memories/projects//memory/Local only, never in GitMEMORY.mdIndex, one entry per line*.mdOne file per saved fact
MEMORY.md has one line per memory, pointing to its file:
- [pnpm only](pnpm-only.md) — use pnpm for all dependencies
Each memory is its own file. It starts with a name, a one-line description, and a type. Feedback and project memories usually also note why (Why) and how to apply it (How to apply):
---
name: pnpm-only
description: This project uses pnpm for all dependencies
metadata:
type: project
---
Install, upgrade, and remove dependencies with pnpm, never npm or yarn.
**Why:** Avoids multiple lockfiles.
**How to apply:** Write every dependency command with pnpm.
Memory files are stored locally. When extracting or using memory, relevant conversation and memory content may be sent as context to the model service you select. You can open, edit, or delete these files at any time. Deleting a project's memory directory resets its saved memory. Removing a project in project management with Also delete their ZCode data checked deletes its memory as well.
Limits and Notes
Review and cleanup: select a workspace in Settings → Memory to find its memory files. To change or remove an entry, ask the Agent in conversation—for example, “What do you remember about this project?” or “Forget…”—or edit the files on disk.
Remote workspaces are not supported: memory extraction currently runs for local projects only.
The memory file list appears only in the local desktop app: when a remote device is selected, the page shows “Memory details for remote devices are not available yet.”
The index has a size limit: when MEMORY.md exceeds 200 lines or about 25,000 characters, only the first part is loaded. Keep each index entry to one line under about 200 characters and put details in the memory file.
Independent of MCP memory servers: Memory is built into ZCode and requires no MCP configuration. Memory-related MCP tools operate independently.
Next Steps
ZCode AgentLearn about model selection, execution modes, and context management.Usage StatsReview token usage, including additional Memory requests.MCPLearn how to connect external capabilities through MCP.