PromptBase
PromptBase SelectGet Select
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
(claude-5-5-sonnet)
Token size
4,256
Example input
[AGENT_PURPOSE]: Manage user preferences, tasks, decisions, and long-term conversation continuity. [MEMORY_ARCHITECTURE]: PostgreSQL database with conversation history and basic persistent memory. [MODEL_AND_TOKEN_LIMITS]: GPT model, 32,000-token context window, maximum 4,000 tokens for retrieved memories. [SESSION_DATA]: User prefers Python over JavaScript for automation projects. User is developing an AI-powered SaaS product. User's current project deadline is December 15, 2026. User temporarily needs a presentation for tomorrow. User previously preferred PostgreSQL but now says they want to use MongoDB for the new project. [SYSTEM_CONSTRAINTS]: Never store exposed credentials. Preserve important project decisions. Detect conflicting preferences. Maintain cross-session continuity. Limit retrieved memory to 4,000 tokens. Support user-requested deletion.
Example output
### 🧩 PHASE 1: MEMORY REQUIREMENT RECONSTRUCTION Objective: Understand the agent's memory requirements. Test Analysis: | Requirement | Classification | | ----------------------------------------- | -------------- | | Preserve coding preferences | Explicit | | Track SaaS development progress | Explicit | | Remember project deadline | Explicit | | Support long-term continuity | Explicit | | Weekly progress summaries | Explicit | | Detect database preference changes | Derived | | Automatically determine memory importance | Proposed | | Exact session volume | Unknown | Identified Requirements: * Maintain persistent user preferences. * Track active project status. * Separate temporary tasks from long-term memories. * Preserve historical project decisions. * Support memory retrieval across sessions. * Prevent sensitive credential storage. Expected: Pass Validation: The agent must distinguish explicit requirements, derived requirements, assumptions, and unresolved questions. ### πŸ” PHASE 2: EXISTING MEMORY ARCHITECTURE AUDIT Objective: Identify weaknesses in the existing architecture. Supplied Architecture: * PostgreSQL database. * Conversation history storage. * Basic persistent memory. Audit Results: | Component | Assessment | | --------------------- | ---------------- | | Conversation history | Available | | Persistent memory | Available | | Working memory | Not confirmed | | Task state management | Not confirmed | | Vector database | Not provided | | Retrieval ranking | Not provided | | Token counting | Not provided | | Memory versioning | Not provided | | Deletion controls | Requirement only | Potential Problems: * No confirmed duplicate detection. * No confirmed memory expiration mechanism. * No confirmed conflict-resolution system. * No confirmed token-budget enforcement. * No confirmed sensitive-data filtering. * No confirmed checkpoint recovery. Recommendation: Extend the existing PostgreSQL architecture before introducing additional infrastructure. Expected: Pass ### πŸ—‚οΈ PHASE 3: MEMORY CLASSIFICATION AND TAXONOMY Objective: Classify every supplied information item. | Information | Memory Category | Retention | | ------------------------------ | --------------- | ---------------- | | Python preference | Long-term | Until changed | | SaaS development | Episodic / Task | Until completed | | December 15 deadline | Task | Until expiry | | Tomorrow's presentation | Short-term | Until completed | | PostgreSQL preference | Episodic | Historical | | MongoDB decision | Task / Episodic | Project lifetime | | Exposed API key | Reject | Never store | | Weekly summaries | Procedural | Until changed | | Authentication completed | Task | Project lifetime | | Database integration completed | Task | Project lifetime | | Payment integration pending | Task | Until completed | | Restaurant recommendation | Ignore | No retention | Important Classification Rule: The old PostgreSQL preference must not automatically be deleted because the new MongoDB decision applies specifically to the new project. The system must preserve the distinction between a general preference and a project-specific decision. Expected Memory Categories: * Working memory: Current execution details. * Short-term memory: Tomorrow's presentation. * Long-term memory: Python preference. * Episodic memory: Previous PostgreSQL preference. * Procedural memory: Weekly reporting instruction. * Task memory: SaaS development progress. Expected: Pass ### 🧠 PHASE 4: MEMORY ADMISSION AND SELECTION ENGINE Objective: Determine what should be stored. | Candidate | Decision | Reason | | ------------------------------ | ------------ | -------------------------- | | Python preference | Store | Durable preference | | SaaS project | Store | Important ongoing project | | December deadline | Store | Future dependency | | Tomorrow's presentation | Session only | Temporary task | | PostgreSQL preference | Preserve | Historical preference | | MongoDB decision | Store | Confirmed project decision | | API key | Reject | Sensitive credential | | Weekly summaries | Store | Reusable instruction | | Completed authentication | Store | Project progress | | Completed database integration | Store | Project progress | | Pending payment integration | Store | Unresolved task | | Restaurant recommendation | Ignore | Irrelevant | Sample Admission Decision Record: ```json { "memory_id": "MEM-1001", "memory_type": "long_term", "content": "User prefers Python for automation projects.", "source": "conversation", "confidence": 1.0, "importance": 0.85, "decision": "STORE", "reason": "Explicit and reusable preference", "retention": "Until updated or deleted", "status": "active" } ``` Security Validation: The API key must not enter persistent memory, summaries, logs, or retrieval indexes. Expected: Pass ### πŸ—οΈ PHASE 5: MEMORY SCHEMA AND STORAGE DESIGN Objective: Design structured memory storage. Recommended Architecture: PostgreSQL No vector database is required initially because the supplied requirements do not establish a need for semantic vector retrieval. Proposed Schema: ```sql CREATE TABLE agent_memories ( memory_id UUID PRIMARY KEY, user_id UUID NOT NULL, session_id UUID, memory_type VARCHAR(30) NOT NULL, content TEXT NOT NULL, source TEXT, confidence FLOAT NOT NULL, importance FLOAT NOT NULL, created_at TIMESTAMP NOT NULL, updated_at TIMESTAMP NOT NULL, expires_at TIMESTAMP, version INTEGER DEFAULT 1, status VARCHAR(20) DEFAULT 'active' ); ``` Additional Requirements: * Index user_id and memory_type. * Enforce tenant-level isolation. * Add version history for important updates. * Validate confidence and importance ranges. * Use access controls for sensitive records. * Add deletion propagation to derived summaries. Expected Result: Structured storage supports memory ownership, classification, updates, and expiration. Expected: Pass ### πŸ“ PHASE 6: MEMORY SUMMARIZATION ENGINE Objective: Compress conversation history without losing critical information. Sample Original Conversation Information: * User is developing an AI-powered SaaS product. * Python is preferred for automation. * Project deadline is December 15, 2026. * Authentication is complete. * Database integration is complete. * Payment integration remains pending. * Weekly progress summaries are requested. Expected Compressed Summary: ```text PROJECT: AI-Powered SaaS Deadline: December 15, 2026. USER PREFERENCE: Python for automation projects. COMPLETED: 1. Authentication. 2. Database integration. PENDING: 1. Payment integration. INSTRUCTIONS: Generate weekly project progress summaries. DATABASE DECISION: MongoDB selected for the new project. Previous PostgreSQL preference retained as historical context. TEMPORARY: Presentation required tomorrow. ``` Validation Checks: * Preserve project deadline. * Preserve completed tasks. * Preserve pending tasks. * Preserve user preferences. * Preserve historical decisions. * Separate temporary tasks. * Exclude API credentials. * Exclude unrelated conversation. Expected: Pass ### βœ‚οΈ PHASE 7: CONTEXT PRUNING AND INFORMATION RETENTION Objective: Remove unnecessary context safely. | Context Item | Action | | -------------------------------- | -------------------- | | System instructions | Must retain | | Current SaaS objective | Must retain | | MongoDB decision | Must retain | | Project deadline | Must retain | | Pending payment integration | Must retain | | Python preference | Retain | | Historical PostgreSQL preference | Retain when relevant | | Presentation task | Session only | | Restaurant recommendation | Remove | | Repeated project explanations | Summarize | | API credential | Reject and exclude | Pruning Rules: * Never remove active task dependencies. * Never remove unresolved decisions. * Preserve historical information when it explains current decisions. * Remove redundant context. * Keep temporary tasks separate from persistent memory. * Validate the retained context before pruning the original history. Expected Result: Reduced context without loss of important project information. Expected: Pass ### πŸ“Š PHASE 8: TOKEN BUDGET AND CONTEXT WINDOW OPTIMIZATION Objective: Allocate the 32,000-token context window. Proposed Token Allocation: | Context Component | Token Budget | | --------------------------- | ------------ | | System instructions | 4,000 | | Developer instructions | 2,000 | | Current user request | 2,000 | | Recent conversation | 5,000 | | Retrieved memories | 4,000 | | Active task state | 3,000 | | Tool outputs | 5,000 | | Response generation reserve | 7,000 | | Total | 32,000 | Overflow Strategy: * First remove redundant historical messages. * Compress repeated tool outputs. * Summarize completed conversation sections. * Preserve critical decisions and dependencies. * Never truncate protected system instructions. * Recount tokens after context assembly. Expected Result: Context must never exceed 32,000 tokens. Expected: Pass ### 🎯 PHASE 9: MEMORY RETRIEVAL AND RELEVANCE ENGINE Objective: Retrieve only relevant memories. New User Query: "What should I complete next in my SaaS project?" Expected Retrieved Memories: | Memory | Relevance | Action | | --------------------------- | --------- | ---------------------------------------------- | | SaaS project status | High | Retrieve | | Payment integration pending | High | Retrieve | | December deadline | High | Retrieve | | MongoDB project decision | High | Retrieve | | Python preference | Medium | Retrieve if implementation advice needs it | | Restaurant recommendation | None | Reject | | Presentation task | Low | Reject | | Old PostgreSQL preference | Low | Exclude unless historical comparison is needed | Expected Agent Response: "Your next priority should be payment integration because authentication and database integration are already complete. After integrating payments, test successful transactions, failed transactions, webhook handling, and refund workflows." Retrieval Safeguards: * Apply user and tenant filters. * Deduplicate retrieved records. * Check memory status and expiration. * Prefer confirmed and relevant memories. * Identify stale or conflicting records. * Distinguish empty results from retrieval failures. Expected: Pass ### πŸ”„ PHASE 10: LONG-RUNNING SESSION MANAGEMENT Objective: Maintain continuity across interrupted sessions. Scenario: The user closes the application after completing payment integration halfway. Expected Checkpoint: ```json { "checkpoint_id": "CP-1001", "objective": "Complete SaaS development", "completed_steps": [ "Authentication", "Database integration" ], "pending_steps": [ "Payment integration", "Payment testing" ], "important_decisions": [ "MongoDB selected for this project" ], "constraints": [ "Project deadline: 2026-12-15" ], "last_checkpoint": "2026-11-01T10:00:00+05:30", "recovery_instruction": "Verify payment integration status before continuing." } ``` Recovery Test: When the user returns and asks, "Continue my SaaS project." Expected behavior: * Retrieve the latest valid checkpoint. * Verify its timestamp and status. * Retrieve relevant project memories. * Identify completed and pending tasks. * Resume without repeating completed work. * Ask for clarification if the checkpoint conflicts with newer evidence. Expected: Pass ### πŸ”§ PHASE 11: MEMORY CONSOLIDATION AND UPDATE MANAGEMENT Objective: Handle changing preferences and conflicting information. Test Scenario: Previous memory: "User prefers PostgreSQL." New information: "For my new SaaS project, I have decided to use MongoDB." Incorrect Behavior: Delete PostgreSQL preference and replace it with MongoDB globally. Correct Behavior: | Memory | Status | | ----------------------------- | --------------------- | | PostgreSQL general preference | Historical / Retained | | MongoDB for new SaaS project | Active | | Global database preference | Unresolved | Consolidation Rules: * Preserve historical decisions. * Store the new project-specific decision. * Do not assume global preference changes. * Record source and timestamp. * Require clarification before changing a general preference when necessary. * Maintain version history. Expected: Pass ### πŸ” PHASE 12: MEMORY EXPIRATION, DELETION AND PRIVACY Objective: Prevent unauthorized or unnecessary information retention. | Information | Retention Policy | | -------------------------- | ------------------------------------ | | Python preference | Until updated or deleted | | SaaS project memory | Until project completion and cleanup | | Temporary presentation | Until completed | | API credential | Never persist | | Restaurant recommendation | No storage | | Project checkpoint | Until superseded or expired | | Weekly summary instruction | Until changed | Security Requirements: * Encrypt persistent memory at rest. * Apply user-level authorization. * Enforce tenant isolation. * Exclude credentials from summaries and logs. * Support user-requested memory deletion. * Propagate deletion to derived summaries and search indexes. * Verify deletion across backups according to the configured retention policy. Expected Result: No credential leakage and no cross-user memory exposure. Expected: Pass ### 🚨 PHASE 13: FAILURE DETECTION AND RECOVERY Objective: Test failure handling. | Failure | Detection | Recovery | | ---------------------- | --------------------- | ----------------------------- | | Duplicate memory | Duplicate fingerprint | Merge records | | Wrong summary | Validation failure | Regenerate from source | | Context overflow | Token counter | Reassemble context | | Stale memory | Expiration check | Exclude or refresh | | Conflicting decisions | Conflict detector | Preserve versions | | Database write failure | Transaction error | Bounded retry | | Retrieval failure | Backend error | Retry or report failure | | Missing checkpoint | Checkpoint lookup | Recover from verified history | | Unauthorized access | Permission check | Deny access and log event | | Incomplete deletion | Deletion verification | Retry cleanup and escalate | Critical Test: If the database write fails while saving payment integration progress, the agent must not claim that the checkpoint was successfully saved. Expected: Pass ### πŸ§ͺ PHASE 14: TESTING AND MEMORY QUALITY EVALUATION Objective: Verify memory-management quality. Test Suite: | Test ID | Test Scenario | Expected Result | | ------- | --------------------------------- | --------------- | | AMM-001 | Store Python preference | Pass | | AMM-002 | Reject API credential | Pass | | AMM-003 | Preserve project deadline | Pass | | AMM-004 | Identify temporary presentation | Pass | | AMM-005 | Detect database decision conflict | Pass | | AMM-006 | Preserve pending payment task | Pass | | AMM-007 | Remove unrelated context | Pass | | AMM-008 | Enforce token budget | Pass | | AMM-009 | Retrieve project memories | Pass | | AMM-010 | Restore checkpoint | Pass | | AMM-011 | Prevent cross-user access | Pass | | AMM-012 | Verify deletion | Pass | Measurable Acceptance Criteria: * Critical information retention: 100% on the defined test suite. * Credential persistence: 0 successful admissions. * Cross-tenant leakage: 0. * Context budget violations: 0. * Required task recovery: 100% on valid checkpoint tests. * Duplicate active records: 0 after successful consolidation. Expected: Pass These are target acceptance criteria, not measured execution results. ### ⚑ PHASE 15: PERFORMANCE, COST AND OBSERVABILITY Objective: Define operational monitoring. Required Metrics: | Metric | Purpose | | ------------------------------ | --------------------------- | | Memory admission rate | Track stored candidates | | Memory rejection rate | Track rejected candidates | | Retrieval precision | Measure relevant results | | Critical information retention | Detect information loss | | Summary compression ratio | Measure context reduction | | Tokens per session | Monitor context consumption | | Retrieval latency | Measure retrieval speed | | Summarization latency | Measure summary speed | | Memory write failures | Track storage reliability | | Context overflow frequency | Detect budget problems | | Checkpoint restoration success | Measure continuity | Suggested Logging Format: ```json { "event": "memory_retrieval", "user_id": "USER-001", "query_type": "project_status", "retrieved_count": 4, "filtered_count": 3, "status": "success", "latency_ms": null } ``` Important: Actual latency and cost must be measured through instrumentation. No performance figures should be fabricated. Optimization Recommendations: * Cache frequently accessed stable memories. * Use database indexes. * Avoid unnecessary summarization. * Limit retrieval results. * Batch non-critical memory operations. * Monitor token consumption per session. Expected: Pass ### πŸ† PHASE 16: FINAL AGENT MEMORY MANAGEMENT BLUEPRINT Objective: Deliver the implementation-ready architecture. ### A. Executive Summary Build a memory-management system that stores useful user preferences, tracks SaaS project progress, and maintains continuity across sessions. ### B. Memory Classification Use six practical memory types: * Working * Short-term * Long-term * Episodic * Procedural * Task ### C. Memory Admission Implement: * Importance scoring. * Durability evaluation. * Sensitivity filtering. * Duplicate detection. * Confidence validation. * Explicit update rules. ### D. Summarization Implement a structured summarization pipeline that preserves decisions, deadlines, completed tasks, pending tasks, and unresolved questions. ### E. Context Pruning Prioritize system instructions, active tasks, important decisions, and relevant memories. ### F. Token Budget Enforce the 32,000-token context limit with a 4,000-token retrieval cap. ### G. Retrieval Use metadata filtering, keyword search, task relevance, recency, and confidence. ### H. Long-Session Management Implement checkpoints, session restoration, and recovery validation. ### I. Storage Start with PostgreSQL. Add vector search only when semantic retrieval requirements justify it. ### J. Memory Lifecycle Implement creation, updates, consolidation, expiration, and deletion. ### K. Security Enforce tenant isolation, authorization, credential filtering, and deletion propagation. ### L. Failure Recovery Implement bounded retries, transactional writes, validation, and operational alerts. ### M. Testing Automate memory admission, summarization, retrieval, pruning, security, and recovery tests. ### N. Observability Track token usage, retrieval quality, memory growth, latency, and failure rates. ### O. Implementation Roadmap | Priority | Engineering Task | | -------- | ----------------------------------- | | P0 | Memory schema and access controls | | P0 | Sensitive information filtering | | P0 | Memory admission engine | | P1 | Memory retrieval engine | | P1 | Summarization engine | | P1 | Context token enforcement | | P1 | Conflict detection and versioning | | P2 | Checkpoint and recovery | | P2 | Expiration and deletion propagation | | P2 | Observability dashboard | | P3 | Advanced semantic retrieval | ### P. Final Definition of Done The Agent Memory Manager is ready for production evaluation when: * Memory admission follows defined policies. * Sensitive credentials are rejected. * Important information survives summarization. * Contradictory memories are detected. * Context pruning protects active dependencies. * Token limits are enforced programmatically. * Retrieval returns relevant memories. * Long sessions recover successfully. * Memory deletion is verifiable. * Tenant isolation passes security tests. * Automated test suite meets acceptance criteria. * Monitoring and failure alerts are operational. ### πŸ“‹ FINAL TEST REPORT Agent Memory Manager 16 Phases Evaluated ### 16/16 Expected phase-level evaluation coverage, not actual implementation test results. | Evaluation Area | Expected Outcome | | -------------------------- | ---------------- | | Requirement reconstruction | Pass | | Architecture audit | Pass | | Memory classification | Pass | | Memory admission | Pass | | Schema design | Pass | | Summarization | Pass | | Context pruning | Pass | | Token optimization | Pass | | Memory retrieval | Pass | | Session continuity | Pass | | Memory consolidation | Pass | | Privacy and deletion | Pass | | Failure recovery | Pass | | Testing strategy | Pass | | Observability | Pass | | Final blueprint | Pass | Overall Assessment Architecture Design: StrongProduction Implementation: Not Verified The proposed architecture addresses all 16 phases. Actual production readiness requires code implementation, automated testing, security validation, and performance measurements. Principal Engineer's Final Recommendation: Start with PostgreSQL, structured memory records, deterministic admission rules, and a reliable checkpoint system. Do not introduce unnecessary vector infrastructure or complex memory agents before establishing reliable memory lifecycle management.
Claude

Agent Memory Manager

Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-5-SONNET
Tested icon
Guide icon
4 examples icon
Free credits icon
Design and optimize intelligent memory-management systems for AI agents. This advanced prompt helps developers determine what an AI agent should remember, what it should discard, when conversation history should be summarized, and how context should be maintained across long-running sessions. Memory Selection Memory Classification Memory Summ Designed for developers building AI agents that need reliable context continuity without allowing memory and conversation history to grow uncontrollably.
...more
Added 14 hours ago
Report
Browse Marketplace