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.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(codex): skip sockets in session home overlay (#2104)
Rudimar Ronsonic4ddcb93a7ff
diff --git a/headroom/cli/wrap.py b/headroom/cli/wrap.pyindex d3d71d172..369ece852 100644--- a/headroom/cli/wrap.py+++ b/headroom/cli/wrap.py@@ -1505,7 +1505,14 @@ def _codex_session_home_overlay() -> Any:with tempfile.TemporaryDirectory(prefix="headroom-codex-home-") as tmp_dir:session_home = Path(tmp_dir)if source_home.exists():- shutil.copytree(source_home, session_home, dirs_exist_ok=True)+ shutil.copytree(+ source_home,+ session_home,+ dirs_exist_ok=True,+ ignore=lambda directory, names: [+ name for name in names if (Path(directory) / name).is_socket()+ ],+ )os.environ["CODEX_HOME"] = str(session_home)try:diff --git a/tests/test_cli/test_wrap_codex.py b/tests/test_cli/test_wrap_codex.pyindex dd0ffd224..0dea434f5 100644--- a/tests/test_cli/test_wrap_codex.py+++ b/tests/test_cli/test_wrap_codex.py@@ -10,7 +10,9 @@ way a user would from the shell.from __future__ import annotationsimport shutil+import socketimport sqlite3+import sysfrom pathlib import Pathfrom unittest.mock import patch@@ -1081,6 +1083,38 @@ def test_codex_session_home_overlay_seeds_active_home_and_cleans_up(assert auth_file.read_text(encoding="utf-8") == original_auth+ sys.platform == "win32" or not hasattr(socket, "AF_UNIX"),+ reason="requires POSIX Unix domain sockets",+)+def test_codex_session_home_overlay_skips_unix_sockets(+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path+) -> None:+ _set_test_home(monkeypatch, tmp_path)+ codex_home = tmp_path / "custom-codex-home"+ socket_dir = codex_home / "vendor_imports" / "skills" / ".git"+ socket_dir.mkdir(parents=True)+ monkeypatch.setenv("CODEX_HOME", str(codex_home))+ monkeypatch.chdir(codex_home)++ head_file = socket_dir / "HEAD"+ head_file.write_text("ref: refs/heads/main\n", encoding="utf-8")+ socket_file = socket_dir / "fsmonitor--daemon.ipc"+ relative_socket_file = socket_file.relative_to(codex_home)++ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as fsmonitor_socket:+ fsmonitor_socket.bind(str(relative_socket_file))++ with wrap_mod._codex_session_home_overlay() as session_home:+ session_socket_dir = session_home / socket_dir.relative_to(codex_home)+ assert (session_socket_dir / "HEAD").read_text(encoding="utf-8") == (+ "ref: refs/heads/main\n"+ )+ assert not (session_socket_dir / socket_file.name).exists()++ assert socket_file.is_socket()++def test_wrap_codex_launch_uses_session_scoped_codex_home(runner: CliRunner, monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: