From 49638ba36ac625051a21d276a78cefb5d389c2a9 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Mon, 12 Oct 2026 19:29:17 -0600 Subject: [PATCH] rag_refresh: retry attach up to 3x (transient 400 while file processes) --- rag_refresh.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rag_refresh.py b/rag_refresh.py index c937c4f..759a282 100644 --- a/rag_refresh.py +++ b/rag_refresh.py @@ -91,7 +91,13 @@ for name in DOCS: print(f"rag_refresh: upload failed for {name}: {e}", file=sys.stderr) continue fid = resp.get("id") - code, _ = api(f"/api/v1/knowledge/{KB_ID}/file/add", {"file_id": fid}) + # attach can 400 transiently right after upload (file still processing) — retry + code = None + for attempt in range(3): + code, _ = api(f"/api/v1/knowledge/{KB_ID}/file/add", {"file_id": fid}) + if code == 200: + break + time.sleep(5 * (attempt + 1)) if code != 200: print(f"rag_refresh: attach failed for {name}: {code}", file=sys.stderr) continue