豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 8573650

Browse files
authored
feat(config): split memoryManager flag into autoMemory (#25601)
1 parent 220888a commit 8573650

File tree

16 files changed

+239
-12
lines changed

16 files changed

+239
-12
lines changed

docs/cli/auto-memory.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Auto Memory
2+
3+
Auto Memory is an experimental feature that mines your past Gemini CLI sessions
4+
in the background and turns recurring workflows into reusable
5+
[Agent Skills](./skills.md). You review, accept, or discard each extracted skill
6+
before it becomes available to future sessions.
7+
8+
<!-- prettier-ignore -->
9+
> [!NOTE]
10+
> This is an experimental feature currently under active development.
11+
12+
## Overview
13+
14+
Every session you run with Gemini CLI is recorded locally as a transcript. Auto
15+
Memory scans those transcripts for procedural patterns that recur across
16+
sessions, then drafts each pattern as a `SKILL.md` file in a project-local
17+
inbox. You inspect the draft, decide whether it captures real expertise, and
18+
promote it to your global or workspace skills directory if you want it.
19+
20+
You'll use Auto Memory when you want to:
21+
22+
- **Capture team workflows** that you find yourself walking the agent through
23+
more than once.
24+
- **Codify hard-won fixes** for project-specific landmines so future sessions
25+
avoid them.
26+
- **Bootstrap a skills library** without writing every `SKILL.md` by hand.
27+
28+
Auto Memory complements—but does not replace—the
29+
[`save_memory` tool](../tools/memory.md), which captures single facts into
30+
`GEMINI.md`. Auto Memory captures multi-step procedures into skills.
31+
32+
## Prerequisites
33+
34+
- Gemini CLI installed and authenticated.
35+
- At least 10 user messages across recent, idle sessions in the project. Auto
36+
Memory ignores active or trivial sessions.
37+
38+
## How to enable Auto Memory
39+
40+
Auto Memory is off by default. Enable it in your settings file:
41+
42+
1. Open your global settings file at `~/.gemini/settings.json`. If you only
43+
want Auto Memory in one project, edit `.gemini/settings.json` in that
44+
project instead.
45+
46+
2. Add the experimental flag:
47+
48+
```json
49+
{
50+
"experimental": {
51+
"autoMemory": true
52+
}
53+
}
54+
```
55+
56+
3. Restart Gemini CLI. The flag requires a restart because the extraction
57+
service starts during session boot.
58+
59+
## How Auto Memory works
60+
61+
Auto Memory runs as a background task on session startup. It does not block the
62+
UI, consume your interactive turns, or surface tool prompts.
63+
64+
1. **Eligibility scan.** The service indexes recent sessions from
65+
`~/.gemini/tmp/<project>/chats/`. Sessions are eligible only if they have
66+
been idle for at least three hours and contain at least 10 user messages.
67+
2. **Lock acquisition.** A lock file in the project's memory directory
68+
coordinates across multiple CLI instances so extraction runs at most once at
69+
a time.
70+
3. **Sub-agent extraction.** A specialized sub-agent (named `confucius`)
71+
reviews the session index, reads any sessions that look like they contain
72+
repeated procedural workflows, and drafts new `SKILL.md` files. Its
73+
instructions tell it to default to creating zero skills unless the evidence
74+
is strong, so most runs produce no inbox items.
75+
4. **Patch validation.** If the sub-agent proposes edits to skills outside the
76+
inbox (for example, an existing global skill), it writes a unified diff
77+
`.patch` file. Auto Memory dry-runs each patch and discards any that do not
78+
apply cleanly.
79+
5. **Notification.** When a run produces new skills or patches, Gemini CLI
80+
surfaces an inline message telling you how many items are waiting.
81+
82+
## How to review extracted skills
83+
84+
Use the `/memory inbox` slash command to open the inbox dialog at any time:
85+
86+
**Command:** `/memory inbox`
87+
88+
The dialog lists each draft skill with its name, description, and source
89+
sessions. From there you can:
90+
91+
- **Read** the full `SKILL.md` body before deciding.
92+
- **Promote** a skill to your user (`~/.gemini/skills/`) or workspace
93+
(`.gemini/skills/`) directory.
94+
- **Discard** a skill you do not want.
95+
- **Apply** or reject a `.patch` proposal against an existing skill.
96+
97+
Promoted skills become discoverable in the next session and follow the standard
98+
[skill discovery precedence](./skills.md#skill-discovery-tiers).
99+
100+
## How to disable Auto Memory
101+
102+
To turn off background extraction, set the flag back to `false` in your settings
103+
file and restart Gemini CLI:
104+
105+
```json
106+
{
107+
"experimental": {
108+
"autoMemory": false
109+
}
110+
}
111+
```
112+
113+
Disabling the flag stops the background service immediately on the next session
114+
start. Existing inbox items remain on disk; you can either drain them with
115+
`/memory inbox` first or remove the project memory directory manually.
116+
117+
## Data and privacy
118+
119+
- Auto Memory only reads session files that already exist locally on your
120+
machine. Nothing is uploaded to Gemini outside the normal API calls the
121+
extraction sub-agent makes during its run.
122+
- The sub-agent is instructed to redact secrets, tokens, and credentials it
123+
encounters and to never copy large tool outputs verbatim.
124+
- Drafted skills live in your project's memory directory until you promote or
125+
discard them. They are not automatically loaded into any session.
126+
127+
## Limitations
128+
129+
- The sub-agent runs on a preview Gemini Flash model. Extraction quality depends
130+
on the model's ability to recognize durable patterns versus one-off incidents.
131+
- Auto Memory does not extract skills from the current session. It only
132+
considers sessions that have been idle for three hours or more.
133+
- Inbox items are stored per project. Skills extracted in one workspace are not
134+
visible from another until you promote them to the user-scope skills
135+
directory.
136+
137+
## Next steps
138+
139+
- Learn how skills are discovered and activated in [Agent Skills](./skills.md).
140+
- Explore the [memory management tutorial](./tutorials/memory-management.md) for
141+
the complementary `save_memory` and `GEMINI.md` workflows.
142+
- Review the experimental settings catalog in
143+
[Settings](./settings.md#experimental).

docs/cli/settings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ they appear in the UI.
169169
| Model Steering | `experimental.modelSteering` | Enable model steering (user hints) to guide the model during tool execution. | `false` |
170170
| Direct Web Fetch | `experimental.directWebFetch` | Enable web fetch behavior that bypasses LLM summarization. | `false` |
171171
| Memory Manager Agent | `experimental.memoryManager` | Replace the built-in save_memory tool with a memory manager subagent that supports adding, removing, de-duplicating, and organizing memories. | `false` |
172+
| Auto Memory | `experimental.autoMemory` | Automatically extract reusable skills from past sessions in the background. Review results with /memory inbox. | `false` |
172173
| Use the generalist profile to manage agent contexts. | `experimental.generalistProfile` | Suitable for general coding and software development tasks. | `false` |
173174
| Enable Context Management | `experimental.contextManagement` | Enable logic for context management. | `false` |
174175

docs/cli/tutorials/memory-management.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,5 @@ immediately. Force a reload with:
124124
- Explore the [Command reference](../../reference/commands.md) for more
125125
`/memory` options.
126126
- Read the technical spec for [Project context](../../cli/gemini-md.md).
127+
- Try the experimental [Auto Memory](../auto-memory.md) feature to extract
128+
reusable skills from your past sessions automatically.

docs/reference/configuration.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,12 @@ their corresponding top-level category object in your `settings.json` file.
17291729
- **Default:** `false`
17301730
- **Requires restart:** Yes
17311731

1732+
- **`experimental.autoMemory`** (boolean):
1733+
- **Description:** Automatically extract reusable skills from past sessions in
1734+
the background. Review results with /memory inbox.
1735+
- **Default:** `false`
1736+
- **Requires restart:** Yes
1737+
17321738
- **`experimental.generalistProfile`** (boolean):
17331739
- **Description:** Suitable for general coding and software development tasks.
17341740
- **Default:** `false`

docs/sidebar.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@
9696
]
9797
},
9898
{ "label": "Agent Skills", "slug": "docs/cli/skills" },
99+
{
100+
"label": "Auto Memory",
101+
"badge": "🔬",
102+
"slug": "docs/cli/auto-memory"
103+
},
99104
{ "label": "Checkpointing", "slug": "docs/cli/checkpointing" },
100105
{ "label": "Headless mode", "slug": "docs/cli/headless" },
101106
{

evals/skill_extraction.eval.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ async function readSkillBodies(skillsDir: string): Promise<string[]> {
149149

150150
/**
151151
* Shared configOverrides for all skill extraction component evals.
152-
* - experimentalMemoryManager: enables the memory extraction pipeline.
152+
* - experimentalAutoMemory: enables the Auto Memory skill extraction pipeline.
153153
* - approvalMode: YOLO auto-approves tool calls (write_file, read_file) so the
154154
* background agent can execute without interactive confirmation.
155155
*/
156156
const EXTRACTION_CONFIG_OVERRIDES = {
157-
experimentalMemoryManager: true,
157+
experimentalAutoMemory: true,
158158
approvalMode: ApprovalMode.YOLO,
159159
};
160160

packages/cli/src/acp/commands/memory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ export class InboxMemoryCommand implements Command {
135135
context: CommandContext,
136136
_: string[],
137137
): Promise<CommandExecutionResponse> {
138-
if (!context.agentContext.config.isMemoryManagerEnabled()) {
138+
if (!context.agentContext.config.isAutoMemoryEnabled()) {
139139
return {
140140
name: this.name,
141-
data: 'The memory inbox requires the experimental memory manager. Enable it with: experimental.memoryManager = true in settings.',
141+
data: 'The memory inbox requires Auto Memory. Enable it with: experimental.autoMemory = true in settings.',
142142
};
143143
}
144144

packages/cli/src/config/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,7 @@ export async function loadCliConfig(
990990
disabledSkills: settings.skills?.disabled,
991991
experimentalJitContext: settings.experimental?.jitContext,
992992
experimentalMemoryManager: settings.experimental?.memoryManager,
993+
experimentalAutoMemory: settings.experimental?.autoMemory,
993994
contextManagement,
994995
modelSteering: settings.experimental?.modelSteering,
995996
topicUpdateNarration:

packages/cli/src/config/settingsSchema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,16 @@ const SETTINGS_SCHEMA = {
22132213
'Replace the built-in save_memory tool with a memory manager subagent that supports adding, removing, de-duplicating, and organizing memories.',
22142214
showInDialog: true,
22152215
},
2216+
autoMemory: {
2217+
type: 'boolean',
2218+
label: 'Auto Memory',
2219+
category: 'Experimental',
2220+
requiresRestart: true,
2221+
default: false,
2222+
description:
2223+
'Automatically extract reusable skills from past sessions in the background. Review results with /memory inbox.',
2224+
showInDialog: true,
2225+
},
22162226
generalistProfile: {
22172227
type: 'boolean',
22182228
label: 'Use the generalist profile to manage agent contexts.',

packages/cli/src/test-utils/mockConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const createMockConfig = (overrides: Partial<Config> = {}): Config =>
3939
fireSessionStartEvent: vi.fn().mockResolvedValue(undefined),
4040
})),
4141
isMemoryManagerEnabled: vi.fn(() => false),
42+
isAutoMemoryEnabled: vi.fn(() => false),
4243
getListExtensions: vi.fn(() => false),
4344
getExtensions: vi.fn(() => []),
4445
getListSessions: vi.fn(() => false),

0 commit comments

Comments
 (0)