mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-06 14:22:47 +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
|
|
@ -607,6 +607,10 @@ def _build_compiled_agent_blocking(
|
|||
model=llm,
|
||||
extra_middleware=subagent_extra_middleware,
|
||||
)
|
||||
logging.info(
|
||||
"Specialized subagents registered for task tool: %s",
|
||||
[s["name"] for s in specialized_subagents],
|
||||
)
|
||||
except Exception as exc: # pragma: no cover - defensive
|
||||
logging.warning(
|
||||
"Specialized subagent build failed; running without them: %s",
|
||||
|
|
|
|||
|
|
@ -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