SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.18349 · 2026

HiGMem: A Hierarchical and LLM-Guided Memory System for Long-Term Conversational Agents

Fei Tan, Jingyi He, Shuqi Cao

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 0 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2604.18349.json · badge: /api/ran/2604.18349.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
ZeroLoss-Lab/HiGMem canonical (classifier label)
classifier basis: census
8 ran · 0 no recorded run
FunctionStatusWhere it lives
build_category_prompt Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/run_fphm_evaluation.py
code served (permissive licence) · get_code("d1ba486baefb3654")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

class QAObject:
    """Stand-in class for qa parameter with adversarial_answer attribute."""
    def __init__(self):
        self.adversarial_answer = "The adversarial answer option"

ARGS = {
    "category": 5,
    "context": "In the conversation, John mentioned he went to Paris last summer and enjoyed the museums.",
    "question": "Where did John go?",
    "qa": QAObject()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
build_evidence_to_event_map_from_events Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/analyze_recall.py
code served (permissive licence) · get_code("3cfb7d5b2667cf6b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from collections import defaultdict

class MockEvent:
    def __init__(self, turn_note_ids):
        self.turn_note_ids = turn_note_ids

events = {
    'event_1': MockEvent(['turn_1', 'turn_2']),
    'event_2': MockEvent(['turn_2', 'turn_3']),
    'event_3': MockEvent(['turn_1']),
    'event_4': MockEvent(None),
    'event_5': MockEvent([]),
}

ARGS = {
    'events': events,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
infer_sample_id_from_checkpoint Ran
ran, honoured the contract we drafted
ZeroLoss-Lab/HiGMem/analyze_recall.py
code served (permissive licence) · get_code("ce418aef5a4f1b5a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pickle
from pathlib import Path
import tempfile
import os

# Create a temporary checkpoint file with valid pickle data
temp_dir = tempfile.mkdtemp()
checkpoint_path = Path(temp_dir) / "checkpoint.pkl"

# Create saved_state dict with turn_notes
saved_state = {
    'turn_notes': {
        'turn_0': 'note1',
        'turn_1': 'note2',
        'turn_2': 'note3',
    }
}

# Write the checkpoint to a temporary file
with open(checkpoint_path, 'wb') as f:
    pickle.dump(saved_state, f)

# Create turn_count_by_sample dict
# The function matches num_turns (3 in this case) with counts in the dict
turn_count_by_sample = {
    101: 3,
    102: 5,
    103: 2,
}

ARGS = {
    'checkpoint_path': checkpoint_path,
    'turn_count_by_sample': turn_count_by_sample,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_locomo_dataset Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/load_dataset.py
code served (permissive licence) · get_code("921860c7ea653ef0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
from pathlib import Path

# Create a minimal valid LoComo dataset JSON file
dataset_content = {
    "samples": [
        {
            "sample_id": "sample_001",
            "qa": [
                {
                    "question": "What did speaker A say?",
                    "answer": "Speaker A said hello",
                    "evidence": ["session_0:turn_0"],
                    "category": 1,
                    "adversarial_answer": "Something else"
                },
                {
                    "question": "What is mentioned?",
                    "answer": "Not mentioned in the conversation",
                    "evidence": ["session_0:turn_1"],
                    "category": 5
                }
            ],
            "conversation": {
                "speaker_a": "Alice",
                "speaker_b": "Bob",
                "session_0": [
                    {
                        "speaker": "Alice",
                        "dia_id": "session_0:turn_0",
                        "text": "Hello everyone"
                    },
                    {
                        "speaker": "Bob",
                        "dia_id": "session_0:turn_1",
                        "text": "Hi there",
                        "img_url": "http://example.com/image.jpg",
                        "blip_caption": "A nice picture of something"
                    }
                ],
                "session_0_date_time": "2023-01-15 10:30:00"
            },
            "event_summary": {
                "events": {
                    "event_type_1": {
                        "details": ["event detail 1", "event detail 2"]
                    }
                }
            },
            "observation": {
                "observations": {
                    "obs_type_1": {
                        "data": [["obs1", "obs2"], ["obs3", "obs4"]]
                    }
                }
            },
            "session_summary": {
                "session_0": "This session was about greeting each other"
            }
        }
    ]
}

# Create temporary JSON file
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False, encoding='utf-8') as f:
    json.dump(dataset_content["samples"], f)
    temp_file_path = f.name

# Define arguments for the function
ARGS = {
    "file_path": temp_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_conversation Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/load_dataset.py
code served (permissive licence) · get_code("4a1510da2b417c43")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Conversation. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Dict, List

# Construct a valid conv_data dictionary for parse_conversation
conv_data = {
    'speaker_a': 'Alice',
    'speaker_b': 'Bob',
    'session_0': [
        {
            'speaker': 'Alice',
            'dia_id': 'turn_1',
            'text': 'Hello, how are you?',
        },
        {
            'speaker': 'Bob',
            'dia_id': 'turn_2',
            'text': 'I am doing well.',
            'img_url': 'https://example.com/image1.jpg',
            'blip_caption': 'A cat sitting on a couch',
        },
    ],
    'session_0_date_time': '2024-01-15 10:30:00',
    'session_1': [
        {
            'speaker': 'Alice',
            'dia_id': 'turn_3',
            'text': 'That sounds great!',
            'img_url': 'https://example.com/image2.jpg',
            'blip_caption': 'A sunny day at the beach',
        },
        {
            'speaker': 'Bob',
            'dia_id': 'turn_4',
            'text': '',
        },
    ],
    'session_1_date_time': '2024-01-15 11:45:00',
    'session_2': [],
    'session_2_date_time': '2024-01-15 12:00:00',
}

ARGS = {
    'conv_data': conv_data,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Conversation — a Conversation output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conversation output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_session Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/load_dataset.py
code served (permissive licence) · get_code("3701fefb10719e87")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Session. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from typing import Dict, List, Optional, Union
from dataclasses import dataclass

@dataclass
class Turn:
    speaker: str
    dia_id: str
    text: str

@dataclass
class Session:
    session_id: int
    date_time: str
    turns: List[Turn]

def parse_session(session_data: List[dict], session_id: int, date_time: str) -> Session:
    """Parse a single session's data, including turns with images by using their captions."""
    turns = []
    for turn in session_data:
        text = turn.get('text', '')
        if 'img_url' in turn and 'blip_caption' in turn:
            caption_text = f"[Image: {turn['blip_caption']}]"
            if text:
                text = f'{caption_text} {text}'
            else:
                text = caption_text
        turns.append(Turn(speaker=turn['speaker'], dia_id=turn['dia_id'], text=text))
    return Session(session_id=session_id, date_time=date_time, turns=turns)


# Setup code to construct valid arguments
session_data = [
    {
        'speaker': 'user',
        'dia_id': 'turn_001',
        'text': 'Hello, how are you?'
    },
    {
        'speaker': 'assistant',
        'dia_id': 'turn_002',
        'text': 'I am doing well.',
        'img_url': 'https://example.com/image.jpg',
        'blip_caption': 'A cat sitting on a table'
    },
    {
        'speaker': 'user',
        'dia_id': 'turn_003',
        'img_url': 'https://example.com/image2.jpg',
        'blip_caption': 'A dog running in the park'
    }
]

ARGS = {
    'session_data': session_data,
    'session_id': 42,
    'date_time': '2024-01-15 10:30:00'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Session — a Session output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Session output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
retry Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/fphm_core.py
code served (permissive licence) · get_code("3fe5ee16f3f90707")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random
import time
from functools import wraps

def retry(max_tries=10, initial_delay=5, backoff_factor=1.2, max_delay=120, jitter=True):

    def decorator(func):

        @wraps(func)
        def wrapper(self, *args, **kwargs):
            tries = 0
            current_delay = initial_delay
            while tries < max_tries:
                try:
                    return func(self, *args, **kwargs)
                except Exception as e:
                    tries += 1
                    if tries >= max_tries:
                        final_error_message = f'LLM call failed after {max_tries} attempts. Final error: {e}'
                        print(final_error_message)
                        if hasattr(self, 'logger') and self.logger:
                            self.logger.log('llm_retry_failed', {'function': func.__name__, 'max_tries': max_tries, 'error': str(e)})
                        break
                    sleep_time = current_delay
                    if jitter:
                        sleep_time += random.uniform(0, current_delay * 0.25)
                    error_message = f'LLM call failed (attempt {tries}/{max_tries}): {e}. Retrying in {sleep_time:.2f}s...'
                    print(error_message)
                    if hasattr(self, 'logger') and self.logger:
                        self.logger.log('llm_retry_attempt', {'function': func.__name__, 'attempt': tries, 'error': str(e), 'delay': sleep_time})
                    time.sleep(sleep_time)
                    current_delay = min(current_delay * backoff_factor, max_delay)
            return None
        return wrapper
    return decorator


class StubLogger:
    def log(self, event_type, data):
        pass


class StubService:
    def __init__(self, logger=None):
        self.logger = logger

    @retry(max_tries=3, initial_delay=0.1, backoff_factor=1.5, max_delay=1.0, jitter=False)
    def sample_method(self):
        return "success"


ARGS = {
    "max_tries": 3,
    "initial_delay": 0.1,
    "backoff_factor": 1.5,
    "max_delay": 1.0,
    "jitter": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
simple_tokenize Ran
ran; our contract draft was wrong, not the code
ZeroLoss-Lab/HiGMem/utils.py
code served (permissive licence) · get_code("48cea41b09d89a75")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The simple_tokenize function takes a single parameter 'text'
# It converts text to string, lowercases it, replaces punctuation with spaces,
# and splits on whitespace to return a list of tokens

ARGS = {
    "text": "Hello, world! This is a test. How are you?"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 4 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 4 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
load_locomo_dataset 2 other papers
1 dated earlier, 1 later
2502.12110 (2025-02)
A-Mem: Agentic Memory for LLM Agents
2606.07402 (2026-06)
M 3 Exam: Benchmarking Multimodal Memory for Realistic User-Agent Interactions
parse_conversation 2 other papers
1 dated earlier, 1 later
2502.12110 (2025-02)
A-Mem: Agentic Memory for LLM Agents
2606.07402 (2026-06)
M 3 Exam: Benchmarking Multimodal Memory for Realistic User-Agent Interactions
parse_session 2 other papers
1 dated earlier, 1 later
2502.12110 (2025-02)
A-Mem: Agentic Memory for LLM Agents
2606.07402 (2026-06)
M 3 Exam: Benchmarking Multimodal Memory for Realistic User-Agent Interactions
simple_tokenize 1 other paper
1 later
2606.07402 (2026-06)
M 3 Exam: Benchmarking Multimodal Memory for Realistic User-Agent Interactions

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Long-term conversational large language model (LLM) agents require memory systems that can recover relevant evidence from historical interactions without overwhelming the answer stage with irrelevant context. However, existing memory systems, including hierarchical ones, still often rely solely on vector similarity for retrieval. It tends to produce bloated evidence sets: adding many superficially similar dialogue turns yields little additional recall, but lowers retrieval precision, increases answerstage context cost, and makes retrieved memories harder to inspect and manage. To address this, we propose HiGMem (Hierarchical and LLM-Guided Memory System), a two-level event-turn memory system that allows LLMs to use event summaries as semantic anchors to predict which related turns are worth reading. This allows the model to inspect highlevel event summaries first and then focus on a smaller set of potentially useful turns, providing a concise and reliable evidence set through reasoning, while avoiding the retrieval overhead that would be excessively high compared to vector retrieval. On the LoCoMo10 benchmark, HiGMem achieves the best F1 on four of five question categories and improves adversarial F1 from 0.54 to 0.78 over A-Mem, while retrieving an order of magnitude fewer turns. Code is publicly available at https: //github.com/ZeroLoss-Lab/HiGMem.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2604.18349")
get_code_for_paper("2604.18349")
have("2604.18349")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2604.18349.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2604.18349.svg)](https://syntology.ai/paper/2604.18349)

Connect an agent — have() is free.