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
Format prefix_cache_benchmark.py for ruff 0.15 compatibility
chopratejas1474355f1c31
diff --git a/benchmarks/prefix_cache_benchmark.py b/benchmarks/prefix_cache_benchmark.pyindex 519490a07..45b185f09 100644--- a/benchmarks/prefix_cache_benchmark.py+++ b/benchmarks/prefix_cache_benchmark.py@@ -225,12 +225,14 @@ TOOL_RESPONSES = {for i, f in enumerate(["auth", "api", "cache"])]),- "read_file": lambda q: "# File contents (simulated)\nimport logging\nfrom typing import Optional\n\nlogger = logging.getLogger(__name__)\n\n"- + "\n".join(- [- f"def function_{i}(arg: str) -> Optional[dict]:\n \"\"\"Process {q}.\"\"\"\n result = {{}}\n for key in ['id', 'name', 'status']:\n result[key] = f'value_{{key}}_{{arg}}'\n logger.info(f'Processed {{arg}}')\n return result\n"- for i in range(8)- ]+ "read_file": lambda q: (+ "# File contents (simulated)\nimport logging\nfrom typing import Optional\n\nlogger = logging.getLogger(__name__)\n\n"+ + "\n".join(+ [+ f"def function_{i}(arg: str) -> Optional[dict]:\n \"\"\"Process {q}.\"\"\"\n result = {{}}\n for key in ['id', 'name', 'status']:\n result[key] = f'value_{{key}}_{{arg}}'\n logger.info(f'Processed {{arg}}')\n return result\n"+ for i in range(8)+ ]+ )),"query_database": lambda q: json.dumps([