Skip to content

[Bug]: Background semantic ingestion crashes/restarts when semantic storage references missing episode_ids #1102

Description

@sscargal

Describe the bug

Reported error - https://github.com/MemMachine/MemMachine/actions/runs/21885425744/job/63179096417

The job is failing because the ingestion process encountered invalid episode_ids for set_id user-b, specifically ['4'], resulting in this error:

ValueError: Failed to retrieve messages. Invalid episode_ids exist for set_id user-b: ['4']
This error is raised in src/memmachine/semantic_memory/semantic_ingestion.py at line 110, when messages cannot be retrieved for the given episode_ids.

Steps to reproduce

Review any Pull Request that failed the test.

Expected behavior

Unit tests should pass.

Environment

  • OS: Mac OS X
  • MemMachine: current commit

Additional context

Proposed fix

Investigate why episode_id '4' is invalid or missing from the episode storage. Check if it's being deleted prematurely or not added correctly.

If an episode was deleted or failed to save, ensure all references to that episode_id are removed or handled gracefully.

You can modify the ingestion logic to skip invalid episode_ids rather than fail entirely.
In src/memmachine/semantic_memory/semantic_ingestion.py, update the _process_single_set method as follows:

# Replace
if len(none_h_ids) != 0:
    raise ValueError(
        "Failed to retrieve messages. Invalid episode_ids exist for set_id "
        f"{set_id}: {none_h_ids}"
    )
# With
if len(none_h_ids) != 0:
    logger.warning(f"Skipping invalid episode_ids for set_id {set_id}: {none_h_ids}")
    raw_messages = [m for m in raw_messages if m is not None]
    # Optionally, mark as ingested or delete references to prevent repeated failures

Additionally, audit your data insertion and deletion routines to prevent inconsistent episode references for set_id user-b.

This change will prevent complete ingestion failure and allow processing of valid messages.

Activity

  1. added theissue type on Feb 11, 2026
  2. jgong commented on Feb 25, 2026

    @jgong
    Contributor

    Hi @o-love , i hit a lot of errors today after set prompt to

    prompt:
      default_org_categories: []
      default_project_categories: []
      default_user_categories:
      - profile_prompt
    

    errors are

    2026-02-24 23:53:49,628 [ERROR] memmachine.semantic_memory.semantic_ingestion - Failed to process set_id mem_user_set_org_MemVerge_1_7e8d0b20c039__producer_id_Mel
    Traceback (most recent call last):
      File "/app/.venv/lib/python3.12/site-packages/memmachine/semantic_memory/semantic_ingestion.py", line 61, in _run
        await self._process_single_set(set_id)
      File "/app/.venv/lib/python3.12/site-packages/memmachine/semantic_memory/semantic_ingestion.py", line 110, in _process_single_set
        raise ValueError(
    ValueError: Failed to retrieve messages. Invalid episode_ids exist for set_id mem_user_set_org_MemVerge_1_7e8d0b20c039__producer_id_Mel: ['2', '4']
    2026-02-24 23:53:49,629 [ERROR] memmachine.semantic_memory.semantic_ingestion - Failed to process set_id mem_user_set_org_MemVerge_1_7e8d0b20c039__producer_id_Sarah
    Traceback (most recent call last):
      File "/app/.venv/lib/python3.12/site-packages/memmachine/semantic_memory/semantic_ingestion.py", line 61, in _run
        await self._process_single_set(set_id)
      File "/app/.venv/lib/python3.12/site-packages/memmachine/semantic_memory/semantic_ingestion.py", line 110, in _process_single_set
        raise ValueError(
    ValueError: Failed to retrieve messages. Invalid episode_ids exist for set_id mem_user_set_org_MemVerge_1_7e8d0b20c039__producer_id_Sarah: ['10', '7', '9']
    
  3. added
    priority: highIssue is urgent or highly impactful. Needs to be addressed as soon as possible.
    on Feb 25, 2026
  4. jgong commented on Feb 25, 2026

    @jgong
    Contributor

    Added priority label since the error can be reproduced after using user level profile prompt.

  5. added 5 commits that reference this issue on Feb 27, 2026
  6. added a commit that references this issue on Feb 28, 2026
  7. added 2 commits that reference this issue on Mar 3, 2026
  8. jgong commented on Mar 3, 2026

    @jgong
    Contributor

    Thank you @o-love for the fix, i don't see this error anymore in my test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: highIssue is urgent or highly impactful. Needs to be addressed as soon as possible.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions