Skip to content

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.

fix(proxy): alias nested codex responses routes

JerrettDavis2ceceb402459
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py
index 5574334a1..40d70eb20 100644
--- a/headroom/proxy/server.py
+++ b/headroom/proxy/server.py
@@ -1822,7 +1822,6 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:
async def openai_codex_nested_responses_sub(request: Request, sub_path: str):
"""Passthrough for /backend-api/codex/responses/* sub-endpoints."""
return await openai_responses_sub(request, sub_path)
-
# OpenAI Batch API endpoints (with compression!)
@app.post("/v1/batches")
async def create_batch(request: Request):
diff --git a/tests/test_proxy_codex_route_aliases.py b/tests/test_proxy_codex_route_aliases.py
index cda428fc6..67aacee3a 100644
--- a/tests/test_proxy_codex_route_aliases.py
+++ b/tests/test_proxy_codex_route_aliases.py
@@ -1,17 +1,37 @@
+from fastapi import WebSocket
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from headroom.proxy.server import HeadroomProxy, ProxyConfig, create_app
-def test_backend_api_responses_alias_delegates_to_openai_handler(monkeypatch):
+def test_codex_responses_aliases_delegate_to_openai_handler(monkeypatch):
async def fake_handle(self, request): # type: ignore[no-untyped-def]
return JSONResponse({"ok": True, "path": request.url.path})
monkeypatch.setattr(HeadroomProxy, "handle_openai_responses", fake_handle)
with TestClient(create_app(ProxyConfig())) as client:
- response = client.post("/backend-api/responses", json={"model": "gpt-5.3-codex"})
+ for path in ("/backend-api/responses", "/backend-api/codex/responses"):
+ response = client.post(path, json={"model": "gpt-5.3-codex"})
+ assert response.status_code == 200
+ assert response.json() == {"ok": True, "path": path}
- assert response.status_code == 200
- assert response.json() == {"ok": True, "path": "/backend-api/responses"}
+
+def test_codex_responses_websocket_aliases_delegate_to_openai_handler(monkeypatch):
+ seen_paths: list[str] = []
+
+ async def fake_handle_ws(self, websocket: WebSocket): # type: ignore[no-untyped-def]
+ seen_paths.append(websocket.url.path)
+ await websocket.accept()
+ await websocket.send_json({"ok": True, "path": websocket.url.path})
+ await websocket.close()
+
+ monkeypatch.setattr(HeadroomProxy, "handle_openai_responses_ws", fake_handle_ws)
+
+ with TestClient(create_app(ProxyConfig())) as client:
+ for path in ("/backend-api/responses", "/backend-api/codex/responses"):
+ with client.websocket_connect(path) as websocket:
+ assert websocket.receive_json() == {"ok": True, "path": path}
+
+ assert seen_paths == ["/backend-api/responses", "/backend-api/codex/responses"]