Loading...
Loading...
Working memory management, context prioritization, and knowledge retention patterns for AI agents. Use when you need to maintain relevant context and avoid information loss during long tasks.
npx skill4agent add alicoder001/agent-skills memoryEfficient context and knowledge management.
┌─────────────────────────────────────────┐
│ WORKING MEMORY │
├─────────────────────────────────────────┤
│ • Current task goal │
│ • Relevant file contents │
│ • Recent decisions │
│ • Active constraints │
└─────────────────────────────────────────┘
↑ Load ↓ Store
┌─────────────────────────────────────────┐
│ LONG-TERM MEMORY │
├─────────────────────────────────────────┤
│ • Project structure │
│ • User preferences │
│ • Past solutions │
│ • Domain knowledge │
└─────────────────────────────────────────┘| Priority | Content | Action |
|---|---|---|
| 🔴 Critical | Current task, active file | Always keep |
| 🟠 High | Related files, types | Keep if relevant |
| 🟡 Medium | Project structure | Summarize |
| 🟢 Low | History, logs | Forget if needed |
## What to Remember
✅ Keep in context:
- Current task objective
- File being modified
- Type definitions in use
- Recent error messages
- User preferences
❌ Safe to forget:
- Already processed files
- Resolved errors
- Intermediate calculations
- Verbose logs## Summarization Rules
1. **Files**: Keep imports, types, key functions
2. **Errors**: Keep message, remove stack trace
3. **Logs**: Keep last 10 lines
4. **History**: Keep decisions, remove process
### Example
Before (verbose):
"I looked at file A, then file B, noticed pattern X,
then explored file C, found issue Y, traced it to..."
After (summarized):
"Analyzed A, B, C. Found: pattern X, issue Y in C."// Conceptual session state
interface SessionMemory {
// Always retain
task: {
goal: string;
status: 'planning' | 'executing' | 'verifying';
progress: number;
};
// Retain while relevant
context: {
activeFiles: string[];
recentDecisions: string[];
constraints: string[];
};
// Summarize or forget
history: {
summary: string;
keyInsights: string[];
};
}## Before Starting New Task
1. Check: Have I seen this before?
2. Recall: What approach worked?
3. Apply: Use proven patterns
4. Adapt: Modify for current context## Per-Turn Cleanup
After completing a step:
1. ✅ Task still relevant? Keep
2. ❓ Might need later? Summarize
3. ❌ No longer needed? Forget
## End of Task
1. Extract learnings
2. Update knowledge base
3. Clear working memory## Token Budget Allocation
| Category | Budget |
|----------|--------|
| System prompt | 10% |
| Task context | 30% |
| Active code | 40% |
| Conversation | 20% |
## When Near Limit
1. Summarize conversation history
2. Remove resolved issues
3. Keep only relevant code sections
4. Preserve critical context