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
"""Gateway turn contract harness and tests (see the spec's section 6).
Contents:
* ``fake_provider`` - scriptable OpenAI/Anthropic upstream (ASGI + uvicorn thread)
* ``fake_gateway`` - a Python "Kong": drives the two-half contract exactly as
the Lua plugin algorithm does, including the redrive loop
* ``redrive_hook_ext`` - a re-driving turn hook shaped like headroom-tool-search
* ``fold_only_hook`` - a stream-safe, fold-only turn hook
* ``samples`` - deterministic conversation/tool builders shared by tests
"""