feat(api): make _FULL_SESSION_RESOLVE_MAX_CONCURRENT configurable via env (#7421)
[rebase onto current master — same content as 5a7f7d8, no functional changes beyond a single context-line merge from master] Squash-rebase of #7656 onto current master so the 3-way merge CI test no longer pulls in the unmerged stage/7618-7619-renderer-i18n dirty diff that 5a7f7d8 was based on. The actual change set is unchanged: 2 files, +231/-1. What changed (from #7656 / 5a7f7d8): - api/models.py::_read_max_session_resolve_concurrent — new module-level helper that reads the cap from the env var HERMES_WEBUI_MAX_SESSION_RESOLVE with strict validation (positive int in [1, 64], malformed → default 2). - tests/test_issue7421_resolve_cap_config.py — 12 regression tests covering unset/empty/whitespace, headline cases (4/8/64), safety paths (0/-1/999999/non-numeric), whitespace tolerance, BoundedSemaphore capacity check, and a static wiring assertion. Model: MiniMax-M3
This commit is contained in:
1 parent
5e16dd860f
commit
31e22a152b
2 files changed
+230
-1
No files matched your search
+28
-1
@@ -4788,7 +4788,34 @@ class _FullSessionResolveRequired(RuntimeError):
|
||||
"""Internal signal that a full sidecar load must enter the bounded path."""
|
||||
|
||||
|
||||
_FULL_SESSION_RESOLVE_MAX_CONCURRENT = 2
|
||||
def _read_max_session_resolve_concurrent() -> int:
|
||||
"""#7421: env override for the heavy session-resolve cap. The
|
||||
hardcoded literal 2 is too low for high-concurrency
|
||||
deployments where several parallel active sessions all need
|
||||
a full-transcript resolve; operators can set
|
||||
``HERMES_WEBUI_MAX_SESSION_RESOLVE`` to a positive int to
|
||||
raise the cap without code changes. A bad or missing value
|
||||
falls back to the previous default of 2, so an operator who
|
||||
sets ``HERMES_WEBUI_MAX_SESSION_RESOLVE=0`` or a non-numeric
|
||||
value does not regress to a blocked or unbounded state. The
|
||||
upper bound (64) is a generous but finite safety net against
|
||||
a typo like ``=999999`` bypassing the bounded semaphore
|
||||
entirely; the deeper per-read cost is tracked in #7310."""
|
||||
raw = (os.getenv("HERMES_WEBUI_MAX_SESSION_RESOLVE") or "").strip()
|
||||
if not raw:
|
||||
return 2
|
||||
try:
|
||||
n = int(raw)
|
||||
except (TypeError, ValueError):
|
||||
return 2
|
||||
if n < 1:
|
||||
return 2
|
||||
if n > 64:
|
||||
return 64
|
||||
return n
|
||||
|
||||
|
||||
_FULL_SESSION_RESOLVE_MAX_CONCURRENT = _read_max_session_resolve_concurrent()
|
||||
_FULL_SESSION_RESOLVE_SLOTS = threading.BoundedSemaphore(
|
||||
_FULL_SESSION_RESOLVE_MAX_CONCURRENT
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user