feat(inference): LLM 客户端全异步化(T8 架构审查整改)

- Issue9: client.py 由同步 httpx.Client 全异步化
  - LLMClient Protocol / HttpLLMClient.chat → async;httpx.AsyncClient + asyncio.sleep 退避
  - __enter__/__exit__ → __aenter__/__aexit__(async with 生命周期闭环)
- engine.py chat/chat_structured/_call 全部 async + await
- FakeLLMClient.chat → async;测试用 anyio pytest 插件转换(engine 32 + client 10 用例)
- 同步 inference-engine spec 与 milestone3 review 的 httpx 描述
- 全量 182 passed / 100.00%(987 stmts/252 br)
This commit is contained in:
lhl
2026-08-12 09:50:37 +08:00
parent 1f931228e7
commit 8239a37a99
8 changed files with 161 additions and 111 deletions
@@ -16,7 +16,7 @@
- `implementation-plan.md` 阶段 1.6 要求「LLM Client 抽象化」;`agent-runtime-design.md` §2 将该抽象扩展为完整的推理引擎(统一 LLM 调用入口、降级、重试、Token 管理、Prompt 版本化)
- 当前仓库**尚无任何 LLM 客户端实现**4 个 AgentParser / Impact / Writer / QA)均等待推理引擎基盘
- 技术选型已定:原生 HTTP(不使用 SDK 封装);HTTP 客户端选择 **httpx**pyproject 新增依赖),同步 `Client` 与异步 `AsyncClient` 双支持,配合编排层 asyncio 任务池
- 技术选型已定:原生 HTTP(不使用 SDK 封装);HTTP 客户端选择 **httpx**pyproject 新增依赖),采用**异步 `AsyncClient`**(T8 架构审查整改:由同步 Client 全异步化,适配编排层 asyncio 任务池,退避用 asyncio.sleepasync with 生命周期闭环)
## 2. 目标