mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-08 07:12:39 +02:00
Fix stale feature flags cache so specialized subagents respect env.
This commit is contained in:
parent
bf9b606a61
commit
3908131105
2 changed files with 13 additions and 14 deletions
|
|
@ -172,24 +172,19 @@ class AgentFeatureFlags:
|
|||
)
|
||||
|
||||
|
||||
# Module-level cache. Read once at import time so the values are consistent
|
||||
# across the process lifetime. Use ``reload_for_tests`` to reset in tests.
|
||||
_FLAGS: AgentFeatureFlags | None = None
|
||||
|
||||
|
||||
def get_flags() -> AgentFeatureFlags:
|
||||
"""Return the resolved feature-flag state, caching on first call."""
|
||||
global _FLAGS
|
||||
if _FLAGS is None:
|
||||
_FLAGS = AgentFeatureFlags.from_env()
|
||||
return _FLAGS
|
||||
"""Return the resolved feature-flag state from the **current** process environment.
|
||||
|
||||
Intentionally **not** cached: ``load_dotenv`` and operator edits to env vars
|
||||
must affect the next agent build without requiring a full process restart.
|
||||
Cost is negligible (reads ``os.environ`` once per call).
|
||||
"""
|
||||
return AgentFeatureFlags.from_env()
|
||||
|
||||
|
||||
def reload_for_tests() -> AgentFeatureFlags:
|
||||
"""Force a fresh read from env. Tests should call this after monkeypatching env."""
|
||||
global _FLAGS
|
||||
_FLAGS = AgentFeatureFlags.from_env()
|
||||
return _FLAGS
|
||||
"""Compatibility helper for tests; equivalent to :func:`get_flags`."""
|
||||
return AgentFeatureFlags.from_env()
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue