JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: _StableGitFacts 缓存加上界,堵住每会话一条的累积(issue#5240 残余)
wangmingqi2a6c5528ad5c
diff --git a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.pyindex 8d0006eb9e..93686562a8 100644--- a/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py+++ b/jiuwenswarm/server/runtime/agent_adapter/interface_deep.py@@ -1329,6 +1329,12 @@ class _StableGitFacts:_STABLE_GIT_FACTS: dict[str, _StableGitFacts] = {}_STABLE_GIT_FACTS_LOCK = threading.Lock()+# Cache ceiling: ``project_dir`` is per-session (the session workspace), so the+# key space grows with sessions and an unbounded dict leaks one entry per+# session forever (issue#5240 residual hunt: +100 entries / 2min ≈ 1MB/h).+# FIFO-evict the oldest insert at the cap; a miss only costs re-running the+# six cached git subprocesses, never correctness.+_STABLE_GIT_FACTS_MAX = 1024def _resolve_stable_git_facts(@@ -1383,6 +1389,8 @@ def _resolve_stable_git_facts(head_file=head_file,)with _STABLE_GIT_FACTS_LOCK:+ if len(_STABLE_GIT_FACTS) >= _STABLE_GIT_FACTS_MAX:+ _STABLE_GIT_FACTS.pop(next(iter(_STABLE_GIT_FACTS)), None)_STABLE_GIT_FACTS[cache_key] = factsreturn facts