Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

refactor(memory): deprecate the never-wired agent memory writers (#4101)

Tejas Chopra2e497cbec3c2
diff --git a/headroom/memory/writers/__init__.py b/headroom/memory/writers/__init__.py
index a6f88e7df..ebf54415e 100644
--- a/headroom/memory/writers/__init__.py
+++ b/headroom/memory/writers/__init__.py
@@ -14,14 +14,28 @@ Supported agents:
- Aider: Convention files referenced in .aider.conf.yml
- Gemini: GEMINI.md
- Generic: Plain markdown (any agent)
+
+.. deprecated::
+ Nothing in Headroom uses these writers. ``headroom learn`` writes agent
+ context files through ``headroom.learn.writer`` instead.
"""
+import warnings
+
from headroom.memory.writers.base import AgentWriter, ExportResult, MemoryEntry
from headroom.memory.writers.claude_writer import ClaudeCodeMemoryWriter
from headroom.memory.writers.codex_writer import CodexMemoryWriter
from headroom.memory.writers.cursor_writer import CursorMemoryWriter
from headroom.memory.writers.generic_writer import GenericMemoryWriter
+warnings.warn(
+ "headroom.memory.writers is deprecated and will be removed in a future release; "
+ "it has no replacement (headroom learn writes agent context files through "
+ "headroom.learn.writer).",
+ DeprecationWarning,
+ stacklevel=2,
+)
+
__all__ = [
"AgentWriter",
"ClaudeCodeMemoryWriter",
diff --git a/tests/test_memory/test_writers.py b/tests/test_memory/test_writers.py
index fae5f856f..a864f3deb 100644
--- a/tests/test_memory/test_writers.py
+++ b/tests/test_memory/test_writers.py
@@ -3,6 +3,8 @@
from __future__ import annotations
import asyncio
+import importlib
+import sys
import time
from datetime import datetime, timezone
from pathlib import Path
@@ -22,6 +24,18 @@ from headroom.memory.writers.codex_writer import CodexMemoryWriter
from headroom.memory.writers.cursor_writer import CursorMemoryWriter
from headroom.memory.writers.generic_writer import GenericMemoryWriter
+
+def test_importing_the_writers_package_warns_deprecated(monkeypatch: pytest.MonkeyPatch) -> None:
+ # Restore both the sys.modules entry and the parent attribute afterwards, so
+ # later tests see the original package object whatever the import form.
+ import headroom.memory
+
+ monkeypatch.delitem(sys.modules, "headroom.memory.writers", raising=False)
+ monkeypatch.delattr(headroom.memory, "writers", raising=False)
+ with pytest.warns(DeprecationWarning, match="headroom.memory.writers is deprecated"):
+ importlib.import_module("headroom.memory.writers")
+
+
# =============================================================================
# Test Data
# =============================================================================