-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
status:todoPlanned but not startedPlanned but not started
Description
🔍 发现的问题 / 原始需求描述
适配器层对上游 OpenCode 缺乏并发限制。在高负载或上游延迟突增场景下,适配器层可能积压大量未决的异步任务,导致内存消耗剧增。
🛠️ 详细实施方案
- 涉及文件:
src/opencode_a2a_server/opencode_upstream_client.py - 核心逻辑:
- 在
OpencodeUpstreamClient中引入并发信号量(asyncio.Semaphore)。 - 封装
_dispatch_with_concurrency_limit方法,对所有流式和常规请求生效。
- 在
- 伪代码:
class OpencodeUpstreamClient: def __init__(self, limit: int = 50): self._semaphore = asyncio.Semaphore(limit) async def _call_with_limit(self, ...): async with self._semaphore: return await self._client.post(...)
🧪 回归测试建议
- 编写压力测试脚本,在限制并发数为 5 时发起 10 个以上请求,验证多余请求在队列中排队而非立即失败或内存泄露。
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status:todoPlanned but not startedPlanned but not started