You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/memoryops.md
+30-87Lines changed: 30 additions & 87 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,21 +12,7 @@ Use MemoryOps for incremental processing, trend analysis, multi-step tasks, and
12
12
## How to Use These Patterns
13
13
14
14
> [!TIP]
15
-
> **Let the AI Agent Do the Work**
16
-
>
17
-
> When using these patterns, **state your high-level goal** in the workflow prompt and let the AI agent generate the concrete implementation. The patterns below are conceptual guides - you don't need to write the detailed code yourself.
18
-
>
19
-
> **Example approach:**
20
-
>
21
-
> ```markdown
22
-
> # Process All Open Issues
23
-
>
24
-
> Analyze all open issues in the repository. Use cache-memory to track which
25
-
> issues you've already processed so you can resume if interrupted. For each
26
-
> issue, extract sentiment and priority, then generate a summary report.
27
-
> ```
28
-
>
29
-
> The agent will see the cache-memory configuration in your frontmatter and implement the todo/done tracking pattern automatically based on your goal.
15
+
> State your high-level goal in the workflow prompt and let the AI agent handle the implementation. The examples below are prompts you'd write — the agent generates the code automatically based on your memory configuration.
30
16
31
17
## Memory Types
32
18
@@ -61,18 +47,14 @@ tools:
61
47
62
48
Track progress through large datasets with todo/done lists to ensure complete coverage across multiple runs.
63
49
64
-
**Your goal**: "Process all items in a collection, tracking which ones are done so I can resume if interrupted."
65
-
66
-
**How to state it in your workflow**:
67
50
```markdown
68
-
Analyze all open issues in the repository. Track your progress in cache-memory
69
-
so you can resume if the workflow times out. Mark each issue as done after
51
+
Analyze all open issues in the repository. Track your progress in cache-memory
52
+
so you can resume if the workflow times out. Mark each issue as done after
70
53
processing it. Generate a final report with statistics.
71
54
```
72
55
73
-
**What the agent will implement**: Maintain a state file with items to process (`todo`) and completed items (`done`). After processing each item, immediately update the state so the workflow can resume if interrupted.
56
+
The agent maintains a state file with items to process and completed items, updating it after each itemso the workflow can resume if interrupted:
74
57
75
-
**Example structure the agent might use**:
76
58
```json
77
59
{
78
60
"todo": [123, 456, 789],
@@ -82,24 +64,20 @@ processing it. Generate a final report with statistics.
Real examples: `.github/workflows/repository-quality-improver.md`, `.github/workflows/copilot-agent-analysis.md`
86
68
87
69
## Pattern 2: State Persistence
88
70
89
71
Save workflow checkpoints to resume long-running tasks that may timeout.
90
72
91
-
**Your goal**: "Process data in batches, saving progress so I can continue where I left off in the next run."
92
-
93
-
**How to state it in your workflow**:
94
73
```markdown
95
-
Migrate 10,000 records from the old format to the new format. Process 500
96
-
records per run and save a checkpoint. Each run should resume from the last
74
+
Migrate 10,000 records from the old format to the new format. Process 500
75
+
records per run and save a checkpoint. Each run should resume from the last
97
76
checkpoint until all records are migrated.
98
77
```
99
78
100
-
**What the agent will implement**: Store a checkpoint with the last processed position. Each run loads the checkpoint, processes a batch, then saves the new position.
79
+
The agent stores a checkpoint with the last processed position and resumes from it each run:
101
80
102
-
**Example checkpoint the agent might use**:
103
81
```json
104
82
{
105
83
"last_processed_id": 1250,
@@ -109,109 +87,80 @@ checkpoint until all records are migrated.
Real examples: `.github/workflows/daily-news.md`, `.github/workflows/cli-consistency-checker.md`
113
91
114
92
## Pattern 3: Shared Information
115
93
116
-
Share data between workflows using repo-memory branches.
117
-
118
-
**Your goal**: "Collect data in one workflow and analyze it in other workflows."
119
-
120
-
**How to state it in your workflow**:
94
+
Share data between workflows using repo-memory branches. A producer workflow stores data; consumers read it using the same branch name.
121
95
122
96
*Producer workflow:*
123
97
```markdown
124
-
Every 6 hours, collect repository metrics (issues, PRs, stars) and store them
98
+
Every 6 hours, collect repository metrics (issues, PRs, stars) and store them
125
99
in repo-memory so other workflows can analyze the data later.
126
100
```
127
101
128
102
*Consumer workflow:*
129
103
```markdown
130
-
Load the historical metrics from repo-memory and compute weekly trends.
104
+
Load the historical metrics from repo-memory and compute weekly trends.
131
105
Generate a trend report with visualizations.
132
106
```
133
107
134
-
**What the agent will implement**: One workflow (producer) collects data and stores it in repo-memory. Other workflows (consumers) read and analyze the shared data using the same branch name.
108
+
Both workflows reference the same branch:
135
109
136
-
**Configuration both workflows need**:
137
110
```yaml
138
111
tools:
139
112
repo-memory:
140
-
branch-name: memory/shared-data # Same branch for producer and consumer
Real examples: `.github/workflows/metrics-collector.md`(producer), trend analysis workflows (consumers)
144
117
145
118
## Pattern 4: Data Caching
146
119
147
-
Cache API responses to avoid rate limits and reduce workflow time.
148
-
149
-
**Your goal**: "Avoid hitting rate limits by caching API responses that don't change frequently."
120
+
Cache API responses to avoid rate limits and reduce workflow time. The agent checks for fresh cached data before making API calls, using suggested TTLs: repository metadata (24h), contributor lists (12h), issues/PRs (1h), workflow runs (30m).
150
121
151
-
**How to state it in your workflow**:
152
122
```markdown
153
-
Fetch repository metadata and contributor lists. Cache the data for 24 hours
154
-
to avoid repeated API calls. If the cache is fresh, use it. Otherwise, fetch
123
+
Fetch repository metadata and contributor lists. Cache the data for 24 hours
124
+
to avoid repeated API calls. If the cache is fresh, use it. Otherwise, fetch
155
125
new data and update the cache.
156
126
```
157
127
158
-
**What the agent will implement**: Before making expensive API calls, check if cached data exists and is fresh. If cache is valid (based on TTL), use cached data. Otherwise, fetch fresh data and update cache.
Store time-series data and compute trends, moving averages, and statistics.
132
+
Store time-series data and compute trends, moving averages, and statistics. The agent appends new data points to a JSON Lines history file and computes trends using Python.
171
133
172
-
**Your goal**: "Track metrics over time and identify trends."
173
-
174
-
**How to state it in your workflow**:
175
134
```markdown
176
-
Collect daily build times and test times. Store them in repo-memory as
177
-
time-series data. Compute 7-day and 30-day moving averages. Generate trend
135
+
Collect daily build times and test times. Store them in repo-memory as
136
+
time-series data. Compute 7-day and 30-day moving averages. Generate trend
178
137
charts showing whether performance is improving or declining over time.
179
138
```
180
139
181
-
**What the agent will implement**: Append new data points to a history file (JSON Lines format). Load historical data to compute trends, moving averages, and generate visualizations using Python.
Real examples: `.github/workflows/daily-code-metrics.md`, `.github/workflows/shared/charts-with-trending.md`
184
141
185
142
## Pattern 6: Multiple Memory Stores
186
143
187
-
Use multiple memory instances for different purposes and retention policies.
188
-
189
-
**Your goal**: "Organize data with different lifecycles - temporary session data, historical metrics, configuration, and archived snapshots."
190
-
191
-
**How to state it in your workflow**:
144
+
Use multiple memory instances for different lifecycles — cache-memory for temporary session data, separate repo-memory branches for metrics, configuration, and archives.
192
145
193
146
```markdown
194
-
Use cache-memory for temporary API responses during this run. Store daily
195
-
metrics in one repo-memory branch for trend analysis. Keep data schemas in
147
+
Use cache-memory for temporary API responses during this run. Store daily
148
+
metrics in one repo-memory branch for trend analysis. Keep data schemas in
196
149
another branch. Archive full snapshots in a third branch with compression.
197
150
```
198
151
199
-
**What the agent will implement**: Separate hot data (cache-memory) from historical data (repo-memory). Use different repo-memory branches for metrics vs. configuration vs. archives.
200
-
201
-
**Configuration to include**:
202
-
203
152
```yaml
204
153
tools:
205
154
cache-memory:
206
155
key: session-data # Fast, temporary
207
-
156
+
208
157
repo-memory:
209
158
- id: metrics
210
159
branch-name: memory/metrics # Time-series data
211
-
160
+
212
161
- id: config
213
162
branch-name: memory/config # Schema and metadata
214
-
163
+
215
164
- id: archive
216
165
branch-name: memory/archive # Compressed backups
217
166
```
@@ -267,13 +216,7 @@ fi
267
216
268
217
## Security Considerations
269
218
270
-
Memory stores are visible to anyone with repository access:
271
-
272
-
- **Never store**: Credentials, API tokens, PII, secrets
273
-
- **Store only**: Aggregate statistics, anonymized data
274
-
- Consider encryption for sensitive but non-secret data
275
-
276
-
**Safe practices**:
219
+
Memory stores are visible to anyone with repository access. Never store credentials, API tokens, PII, or secrets — only aggregate statistics and anonymized data.
0 commit comments