Tasks

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

Complete CRUD operations plus advanced management: read, write, append, delete, flush, health, clear, and stats

Intelligent Session Management

Maintain user sessions and conversation history with automatic token optimization and memory summarization

Context Preservation

Store and retrieve workflow context across executions, enabling stateful AI agents and persistent workflows

Scalable Storage Backends

Support for Redis, in-memory, and custom storage backends with automatic scaling and performance optimization

Memory Health Monitoring

Real-time memory usage monitoring, performance metrics, and automated cleanup with configurable strategies

Multi-Tenant Architecture

Secure memory isolation with hierarchical key patterns supporting complex organizational structures

Memory Task Flow

Memory tasks follow a structured execution pattern that integrates with Compozy's memory management system:

Loading diagram...

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:

Memory Task Structure
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.

Write Operation
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

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