Skip to content

feat(perception): implement memory-first image storage strategy#1

Merged
IcyFeather233 merged 1 commit intoUbiquantAI:mainfrom
TexasOct:main
Dec 22, 2025
Merged

feat(perception): implement memory-first image storage strategy#1
IcyFeather233 merged 1 commit intoUbiquantAI:mainfrom
TexasOct:main

Conversation

@TexasOct
Copy link
Contributor

Implement a memory-first storage strategy to reduce disk I/O and optimize disk usage.

Key Changes:

  • ImageManager: Add memory-first mode with dynamic TTL calculation

    • New methods: persist_image(), persist_images_batch(), cleanup_batch_screenshots()
    • TTL-based cleanup for memory-only images (default: processing_interval * 2.5)
    • Track image metadata (timestamp, is_persisted) for lifecycle management
  • ActionAgent: Trigger persistence only when actions are created

    • Persist screenshots to disk before saving actions
    • Immediate batch cleanup for unused screenshots after action generation
  • Coordinator: Add periodic TTL cleanup in processing loop

  • Config: Add memory-first configuration options

    • enable_memory_first, memory_ttl_multiplier, memory_ttl_min/max

Benefits:

  • Reduce disk writes by ~95% (from 3,600/hour to ~150/hour)
  • Immediate cleanup of unused screenshots (vs. waiting for TTL)
  • Dynamic TTL based on processing_interval for adaptive behavior

Three-tier cleanup mechanism:

  1. Batch cleanup: Remove unused images immediately after action creation
  2. TTL cleanup: Evict expired memory-only images every processing cycle
  3. LRU eviction: Fallback when cache limit (500 images) is reached

Implement a memory-first storage strategy to reduce disk I/O and optimize disk usage.

**Key Changes:**
- ImageManager: Add memory-first mode with dynamic TTL calculation
  - New methods: persist_image(), persist_images_batch(), cleanup_batch_screenshots()
  - TTL-based cleanup for memory-only images (default: processing_interval * 2.5)
  - Track image metadata (timestamp, is_persisted) for lifecycle management

- ActionAgent: Trigger persistence only when actions are created
  - Persist screenshots to disk before saving actions
  - Immediate batch cleanup for unused screenshots after action generation

- Coordinator: Add periodic TTL cleanup in processing loop

- Config: Add memory-first configuration options
  - enable_memory_first, memory_ttl_multiplier, memory_ttl_min/max

**Benefits:**
- Reduce disk writes by ~95% (from 3,600/hour to ~150/hour)
- Immediate cleanup of unused screenshots (vs. waiting for TTL)
- Dynamic TTL based on processing_interval for adaptive behavior

**Three-tier cleanup mechanism:**
1. Batch cleanup: Remove unused images immediately after action creation
2. TTL cleanup: Evict expired memory-only images every processing cycle
3. LRU eviction: Fallback when cache limit (500 images) is reached
@IcyFeather233 IcyFeather233 merged commit cb3d42e into UbiquantAI:main Dec 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants