Memory Tasks
Manage persistent memory storage with read, write, append, and memory management operations
Overview
Memory tasks provide persistent storage capabilities for workflows, enabling data persistence, session management, and context preservation across workflow executions. They integrate seamlessly with Compozy's memory management system to provide scalable, efficient storage for AI-powered applications.
Unlike basic tasks that operate in isolation, memory tasks create persistent state that survives workflow executions, enabling agent-driven applications with conversation history, complex workflow orchestration with shared context, and intelligent caching systems for improved performance.
8 Memory Operations
Intelligent Session Management
Context Preservation
Scalable Storage Backends
Memory Health Monitoring
Multi-Tenant Architecture
Memory Task Flow
Memory tasks follow a structured execution pattern that integrates with Compozy's memory management system:
Task Structure
Here's the essential structure for a memory task, following task configuration patterns. This example demonstrates user profile storage with template expressions for flexible data handling:
id: store-user-data
type: memory
operation: write
memory_ref: user_session
key_template: "user:{{ .workflow.input.user_id }}:profile"
payload:
role: "system"
content: |
User Profile:
Name: {{ .workflow.input.name }}
Email: {{ .workflow.input.email }}
Preferences: {{ .workflow.input.preferences | toJson }}
Created: {{ now | date "2006-01-02 15:04:05" }}
on_success:
next: process-user-data
Memory Operations Reference
Memory tasks support 8 distinct operations, each optimized for specific use cases. These operations integrate with workflow context and support template expressions for dynamic behavior.
id: write-memory
type: memory
operation: write
memory_ref: conversation_memory
key_template: "conversation:{{ .workflow.input.session_id }}:{{ .workflow.input.message_id }}"
payload:
role: "user"
content: "{{ .workflow.input.message }}"
timestamp: "{{ now }}"
metadata:
user_id: "{{ .workflow.input.user_id }}"
session_id: "{{ .workflow.input.session_id }}"
on_success:
next: read-conversation-history
Memory Key Patterns
Memory keys provide hierarchical organization and enable powerful querying patterns. They work with template expressions and configuration templates, memory keys enable sophisticated data organization patterns.
id: user-session-keys
type: memory
operation: write
memory_ref: user_sessions
key_template: "session:{{ .workflow.input.user_id }}:{{ .workflow.input.session_id }}:{{ now | date '2006-01-02' }}"
payload:
role: "system"
content: "Session started"
Best Practices
Design Hierarchical Keys
Implement Strategic TTL
Monitor Memory Health
Choose Optimal Operations
Plan for Scale
Handle Failures Gracefully
Summary
Memory tasks provide powerful persistent storage capabilities that enable stateful workflows, intelligent AI agents, and efficient data caching. They integrate seamlessly with signal tasks for event coordination, parallel processing for scale, wait tasks for synchronization, and aggregate tasks for data consolidation patterns.
For production deployments, consider memory system configuration, security best practices, and performance monitoring to ensure optimal operation at scale.
Next Steps
Parallel Processing
Parallel tasks enable concurrent execution of multiple operations, dramatically improving workflow performance while providing sophisticated control over execution strategies. They're essential for scalable workflows that need to process independent operations simultaneously.
Signal Tasks
Understanding signal tasks for inter-workflow communication and event-driven coordination in Compozy workflows