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
test: wire test dummies to RequestOutcome funnel for batch + copilot-auth paths
chopratejas299d995066c4
diff --git a/tests/test_proxy_copilot_auth_hooks.py b/tests/test_proxy_copilot_auth_hooks.pyindex 0d625bdfe..e2d7714fd 100644--- a/tests/test_proxy_copilot_auth_hooks.py+++ b/tests/test_proxy_copilot_auth_hooks.py@@ -96,10 +96,26 @@ def test_openai_passthrough_applies_copilot_auth(monkeypatch: pytest.MonkeyPatchdef __init__(self) -> None:self.metrics = SimpleNamespace(record_request=self._record_request)self.http_client = SimpleNamespace(request=self._request)+ self.cost_tracker = None+ self._counter = 0async def _record_request(self, **kwargs) -> None: # noqa: ANN003return None+ async def _next_request_id(self) -> str:+ # The passthrough handler now allocates a request_id at end-+ # of-call because it records via ``_record_request_outcome``,+ # which requires one. Pre-refactor the dummy didn't need+ # this method because metrics.record_request was called+ # directly without a request_id.+ self._counter += 1+ return f"req-{self._counter}"++ async def _record_request_outcome(self, outcome) -> None: # noqa: ANN001+ from headroom.proxy.outcome import emit_request_outcome++ await emit_request_outcome(self, outcome)+async def _request(self, **kwargs): # noqa: ANN003seen["request_kwargs"] = kwargsreturn SimpleNamespace(headers={}, content=b"{}", status_code=200)diff --git a/tests/test_proxy_handlers_batch.py b/tests/test_proxy_handlers_batch.pyindex 590c8b14f..700222346 100644--- a/tests/test_proxy_handlers_batch.py+++ b/tests/test_proxy_handlers_batch.py@@ -93,6 +93,14 @@ class DummyBatchHandler(batch_module.BatchHandlerMixin):self._request_counter += 1return f"req-{self._request_counter}"+ async def _record_request_outcome(self, outcome) -> None: # noqa: ANN001+ # Mirror of HeadroomProxy._record_request_outcome for the batch+ # mixin tests. Delegates to the free funnel so the wire shape+ # matches production.+ from headroom.proxy.outcome import emit_request_outcome++ await emit_request_outcome(self, outcome)+async def handle_passthrough(self, request, base_url): # noqa: ANN001, ANN201return {"request": request, "base_url": base_url}