Skip to content

Commit ad62f24

Browse files
docs: unbloat memoryops guide by removing repetitive pattern labels (#23506)
1 parent c2a9830 commit ad62f24

1 file changed

Lines changed: 30 additions & 87 deletions

File tree

docs/src/content/docs/guides/memoryops.md

Lines changed: 30 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,7 @@ Use MemoryOps for incremental processing, trend analysis, multi-step tasks, and
1212
## How to Use These Patterns
1313

1414
> [!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.
3016
3117
## Memory Types
3218

@@ -61,18 +47,14 @@ tools:
6147

6248
Track progress through large datasets with todo/done lists to ensure complete coverage across multiple runs.
6349

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**:
6750
```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
7053
processing it. Generate a final report with statistics.
7154
```
7255

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 item so the workflow can resume if interrupted:
7457

75-
**Example structure the agent might use**:
7658
```json
7759
{
7860
"todo": [123, 456, 789],
@@ -82,24 +64,20 @@ processing it. Generate a final report with statistics.
8264
}
8365
```
8466

85-
**Real examples**: `.github/workflows/repository-quality-improver.md`, `.github/workflows/copilot-agent-analysis.md`
67+
Real examples: `.github/workflows/repository-quality-improver.md`, `.github/workflows/copilot-agent-analysis.md`
8668

8769
## Pattern 2: State Persistence
8870

8971
Save workflow checkpoints to resume long-running tasks that may timeout.
9072

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**:
9473
```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
9776
checkpoint until all records are migrated.
9877
```
9978

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:
10180

102-
**Example checkpoint the agent might use**:
10381
```json
10482
{
10583
"last_processed_id": 1250,
@@ -109,109 +87,80 @@ checkpoint until all records are migrated.
10987
}
11088
```
11189

112-
**Real examples**: `.github/workflows/daily-news.md`, `.github/workflows/cli-consistency-checker.md`
90+
Real examples: `.github/workflows/daily-news.md`, `.github/workflows/cli-consistency-checker.md`
11391

11492
## Pattern 3: Shared Information
11593

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.
12195

12296
*Producer workflow:*
12397
```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
12599
in repo-memory so other workflows can analyze the data later.
126100
```
127101

128102
*Consumer workflow:*
129103
```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.
131105
Generate a trend report with visualizations.
132106
```
133107

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:
135109

136-
**Configuration both workflows need**:
137110
```yaml
138111
tools:
139112
repo-memory:
140-
branch-name: memory/shared-data # Same branch for producer and consumer
113+
branch-name: memory/shared-data
141114
```
142115

143-
**Real examples**: `.github/workflows/metrics-collector.md` (producer), trend analysis workflows (consumers)
116+
Real examples: `.github/workflows/metrics-collector.md` (producer), trend analysis workflows (consumers)
144117

145118
## Pattern 4: Data Caching
146119

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).
150121

151-
**How to state it in your workflow**:
152122
```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
155125
new data and update the cache.
156126
```
157127

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.
159-
160-
**TTL guidelines to include in your prompt**:
161-
- Repository metadata: 24 hours
162-
- Contributor lists: 12 hours
163-
- Issues/PRs: 1 hour
164-
- Workflow runs: 30 minutes
165-
166-
**Real examples**: `.github/workflows/daily-news.md`
128+
Real examples: `.github/workflows/daily-news.md`
167129

168130
## Pattern 5: Trend Computation
169131

170-
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.
171133

172-
**Your goal**: "Track metrics over time and identify trends."
173-
174-
**How to state it in your workflow**:
175134
```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
178137
charts showing whether performance is improving or declining over time.
179138
```
180139

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.
182-
183-
**Real examples**: `.github/workflows/daily-code-metrics.md`, `.github/workflows/shared/charts-with-trending.md`
140+
Real examples: `.github/workflows/daily-code-metrics.md`, `.github/workflows/shared/charts-with-trending.md`
184141

185142
## Pattern 6: Multiple Memory Stores
186143

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.
192145

193146
```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
196149
another branch. Archive full snapshots in a third branch with compression.
197150
```
198151

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-
203152
```yaml
204153
tools:
205154
cache-memory:
206155
key: session-data # Fast, temporary
207-
156+
208157
repo-memory:
209158
- id: metrics
210159
branch-name: memory/metrics # Time-series data
211-
160+
212161
- id: config
213162
branch-name: memory/config # Schema and metadata
214-
163+
215164
- id: archive
216165
branch-name: memory/archive # Compressed backups
217166
```
@@ -267,13 +216,7 @@ fi
267216

268217
## Security Considerations
269218

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.
277220

278221
```bash
279222
# ✅ GOOD - Aggregate statistics

0 commit comments

Comments
 (0)