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(mixed-content): do not carve ISO-timestamped log rows as search results (#4463)
HetCreepabbade9b4c76
diff --git a/headroom/transforms/mixed_content.py b/headroom/transforms/mixed_content.pyindex 9c0a398c8..e359ef485 100644--- a/headroom/transforms/mixed_content.py+++ b/headroom/transforms/mixed_content.py@@ -7,6 +7,7 @@ import refrom dataclasses import dataclassfrom .content_detector import ContentType, _is_search_result_line+from .lossless_compaction import _TIMESTAMP_ROW_RE@dataclass@@ -45,7 +46,13 @@ def _is_search_line(line: str) -> bool:Sharing it keeps the splitter carving the same lines the detector claims(#3580); otherwise code in context lines would strand in PLAIN_TEXTsections and reach the prose compressor.++ Timestamped log rows (``2026-09-23T10:05:07Z ...``) match the legacy+ pattern but are never grep output; the detector rejects them (#3736), so+ the splitter must too or it hands them to the lossy search compressor."""+ if _TIMESTAMP_ROW_RE.match(line):+ return Falsereturn bool(_SEARCH_RESULT_PATTERN.match(line)) or _is_search_result_line(line)diff --git a/tests/test_mixed_content_sections.py b/tests/test_mixed_content_sections.pyindex 3d80f75dd..822a530a4 100644--- a/tests/test_mixed_content_sections.py+++ b/tests/test_mixed_content_sections.py@@ -98,3 +98,22 @@ def test_extract_json_block_ignores_delimiters_inside_strings():assert end_line == 3assert block == "\n".join(lines)+++def test_split_does_not_carve_timestamped_log_rows_as_search():+ """Regression (#3736 residual): the detector rejects ISO-timestamped log+ rows as search output; the splitter must not carve them either, while+ real ``path:NN:content`` grep lines still carve.+ """+ logs = [+ "2026-09-23T10:05:07Z worker-1 INFO request handled",+ "2026-09-23T10:05:13Z worker-2 ERROR upstream timeout",+ ]+ content = "\n".join(["Intro text", "```python", "print('x')", "```", *logs])++ assert ContentType.SEARCH_RESULTS not in [+ section.content_type for section in split_into_sections(content)+ ]++ grep = "\n".join(["Intro text", "```python", "print('x')", "```", "src/app.py:10:print('x')"])+ assert split_into_sections(grep)[-1].content_type == ContentType.SEARCH_RESULTS