Skip to content

feat(memory): add force_boundary flag to API to fix bulk import queue stalls#124

Open
GoodDaySolution wants to merge 1 commit intoEverMind-AI:mainfrom
GoodDaySolution:fix-queue-boundary
Open

feat(memory): add force_boundary flag to API to fix bulk import queue stalls#124
GoodDaySolution wants to merge 1 commit intoEverMind-AI:mainfrom
GoodDaySolution:fix-queue-boundary

Conversation

@GoodDaySolution
Copy link

Problem

Third-party clients bulk-importing historical conversation chunks (e.g. Chrome extensions importing scraped chats) frequently observe their messages getting permanently stuck in the sync_status = -1 queue. Because these imports are one-time events, the [ConvMemCellExtractor]'s LLM-based time-gap detection never triggers should_end = True, causing silent failures (empty groups).

Solution

This PR introduces a force_boundary boolean flag to the API layer, allowing clients to explicitly signal that an imported batch is complete and should bypass the LLM should_wait logic.

Changes Included:

  1. [src/api_specs/dtos/memory.py]: Added force_boundary: bool = False to [MemorizeMessageRequest] and [MemorizeRequest] DTOs.
  2. [src/api_specs/request_converter.py]: Updated [convert_simple_message_to_memorize_request] to extract the flag from the JSON payload.
  3. [src/memory_layer/memory_manager.py] & [src/biz_layer/mem_memorize.py]: Threaded the force_boundary parameter down into the MemCell ExtractRequest abstractions.
  4. [src/memory_layer/memcell_extractor/conv_memcell_extractor.py]: Modified [extract_memcell] to intercept the flag:
    if getattr(request, 'force_boundary', False):
        boundary_detection_result = BoundaryDetectionResult(
            should_end=True,
            should_wait=False,
            reasoning="Force boundary requested by client API payload",
            confidence=1.0,
            topic_summary="",
        )
    else:
        # ... fallback to standard LLM detection

How to Test

  1. Send a batch of 5 short messages (under the 50 msg limit) to /api/v0/memories.
  2. On the 5th message payload, attach "force_boundary": true.
  3. Verify that the system immediately writes the MemCell to the database, skipping the accumulation wait period.

Note to Maintainers: I have also noted an issue where /api/v1/ routing fails on the live Cloud Gateway, and strict but silent whitelisting on the source field. Please review if those configurations on the API Gateway are intended.

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.

1 participant