From a3802324b87970e693e009d2cf6162a6cd433206 Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Fri, 3 Jul 2026 19:17:49 -0700 Subject: [PATCH] =?UTF-8?q?fix(cache):=20tolerate=20list=20bodies=20from?= =?UTF-8?q?=20JSON-RPC=20batch=20=E2=80=94=20save=5Fto=5Fcache=20crashed?= =?UTF-8?q?=20post-payment=20on=20rpc=5Fbatch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blockrun_llm/cache.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blockrun_llm/cache.py b/blockrun_llm/cache.py index 4c3671c..a64ae4f 100644 --- a/blockrun_llm/cache.py +++ b/blockrun_llm/cache.py @@ -123,6 +123,9 @@ def _readable_filename(endpoint: str, body: Dict[str, Any]) -> str: elif "/v1/image" in endpoint: ep = "image" + if not isinstance(body, dict): + # JSON-RPC batch requests send a list body — no labelable fields. + body = {} label = ( body.get("query") or body.get("username") @@ -178,7 +181,7 @@ def save_to_cache( _append_cost_log( endpoint, cost_usd, - model=model or body.get("model"), + model=model or (body.get("model") if isinstance(body, dict) else None), wallet=wallet, network=network, client_kind=client_kind,