← Back to PRs

#23419: fix(memory): avoid cross-agent qmd embed serialization

by frankekn open 2026-02-22 09:22 View on GitHub →
size: S
## Why A module-global embed queue made all agents share one lock. One agent running `qmd embed` could block every other agent. ## What - move embed queue state from module scope to `QmdMemoryManager` instance scope - keep ordering guarantees within each manager instance - keep behavior unchanged for single-agent runs ## Test - add regression test with two managers (`agent-a`, `agent-b`) - hold embeds in-flight and assert both embeds start concurrently - then release and assert both sync calls complete <!-- greptile_comment --> <h3>Greptile Summary</h3> Moved the `qmd embed` queue lock from module-global scope to per-instance scope in `QmdMemoryManager`. Previously, a single module-level `qmdEmbedQueueTail` variable caused all agent instances to share the same lock, serializing embed operations across different agents. The fix relocates this state to the class instance (`this.qmdEmbedQueueTail`) and makes the lock helper method (`runWithEmbedLock`) a private instance method. This preserves ordering guarantees within each manager instance while allowing concurrent embeds across different agents. The regression test demonstrates the fix by creating two manager instances with different agent IDs, triggering simultaneous forced syncs, and asserting that both embed commands start while the first is in-flight (before the old behavior would have serialized them). <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The change is a straightforward refactor that moves state from module scope to instance scope. The implementation correctly preserves the queue ordering logic while fixing the cross-agent serialization issue. The regression test comprehensively validates the fix by verifying concurrent embeds across separate manager instances. - No files require special attention <sub>Last reviewed commit: 624a17f</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs