agent-state-and-memory
Skill3 starsChanged 38 days agoMITView on GitHub
Design agent runtime state, checkpoints and memory without confusing recall with authoritative facts. Use when deciding what an AI system should persist, handling long-running context, cross-run memory, checkpoint/resume, provenance, expiry or deterministic state transitions. Do not use for coding-session context setup, a normal database migration, or conversational summarization with no runtime persistence design.
In this repository18 other files it gives its agents.
- agent-architectureSkill
- agent-cost-and-latencySkill
- agent-development-workflowSkill
- agent-evalsSkill
- agent-failure-recoverySkill
- agent-guardrailsSkill
- agent-observabilitySkill
- agent-orchestrationSkill
- agent-securitySkill
- agent-testingSkill
- deterministic-authoritySkill
- evidence-provenanceSkill
- human-in-the-loopSkill
- prompt-engineeringSkill
- rag-engineeringSkill
- structured-output-designSkill
- tool-designSkill
- tool-evalsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Start with a storage ownership table.
- Distinctive: line 29
Treat memory writes as proposals requiring validation, consent/policy where applicable, deduplication and provenance.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent State and Memory
Start with a storage ownership table. Do not call every persisted string memory or let a remembered claim update critical application state.
Assign each datum a role
| Kind | Purpose | Authority |
| Conversation context | Messages/evidence visible to the current model call | Input data; may be incomplete or malicious |
| Working memory | Temporary plan, scratch observations and intermediate proposals | Run-local, advisory |
| Persisted state | Typed runtime status, cursors, budgets, pending actions and receipts | Application-owned transitions |
| Episodic memory | Prior event/outcome summaries with evidence | Historical recall; verify consequential facts |
| Semantic memory | Searchable learned facts or document knowledge | Provenance-bound; not automatic truth |
| User preferences | Consented presentation/interaction defaults | Preferences cannot grant permissions |
| Authoritative application state | Current balances, entitlements and committed records | Trusted source for critical decisions |
Design lifecycle and reads
- Specify owner, tenant/user scope, provenance, source timestamp/version, sensitivity, expiry and deletion path for each persistent field. Persist only what supports a concrete task or resume requirement. Exclude credentials, unnecessary personal data, raw private reasoning and unverified model claims of success.
- Treat memory writes as proposals requiring validation, consent/policy where applicable, deduplication and provenance. Distinguish asserted facts from verified outcomes. Preserve conflicting sources and status rather than silently overwriting a newer authoritative fact with an older summary.
- Retrieve with tenant/permission filters before exposing candidates; rank by task relevance and freshness within a bounded context budget. Expire or revalidate consequential facts. Protect memory from cross-user contamination, indirect injection and poisoned preference writes. Revoked access also revokes retrieval/cache access.
- Compact conversation into claims plus source pointers, unresolved questions, remaining budgets and pending action IDs. Preserve provenance and uncertainty. A summary is lossy; re-fetch critical evidence before execution. Do not keep obsolete approval text as an authorization grant.
Make progress durable
- Define typed run states and deterministic allowed transitions. Accept transition events only with expected version, authorized actor and required evidence; use compare-and-set or transaction semantics for concurrent writers. Append immutable receipts and record partial completion rather than asking the model to rewrite status prose.
- Checkpoint at durable operation boundaries: run/task ID, completed effects and idempotency keys, pending/unknown outcomes, remaining budget, state/policy/prompt versions and evidence pointers. Avoid snapshotting an in-flight action as completed. Choose recovery behavior for a crash before versus after commit.
- Resume by validating checkpoint version, identity, access, expiry and unresolved effects against trusted stores. Reconcile ambiguous commits before repeating them. Reauthorize pending actions and preserve cumulative budgets across restarts; a restart must not reset limits.
Deliver the ownership/lifecycle table, transition contract, checkpoint example, compaction/read policy and isolation/deletion tests. Verify a stale success memory against current failure, simultaneous writers, expired preference, cross-tenant retrieval and restart after unknown commit.
Developer-session context packing and handoff are out of scope (a context-engineering skill may cover them). This skill owns the product runtime's persistence and source-of-truth boundary; agent-failure-recovery owns its recovery policy.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

