File Name
gemini/agents/always-on-memory-agent/agent.py
What happened?
Description
The Always-On Memory Agent has two issues that may affect stability and data integrity.
1. Memory crash risk during file ingestion
The ingest_file function reads file content using file_path.read_bytes() before validating the file size.
As a result, large files (e.g. >20MB) may be loaded entirely into memory before the size limit check is performed, potentially causing excessive memory usage, performance degradation, or process crashes.
2. Duplicate memory connections
The store_consolidation function appends memory connections without checking whether the relationship already exists.
When consolidation is executed multiple times for the same memory pair, duplicate entries may be stored in the connections field, resulting in an inflated memory graph and unnecessary storage growth.
Observed Behavior
File ingestion
- Large files are read into memory before size validation.
- Excessive memory consumption may occur for oversized files.
- Agent stability may be affected when processing very large files.
Memory connections
- Repeated consolidation operations can create duplicate relationships.
- The
connections field may contain redundant entries.
- Memory graph data becomes unnecessarily bloated over time.
Expected Behavior
File ingestion
Prompt ingestion should:
- Validate file size before reading file content into memory.
- Skip files larger than 20MB safely.
- Log a warning instead of processing oversized files.
Memory connections
Memory consolidation should:
- Prevent duplicate
(from_id, to_id) relationships.
- Store each connection only once.
- Maintain a clean and deduplicated memory graph.
How to reproduce
Memory ingestion issue
- Create a file larger than 20MB (for example, 50MB).
- Place the file into the monitored
./inbox directory.
- Run the Always-On Memory Agent.
- Observe memory usage while the file is processed.
Duplicate connection issue
- Execute
store_consolidation multiple times using the same source and target memory IDs.
- Inspect the
connections field in the memories table.
- Observe duplicate relationship entries.
Relevant log output
Large file detected during ingestion.
Current behavior:
- File content is read into memory before validation.
- Memory usage increases unnecessarily.
- Oversized files may affect process stability.
Repeated consolidation operations:
Current behavior:
- Duplicate relationships are appended to connections.
- Memory graph grows with redundant entries.
- Storage usage increases over time.
Code of Conduct
File Name
gemini/agents/always-on-memory-agent/agent.pyWhat happened?
Description
The Always-On Memory Agent has two issues that may affect stability and data integrity.
1. Memory crash risk during file ingestion
The
ingest_filefunction reads file content usingfile_path.read_bytes()before validating the file size.As a result, large files (e.g. >20MB) may be loaded entirely into memory before the size limit check is performed, potentially causing excessive memory usage, performance degradation, or process crashes.
2. Duplicate memory connections
The
store_consolidationfunction appends memory connections without checking whether the relationship already exists.When consolidation is executed multiple times for the same memory pair, duplicate entries may be stored in the
connectionsfield, resulting in an inflated memory graph and unnecessary storage growth.Observed Behavior
File ingestion
Memory connections
connectionsfield may contain redundant entries.Expected Behavior
File ingestion
Prompt ingestion should:
Memory connections
Memory consolidation should:
(from_id, to_id)relationships.How to reproduce
Memory ingestion issue
./inboxdirectory.Duplicate connection issue
store_consolidationmultiple times using the same source and target memory IDs.connectionsfield in thememoriestable.Relevant log output
Large file detected during ingestion. Current behavior: - File content is read into memory before validation. - Memory usage increases unnecessarily. - Oversized files may affect process stability. Repeated consolidation operations: Current behavior: - Duplicate relationships are appended to connections. - Memory graph grows with redundant entries. - Storage usage increases over time.Code of Conduct