Prompt Details
Model
Chat - (gpt-5.6)
Token size
4,237
Example input
[DESCRIBE WHAT THE AGENT DOES, WHO USES IT, AND WHICH WORKFLOWS REQUIRE MEMORY]: AI Project Management Agent for freelancers. Helps manage client projects, deadlines, requirements, deliverables, and recurring preferences. Memory is needed across multiple conversations.
[DESCRIBE WHAT TYPES OF INFORMATION THE AGENT MAY ENCOUNTER OR NEED TO REMEMBER]: User preferences Client/project information Task status Past project decisions Deadlines Conversation history User corrections Tool-generated project data
[DESCRIBE EXISTING MEMORY SYSTEMS, DATABASES, VECTOR STORES, SESSION STORAGE, OR OTHER MEMORY MECHANISMS]: Session memory: Redis Long-term structured memory: PostgreSQL Semantic retrieval: Vector database Project events: Event log No formal expiration or conflict-resolution system yet
[DESCRIBE DATA-SENSITIVITY, ACCESS BOUNDARIES, USER CONTROLS, SECURITY REQUIREMENTS, AND MEMORY RESTRICTIONS]: User can access only their own memories. Client A data must never appear in Client B conversations. Sensitive information requires restricted access. User can request memory deletion.
[DESCRIBE WHAT YOU WANT TO OPTIMIZE: ACCURACY, RELEVANCE, FRESHNESS, PERSONALIZATION, COST, LATENCY, SAFETY, OR OTHER OBJECTIVES]: High retrieval relevance High factual accuracy Fresh project status Low irrelevant-memory injection Low latency Controlled storage cost Strong deletion guarantees
Example output
🚀 PHASE 1 — AGENT MEMORY CONTEXT RECONSTRUCTION
🎯 Memory Context
The agent manages freelance projects and therefore needs memory that persists across conversations.
The core principle is:
Current task context ≠ durable memory.
For example:
"Write a proposal for Client A" → temporary task context.
"Client A requires all reports in PDF" → potentially durable project memory.
"The user prefers concise proposals" → potentially durable preference.
"The user said they are tired today" → ephemeral unless explicitly relevant and authorized for persistence.
🔄 Memory-Dependent Workflows
1. Project continuation
Retrieve previous project state.
Identify unfinished tasks.
Verify whether old information is still current.
2. Deliverable creation
Retrieve relevant client requirements.
Retrieve applicable user preferences.
3. Deadline management
Retrieve active deadlines.
Exclude expired deadlines.
4. Client communication
Retrieve project-specific communication preferences.
Never mix information between clients.
5. Project handoff
Retrieve decisions, requirements, dependencies, and outstanding work.
🚨 Critical Memory Requirements
Project isolation
User isolation
Accurate project status
Provenance tracking
Freshness tracking
Conflict detection
Deletion support
Authorization before retrieval
⚠️ Memory Risks
Wrong client information retrieved.
Old deadline treated as current.
User preference incorrectly inferred.
Deleted memory remaining in vector search.
Conflicting project requirements.
Duplicate memories.
Irrelevant memories injected into prompts.
❓ Unknowns
Exact compliance requirements are not specified.
Exact sensitive-data categories are not specified.
Exact infrastructure scale is unknown.
Maximum acceptable retrieval latency is unknown.
Exact backup deletion guarantees are unknown.
---
🧩 PHASE 2 — MEMORY TAXONOMY & CLASSIFICATION
1. 🟢 Working Memory
Purpose: Current reasoning/task execution.
Lifetime: minutes to hours
Storage: session context / Redis
Retrieval: automatically available during active task
Update: continuously
Expiration: end of task/session
Deletion: automatic
Example:
> "Create Client A's proposal using the requirements discussed above."
This does not automatically become long-term memory.
---
2. 🔵 Session Memory
Purpose: Maintain continuity during the current conversation.
Lifetime: current session
Storage: Redis/session store
Retrieval: current session
Update: continuously
Expiration: session expiration
Deletion: automatic according to session policy
---
3. 🟣 Project Memory
Purpose: Preserve durable project context.
Examples:
Project requirements
Approved architecture
Client constraints
Current project state
Important decisions
Lifetime: project lifecycle + defined retention period
Storage: PostgreSQL
Retrieval: project-authorized contexts only
Update: versioned
Expiration: project completion + retention period
---
4. 🟡 Preference Memory
Example:
> User prefers concise client proposals.
Lifetime: potentially long-term
Storage: PostgreSQL
Retrieval: only when relevant
Update: when explicitly changed or sufficiently confirmed
Expiration: based on stability/revalidation policy
---
5. 🟠 Episodic Memory
Example:
> On September 20, Client A approved Version 3 of the landing page.
This records an event rather than a permanent fact.
Storage: event/history store
Retrieval: when historical context matters
Update: append-only where appropriate
Retention: project-dependent
---
6. 🔴 Semantic Memory
Example:
> The project uses PostgreSQL for persistent application data.
Storage: structured database + optional vector index
Retrieval: relevant technical/project queries
Update: versioned
Expiration: when invalidated or project ends
---
🧠 PHASE 3 — MEMORY CREATION & CANDIDATE DETECTION
The agent observes:
> "For all future reports for Client A, use PDF format."
The system creates:
MEMORY CANDIDATE
Candidate:
Client A requires reports in PDF format.
Source:
User statement
Confidence:
High
Scope:
Client A / Project X
Potential lifetime:
Project duration
🔍 Candidate Signals
Strong signals:
Explicit request to remember
Explicit stable requirement
Confirmed project decision
Repeated confirmed requirement
Important project state
Weak signals:
One-time statement
Temporary emotion
Casual conversation
Unconfirmed inference
🟢 Ephemeral Example
> "Let's use a blue button for this mockup."
If it applies only to the current mockup, it remains temporary.
🔴 Should Not Become Memory Automatically
> "The user seems to like modern designs."
This is an INFERENCE, not a confirmed durable preference.
---
🚪 PHASE 4 — MEMORY ADMISSION & QUALITY GATE
Each candidate passes through an admission gate.
🧮 Admission Factors
Relevance
Future usefulness
Stability
Explicitness
Confidence
Scope
Sensitivity
Expected lifetime
Risk if incorrect
🟢 Example 1
> "Remember that Client A requires PDF reports."
Decision:
ACCEPT
Reason:
Explicit
Project-specific
Reusable
High confidence
---
🟡 Example 2
> "I think Client A may prefer shorter emails."
Decision:
REQUIRE CONFIRMATION
Reason:
Uncertain
Preference is inferred
Incorrect memory could affect communication
---
🔴 Example 3
> "I am currently working on a proposal."
Decision:
TEMPORARY ONLY
Reason:
Current task state
No durable value demonstrated
---
❌ Example 4
> "The user probably dislikes long documents."
Decision:
REJECT
Reason:
Unsupported inference
No explicit confirmation
---
⚡ PHASE 5 — SHORT-TERM VS LONG-TERM MEMORY
🟢 Short-Term
Contains:
Current request
Current reasoning state
Temporary task variables
Recent conversation
Intermediate results
Example:
> "Generate three proposal versions."
---
🔵 Long-Term
Contains:
Confirmed client requirements
Stable preferences
Persistent project decisions
Durable project state
Example:
> "Client A requires PDF reports."
---
⬆️ Promotion Rule
SHORT-TERM
↓
MEMORY CANDIDATE
↓
CLASSIFICATION
↓
QUALITY GATE
↓
ADMISSION
↓
LONG-TERM
Repeated appearance alone is not sufficient.
The system must determine whether repetition represents a genuine stable fact.
---
⬇️ Demotion Rule
LONG-TERM
↓
AGING
↓
STALE
↓
REVALIDATION
↓
CURRENT / SUPERSEDED / EXPIRED
---
🗄️ PHASE 6 — MEMORY STORAGE ARCHITECTURE
🏗️ Recommended Hybrid Architecture
Redis ⚡
For:
Working memory
Session memory
Temporary state
PostgreSQL 🗃️
For:
Durable memory records
Metadata
Versions
Permissions
Lifecycle states
Vector Database 🔎
For:
Semantic retrieval
Similarity search
Event Store 📜
For:
Memory creation
Updates
Conflicts
Deletion events
Audit history
🔗 Architecture
USER
↓
AGENT
↓
MEMORY CANDIDATE
↓
ADMISSION ENGINE
↓
POSTGRESQL ─────→ VECTOR INDEX
↓
EVENT LOG
↓
RETRIEVAL ENGINE
↓
AUTHORIZATION
↓
FRESHNESS CHECK
↓
LLM CONTEXT
The vector database should not be treated as the source of truth.
PostgreSQL/project records remain authoritative.
---
🧱 PHASE 7 — MEMORY SCHEMA
A memory record could contain:
memory_id
user_id
tenant_id
project_id
memory_type
content
source_type
source_reference
created_at
updated_at
last_validated_at
confidence
importance
freshness_state
sensitivity_level
scope
owner
status
version
expires_at
supersedes_memory_id
supports_memory_id
deletion_state
🔐 Example
memory_id: MEM-10482
user_id: USER-001
project_id: PROJECT-A
memory_type: PROJECT_REQUIREMENT
content:
"Client A requires PDF reports."
source_type:
USER_STATED
confidence:
0.98
scope:
PROJECT-A
status:
CURRENT
version:
3
freshness_state:
FRESH
---
📜 PHASE 8 — PROVENANCE & VERSIONING
Suppose the original requirement was:
> "Reports must be PDF."
Later the client says:
> "Reports can now be PDF or DOCX."
The system should not silently replace the previous memory.
Instead:
Version 1
"Reports must be PDF."
↓
SUPERSEDED
Version 2
"Reports can be PDF or DOCX."
↓
CURRENT
Record:
Who provided the change
When it changed
Why it changed
Previous version
New version
Supporting evidence
This makes the memory explainable.
---
🔎 PHASE 9 — MEMORY RETRIEVAL ARCHITECTURE
When the user asks:
> "Create Client A's report."
Retrieval should execute:
QUERY
↓
IDENTIFY USER
↓
IDENTIFY PROJECT
↓
CANDIDATE RETRIEVAL
↓
AUTHORIZATION FILTER
↓
STATUS FILTER
↓
FRESHNESS CHECK
↓
RELEVANCE RANKING
↓
VALIDATION
↓
CONTEXT INJECTION
🎯 Retrieval Factors
A memory should receive higher retrieval priority when it has:
Strong task relevance
Correct project scope
High confidence
Recent validation
Current status
Appropriate memory type
🚫 Example of Prevented Leakage
Client A:
> "Reports must be PDF."
Client B:
> "Reports must be DOCX."
When working on Client B, Client A's requirement must be filtered out before context injection, even if semantic similarity is extremely high.
---
🕐 PHASE 10 — FRESHNESS & STALE-MEMORY STRATEGY
Memory states:
FRESH
↓
AGING
↓
STALE
↓
EXPIRED
↓
ARCHIVED / DELETED
🟢 Fresh
Recently validated and no contradictory evidence.
🟡 Aging
Still usable but approaching its validation window.
🟠 Stale
Potentially outdated.
The system should either:
Revalidate
Temporarily exclude
Retrieve with reduced confidence
🔴 Expired
No longer eligible for normal retrieval.
⚫ Invalidated
Known to be incorrect or superseded.
---
⚔️ PHASE 11 — MEMORY UPDATE & CONFLICT RESOLUTION
Example:
Old memory:
> "Client A requires PDF."
New information:
> "Client A now accepts PDF and DOCX."
The system detects a contradiction/change.
Decision
SUPERSEDE
Old:
SUPERSEDED
New:
CURRENT
Historical version remains available for audit/history where policy permits.
---
🟡 Uncertain Conflict
Suppose:
> "Client A might have changed the format requirement."
No authoritative confirmation exists.
Decision:
CONFLICTED / UNCERTAIN
Do not automatically overwrite the current requirement.
The agent should seek confirmation when the decision materially affects the task.
---
⏳ PHASE 12 — RETENTION & EXPIRATION ENGINE
🟢 Working Memory
Retention: session/task lifecycle
Expiration: task/session completion
🔵 Active Project Memory
Retention: active project duration
Revalidation: event-driven and periodic
🟣 Completed Project
Retention: 12 months in this test architecture
Then: expire/archive according to policy
🟡 User Preference
Retention: longer-lived when explicitly confirmed
Revalidation: when user behavior or explicit correction indicates change
🔴 Sensitive Memory
More restrictive retention
Explicit authorization
Narrow retrieval scope
Earlier deletion where appropriate
Indefinite retention is not the default.
---
🗑️ PHASE 13 — DELETION LIFECYCLE
User requests:
> "Delete everything related to Client A."
System executes:
ACTIVE
↓
DELETION REQUEST
↓
MARKED FOR DELETION
↓
PRIMARY RECORD DELETED
↓
VECTOR INDEX REMOVED
↓
CACHE INVALIDATED
↓
DERIVED REFERENCES PROCESSED
↓
BACKUP POLICY APPLIED
↓
DELETION VERIFIED
🔍 Deletion Verification
Verify:
PostgreSQL record
Vector index
Search index
Redis cache
Derived memory
Relevant event references
Backup lifecycle according to applicable policy
Expired memory must not remain silently retrievable.
---
🔐 PHASE 14 — SECURITY & ACCESS CONTROL
👤 User Boundary
USER A
├── Project A
└── Project B
USER B
└── Project C
User A cannot retrieve User B's memories.
🏢 Project Boundary
Client A data:
tenant_id = T1
project_id = A
Client B:
tenant_id = T1
project_id = B
Project-level authorization must be applied before memory injection.
👁️ Access Rules
CREATE
Agent + authorized user/system
READ
Authorized agent/session
UPDATE
Authorized agent/user
DELETE
Authorized user/admin/system policy
EXPORT
Authorized user/admin according to policy
---
🔄 PHASE 15 — MEMORY LIFECYCLE STATE MACHINE
OBSERVE
↓
CANDIDATE
↓
CLASSIFY
↓
ADMISSION GATE
├── REJECT
├── TEMPORARY
├── REQUIRE CONFIRMATION
└── ACCEPT
↓
STORE
↓
INDEX
↓
RETRIEVE
↓
AUTHORIZE
↓
VALIDATE
↓
USE
↓
REVALIDATE
↙ ↘
CURRENT CONFLICT
↓ ↓
UPDATE RESOLVE
↓ ↓
REINFORCE VERSION
↓ ↓
AGING ←──────┘
↓
STALE
↓
REVALIDATE
↙ ↘
CURRENT EXPIRED
↓
ARCHIVE/DELETE
↓
VERIFY
---
🧪 PHASE 16 — MEMORY QUALITY & EVALUATION
📊 Metrics
Memory Precision
How many stored memories are actually useful and valid?
Memory Recall
How often does the system retrieve necessary memories?
Retrieval Relevance
How much retrieved memory is actually relevant to the current task?
Stale-Memory Rate
Percentage of retrieved memories that were outdated.
False-Memory Rate
Percentage of memories incorrectly treated as facts.
Contradiction Rate
Frequency of unresolved conflicting memories.
Unauthorized Retrieval Rate
Target:
0
Deletion Completion Rate
Percentage of deletion requests fully processed.
Retrieval Latency
Measure:
Query → Retrieved authorized memories
---
🧪 PHASE 17 — TEST SCENARIOS
🟢 Test 1 — Correct Retrieval
Input:
> "Create Client A's PDF report."
Expected:
Retrieve Client A PDF requirement.
Verify current status.
Inject into context.
Expected result:
PASS
---
🔴 Test 2 — Wrong Project Retrieval
Input:
> "Create Client B's report."
Client A says PDF.
Client B says DOCX.
Expected:
Client A memory rejected by project scope.
Client B memory retrieved.
Expected result:
PASS
---
🟠 Test 3 — Stale Memory
Old memory:
> Client A requires PDF.
Current project record:
> Client A now accepts DOCX.
Expected:
Detect contradiction.
Do not blindly use old memory.
Retrieve latest authoritative information.
Expected result:
PASS
---
🔵 Test 4 — Deleted Memory
User deletes Client A project.
Expected:
Primary memory deleted.
Vector index cleaned.
Cache invalidated.
Retrieval returns no active Client A memory.
Expected result:
PASS
---
🟣 Test 5 — Inferred Preference
Agent observes:
> User selected short proposal three times.
Agent must not automatically conclude:
> "User permanently prefers short proposals."
Expected:
REQUIRE CONFIRMATION or maintain as a lower-confidence temporary inference according to policy.
---
🔐 Test 6 — Unauthorized Retrieval
User B asks:
> "What did User A tell you about Client A?"
Expected:
Authorization failure.
No memory content exposed.
Expected result:
PASS
---
🧮 PHASE 18 — MEMORY LIFECYCLE DECISION MATRIX
Memory Type Admission Rule Storage Retrieval Update Retention Expiration Deletion
Working Current task only Redis Current task Continuous Session Session end Automatic
Session Useful for current conversation Redis Current session Continuous Session Session expiry Automatic
Project Requirement Confirmed/useful PostgreSQL + Vector Matching project Versioned Project lifecycle Project closure policy User/policy deletion
Preference Explicit/stable PostgreSQL Relevant tasks Confirm/change Long-lived with revalidation Stale/change User request/policy
Episodic Meaningful project event Event Store Historical queries Append/version Project policy Retention policy Lifecycle deletion
Semantic Valid reusable knowledge PostgreSQL + Vector Relevant context Versioned Until invalidated Validation policy Deletion policy
Task State Active task dependency Redis/PostgreSQL Active task Frequent Task lifecycle Task completion Automatic
---
🚨 PHASE 19 — MEMORY RISK REGISTER
Risk Trigger Impact Detection Mitigation Validation
False memory Incorrect admission Wrong agent behavior Admission tests Strong admission gate False-memory benchmark
Stale memory Old project information Incorrect output Freshness checks Revalidation Staleness tests
Cross-project leakage Incorrect scope Privacy breach Authorization tests Project filtering Isolation tests
Duplicate memory Repeated ingestion Retrieval noise Similarity/entity checks Deduplication Duplicate benchmark
Silent overwrite Conflicting update Lost history Version monitoring Versioning Conflict tests
Unauthorized retrieval Permission failure Privacy breach Access logs Authorization layer Security tests
Deleted memory resurfacing Index/cache not cleaned Privacy risk Deletion verification Cascade deletion Deletion tests
Irrelevant retrieval Weak ranking Context pollution Relevance metrics Ranking/filtering Retrieval benchmark
Excessive retention Missing expiration Storage/privacy risk Lifecycle audit Retention engine Expiration tests
---
🛠️ PHASE 20 — IMPLEMENTATION ROADMAP
Phase 1 — Foundation 🧱
Build:
Memory schema
Memory IDs
User/project scope
Memory types
Status fields
Provenance fields
Phase 2 — Admission 🧠
Implement:
Candidate detection
Classification
Confidence
Admission decisions
Temporary-memory handling
Phase 3 — Retrieval 🔎
Implement:
Hybrid retrieval
Authorization filtering
Freshness filtering
Relevance ranking
Context injection controls
Phase 4 — Lifecycle 🔄
Implement:
Versioning
Conflict detection
Revalidation
Expiration
Archival
Deletion
Phase 5 — Governance 🔐
Implement:
Access control
Audit events
User deletion
Project deletion
Index cleanup
Cache invalidation
Phase 6 — Evaluation 🧪
Create automated tests for:
False memories
Missing memories
Stale memories
Conflicts
Duplicate memories
Unauthorized retrieval
Deleted memories
Cross-project leakage
---
❓ PHASE 21 — OPEN QUESTIONS & UNKNOWNS
Before production deployment, clarify:
1. What information is legally or contractually classified as sensitive?
2. Which users can access project memories?
3. How long should completed projects remain available?
4. What is the authoritative source when memory conflicts with a project database?
5. Which memories require explicit user confirmation?
6. What is the maximum acceptable retrieval latency?
7. How should backups handle deleted memories?
8. Should users be able to inspect memory provenance?
9. Should users be able to correct individual memories?
10. What events should immediately invalidate a memory?
---
🏆 PHASE 22 — FINAL MEMORY ARCHITECTURE RECOMMENDATIONS
🧠 Core Architecture
┌─────────────────┐
│ USER / AGENT │
└────────┬────────┘
↓
┌─────────────────┐
│ OBSERVATION │
└────────┬────────┘
↓
┌─────────────────┐
│ CANDIDATE ENGINE │
└────────┬────────┘
↓
┌─────────────────┐
│ ADMISSION GATE │
└───────┬─┬───────┘
│ │
REJECT │ │ ACCEPT
│ ↓
│ ┌──────────────┐
│ │ MEMORY STORE │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ VECTOR INDEX │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ RETRIEVAL │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ AUTHORIZATION│
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ FRESHNESS │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ VALIDATION │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ USE │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │UPDATE/VERSION│
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
│ │ DECAY/EXPIRE │
│ └──────┬───────┘
│ ↓
│ ┌──────────────┐
└────│ ARCHIVE/ │
│ DELETE │
└────────────┘
🔑 Final Design Principles
🧠 Memory is a controlled resource, not a conversation dump.
🎯 Admission happens before persistence.
🔐 Authorization happens before memory reaches the model context.
📜 Every durable memory has provenance.
🕐 Every durable memory has freshness information.
⚔️ Conflicts create explicit states instead of silent overwrites.
🗑️ Deletion covers primary records and relevant derived indexes/caches.
🔎 Semantic similarity does not override authorization or scope.
🧪 Every major lifecycle policy is testable.
📊 Retrieval quality matters more than retrieval quantity.
♻️ Memory can be promoted, updated, superseded, expired, archived, or deleted.
🚫 Unknown information remains UNKNOWN rather than becoming an invented memory.
🎯 Final Lifecycle
OBSERVATION
→ MEMORY CANDIDATE
→ CLASSIFICATION
→ ADMISSION
→ STORAGE
→ INDEXING
→ RETRIEVAL
→ AUTHORIZATION
→ FRESHNESS CHECK
→ VALIDATION
→ USE
→ UPDATE
→ REINFORCEMENT / DECAY
→ EXPIRATION
→ ARCHIVAL / DELETION
→ VERIFICATION
Test Verdict: The architecture successfully demonstrates controlled memory creation, scoped retrieval, provenance, versioning, stale-memory handling, conflict resolution, retention, deletion, security isolation, and lifecycle evaluation.
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Agent Memory Lifecycle Architect designs the complete memory lifecycle from creation → classification → storage → retrieval → validation → update → expiration → deletion, while separating short-term working memory from durable long-term memory.
🧠 Design short-term and long-term memory boundaries
🗂️ Define memory creation and admission rules
🧪 Design memory validation and testing
👉 Turn agent memory from a simple database into a controlled, reliable lifecycle system.
...more
Added 2 weeks ago
