oclaw/runtime/plan_agent_v2/switch.py
oliver 37522f492a feat: plan agent v2, global chat mode, and user-mode v2 flag sync
- Add runtime/plan_agent_v2 package and shims; gateway/direct_loop/WS wiring

- Admin chat: interaction mode and specialist only in user menu; session API stores memory_mode and execution_mode only

- POST /admin/api/chat/user-mode mirrors plan_agent_version to AIA_EXPERT_PLAN_AGENT_V2_ENABLED (v2 to 1, v1 to 0)

- Composer cleanup (hidden mode select, no reasoning toggle in meta bar); tests and _local/system.env.example

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-02 18:41:45 +08:00

35 lines
960 B
Python

from __future__ import annotations
import os
from typing import Any
def _is_truthy(raw: str | None) -> bool:
return str(raw or "").strip().lower() in {"1", "true", "yes", "on"}
def v2_feature_enabled(*, store: Any | None = None) -> bool:
# Default off for shadow path safety.
raw = ""
try:
if store is not None:
raw = str(store.get_setting("AIA_EXPERT_PLAN_AGENT_V2_ENABLED") or "").strip()
except Exception:
raw = ""
if not raw:
raw = str(os.getenv("AIA_EXPERT_PLAN_AGENT_V2_ENABLED") or "").strip()
if not raw:
return False
return _is_truthy(raw)
def should_route_to_v2(*, store: Any | None, interaction_mode: str, force_flag: bool = False) -> bool:
if str(interaction_mode or "").strip().lower() != "expert":
return False
if force_flag:
return True
return v2_feature_enabled(store=store)
__all__ = ["should_route_to_v2", "v2_feature_enabled"]