038: add @RATIONALE/@REJECTED contracts to async C4/C5 modules

5 contracts updated:
  - AsyncNetworkModule (C5): async migration rationale, per-client CSRF cookie rejection
  - AsyncAPIClient (C4): auth lifecycle, cache-hit CSRF refresh
  - AsyncAPIClient.request (C4): string vs dict handling, double-encoding root cause
  - AsyncAPIClient.upload_file (C4): multipart async upload
  - LLMAsyncHttpClient (C4): response.ok -> is_success, module-level httpx singleton
This commit is contained in:
2026-06-05 17:02:30 +03:00
parent fbe0ba122c
commit f731a53c7d
2 changed files with 24 additions and 1 deletions

View File

@@ -7,8 +7,11 @@
# @POST Returns (response text, finish_reason) tuple.
# @SIDE_EFFECT Async HTTP POST to LLM API with optional retry on 429.
# @RATIONALE Async migration of _llm_http.py to use httpx.AsyncClient instead of sync requests.
# Uses asyncio.sleep for 429 backoff instead of time.sleep.
# Uses asyncio.sleep for 429 backoff instead of time.sleep. Module-level httpx client singleton
# for connection reuse. response.ok -> response.is_success for httpx.Response compatibility.
# @REJECTED Keeping sync requests.post — would block async event loop during LLM calls.
# Per-request httpx.AsyncClient — loses connection pooling. response.ok — httpx.Response has no
# .ok attribute (only is_success), causes 'Response' object has no attribute 'ok'.
import asyncio
import os