From 2488f2c80078b069b85baef73dbe25119849b3b8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 31 Aug 2026 08:16:01 +0000 Subject: [PATCH] fix(batch_routing): remove dead build_jsonl_body build_jsonl_body had zero callers outside its own test and, unlike its embeddings twin build_embeddings_jsonl_body, was never re-exported from __init__.py -- the real submission path (PgLlmBatchBackend._assemble_payload) builds JSONL lines directly via to_jsonl_line() and never calls it. Remove the hollow function and its dedicated test. Co-Authored-By: Claude Sonnet 5 --- contextual_orchestrator/batch_routing.py | 5 ----- tests/test_batch_routing.py | 9 --------- 2 files changed, 14 deletions(-) diff --git a/contextual_orchestrator/batch_routing.py b/contextual_orchestrator/batch_routing.py index 82ce36600..7c6fceec1 100644 --- a/contextual_orchestrator/batch_routing.py +++ b/contextual_orchestrator/batch_routing.py @@ -427,11 +427,6 @@ def _extract_answer(body: Dict[str, Any]) -> str: return str(message.get("content", "")) -def build_jsonl_body(requests: List[BatchRequest], endpoint: str = "/v1/chat/completions") -> str: - """Serialize batch requests into an OpenAI Batch API JSONL body.""" - return "\n".join(json.dumps(request.to_jsonl_line(endpoint)) for request in requests) - - # --------------------------------------------------------------------------- # Embeddings batch requests / results / backends # --------------------------------------------------------------------------- diff --git a/tests/test_batch_routing.py b/tests/test_batch_routing.py index 3b7cdc52f..72b3c7c3c 100644 --- a/tests/test_batch_routing.py +++ b/tests/test_batch_routing.py @@ -16,7 +16,6 @@ PgLlmBatchEmbeddingBackend, RoutingHints, RoutingPolicy, - build_jsonl_body, cheapest_upstream, ) from contextual_orchestrator.cost_ledger import PriceBook, PriceEntry # noqa: E402 @@ -235,14 +234,6 @@ async def download_results(self, batch_id, endpoint_alias): assert backend.retrieve(job) == [] -def test_build_jsonl_body_uses_openai_batch_line_shape() -> None: - requests = [BatchRequest(messages=[{"role": "user", "content": "hi"}], custom_id="a", model="gpt-x")] - body = build_jsonl_body(requests) - assert '"custom_id": "a"' in body - assert '"url": "/v1/chat/completions"' in body - assert '"method": "POST"' in body - - def test_pg_llm_embedding_batch_preserves_agent_identity() -> None: class _Assembler: def __init__(self) -> None: