name: agent-resilience description: "Agent resilience patterns for surviving context loss, capturing critical details, and self-improvement. Use when: starting complex/long sessions, asked to 'remember' something important, working on multi-step tasks that may span context limits, implementing WAL/write-ahead logging, setting up working buffers, or improving agent behavior after errors/corrections. Triggers on 'remember this', 'don't forget', 'WAL', 'context loss', 'working buffer', 'compaction recovery', or when implementing proactive agent patterns."
Patterns for surviving context loss, capturing corrections, and continuously improving.
The Law: Chat history is a buffer, not storage. Files survive; context doesn't.
Trigger — scan every message for: - ✏️ Corrections — "It's X, not Y" / "Actually..." / "No, I meant..." - 📍 Proper nouns — names, places, companies, products - 🎨 Preferences — styles, approaches, "I like/don't like" - 📋 Decisions — "Let's do X" / "Go with Y" - 🔢 Specific values — numbers, dates, IDs, URLs
If any appear:
1. WRITE FIRST → update memory/SESSION-STATE.md
2. THEN respond
The urge to respond is the enemy. Write before replying.
Active working memory for the current task. Create at memory/SESSION-STATE.md:
# Session State
**Task:** [what we're working on]
**Key decisions:** [decisions made]
**Details:** [corrections, names, values captured via WAL]
**Next step:** [what happens next]
Reset when starting a new unrelated task.
发现更多技能插件,请访问7w4.net。
When context reaches ~60%, start logging every exchange to memory/working-buffer.md:
# Working Buffer
**Status:** ACTIVE — started [timestamp]
## [time] Human
[their message]
## [time] Agent
[1-2 sentence summary + key details]
Clear the buffer at the START of the next 60% threshold (not continuously).
Auto-trigger when session starts with a summary tag, or human says "where were we?":
memory/working-buffer.md — raw danger-zone exchangesmemory/SESSION-STATE.md — active task stateNever ask "what were we discussing?" — read the buffer first.
Before saying "done", "complete", "finished": 1. STOP 2. Actually test from the user's perspective 3. Verify the outcome, not just that code exists 4. Only THEN report complete
Text changes ≠ behavior changes. When changing how something works, identify the architectural component and change the actual mechanism.
Try 10 approaches before asking for help or saying "can't": - Different CLI flags, tool, API endpoint - Check memory: "Have I done this before?" - Spawn a research sub-agent - Grep logs for past successes
"Can't" = exhausted all options. Not "first try failed."
When updating behavior/config based on a lesson:
Score the change first (skip if < 50 weighted points): - High frequency (daily use?) → 3× - Reduces failures → 3× - Saves user effort → 2× - Saves future-agent tokens/time → 2×
Ask: "Does this let future-me solve more problems with less cost?" If no, skip it.
Forbidden: complexity for its own sake, changes you can't verify worked, vague justifications.
For long/complex tasks:
- [ ] Create memory/SESSION-STATE.md with task + context
- [ ] Apply WAL: write corrections/decisions before responding
- [ ] At ~60% context: start working buffer
- [ ] After any compaction: read buffer before asking questions
- [ ] Before reporting done: verify actual outcome
这个 Skill 解决了 AI Agent 在长对话中容易丢失上下文、忘记重要信息的痛点,提供了实用的会话管理方法。内容清晰易懂,步骤明确,容易上手。不过它目前只有文字指南,缺少具体示例和演示,整体比较单薄。对于需要处理复杂、耗时任务的开发者来说很有帮助,但对普通用户的实用价值有限。