[Bug] Concurrent VLM calls during multi-session memory extraction cause 429 rate-limit errors
Bug Description
When multiple sessions commit simultaneously, OV triggers parallel memory extraction for each session. Each extraction spawns 3 concurrent VLM calls (summary + long-term + execution). With multiple sessions committing at once, this produces a burst of VLM API calls that exceeds rate limits.
The vlm.max_concurrent config only controls the semantic queue worker concurrency — it does not throttle memory extraction VLM calls.
Impact
In a multi-agent Hermes deployment with 20 profiles:
- Multiple sessions commit within seconds of each other
- Each commit triggers 3 parallel VLM calls
- VLM API (GLM-4.7) returns 429 rate-limit errors
- Failed extractions produce
.failed.jsonfiles - Memories are silently lost — the session is marked as processed but extraction failed
Reproduction
- Deploy OV with 3+ active sessions
- Trigger commits on all sessions simultaneously (e.g., after a batch of conversations)
- Observe VLM 429 errors in logs
- Check for
.failed.jsonfiles in the data directory
Workaround Applied
We patched OV source code to add a global asyncio Semaphore(1) around VLM calls in vlm/base.py and openai_vlm.py. This serializes all VLM calls system-wide, preventing rate-limit errors but significantly slowing memory extraction throughput.
The proper fix would be to:
- Apply
vlm.max_concurrentto memory extraction calls (not just semantic queue) - Add retry-with-backoff for 429 responses
- Queue extractions instead of spawning concurrent tasks per session
Environment
- OpenViking: 0.4.5+
- VLM: GLM-4.7 (via zai coding endpoint)
- Multi-agent: 20 Hermes profiles, ~10 active sessions at peak
- Observed: 6
.failed.jsonfiles in a single day before patch
wyl1988 你好,我们在多 agent Hermes 部署上也遇到了几乎一样的问题。
我们团队(果核科技)同样在跑多 agent Hermes + OpenViking 的方案。你们 20 个 profile、每个 commit 触发 3 路并行 VLM 的场景我们踩过完全一样的坑。
我们目前的做法
和你们的 Semaphore(1) 方案思路一致,但我们在上游加了一层调度层面的记忆写入归并:
- 统一记忆写入入口:所有 agent 的 session commit 不直接触发 OV 的 VLM extraction,而是先写入一个共享记忆队列
- 独立 extraction worker:一个单独的 worker 进程消费队列,合并同一时间窗口的 extraction 请求,做 batch + 去重后再触发 VLM
- 结果回写:提取后的结构化记忆写回共享知识层,各 agent 从共享层检索
这样做的额外好处是绕过了 OV 当前 peer 级记忆隔离的限制——所有 agent 共享同一份 extracted knowledge,而不需要在每个 peer 下重复存储。
代码层面
如果不改架构只想快速止血,我们也做了信号量限流加指数退避重试,和你们的思路一致。
import asyncio
_semaphore = asyncio.Semaphore(3)
async def _call_with_retry(fn, max_retries=3, base_delay=1):
for attempt in range(max_retries):
try:
async with _semaphore:
return await fn()
except RateLimitError:
if attempt < max_retries - 1:
delay = base_delay * (2 ** attempt)
await asyncio.sleep(delay)
else:
raise
长期方向
我们觉得根本问题不在限流,而在于 OV 的 VLM extraction 模型设计——extraction 应该是异步批处理,不应该和 session commit 同步绑定。
我们团队专注 AI agent 架构,有兴趣的话可以进一步交流。你们在 Hermes 多 agent 场景下还有遇到什么其他踩坑点吗?
果核科技 — AI agent 架构 & 自动化方案
Data point and a triage question from the original reporter.
Status on our side: we have been running the workaround described in the report since July — a local rate-limiting proxy in front of the VLM endpoint, plus vlm.max_concurrent=2 in the server config — and extraction has been stable since. So there is no urgency from our deployment.
The root cause here (bulk extraction racing interactive work into the shared VLM/embedding endpoint until it 429s) looks like the scheduling half of the problem now tracked in #4578, where an admission-control slice is under active discussion. @qin-ctx @chenjw would you prefer to keep this issue open as the "VLM 429" face of that scheduling work, or close it as a duplicate of #4578? Either works for us — flagging the overlap mainly so the concurrency angle isn't lost when the queue-scheduling design lands.