fix(ai): enforce ollama first for drift governance
This commit is contained in:
@@ -194,14 +194,20 @@ class OpenClawService:
|
||||
|
||||
def _cloud_fallback_allowed_for_alert(self, alert_context: dict | None) -> bool:
|
||||
"""Cloud fallback is allowed after the ordered Ollama lane for alerts."""
|
||||
if alert_context and alert_context.get("allow_cloud_fallback") is False:
|
||||
return False
|
||||
if not self._is_incident_alert_context(alert_context):
|
||||
return True
|
||||
return bool(getattr(settings, "ALERT_AI_ALLOW_CLOUD_FALLBACK", True))
|
||||
|
||||
def _alert_enforces_ollama_first(self, alert_context: dict | None) -> bool:
|
||||
"""Alert cards must try GCP-A/GCP-B/111 before Gemini backup."""
|
||||
"""Alert and AI-governance lanes must try GCP-A/GCP-B/111 before Gemini backup."""
|
||||
return (
|
||||
self._is_incident_alert_context(alert_context)
|
||||
bool(alert_context)
|
||||
and (
|
||||
bool(alert_context.get("enforce_ollama_first"))
|
||||
or self._is_incident_alert_context(alert_context)
|
||||
)
|
||||
and bool(getattr(settings, "ALERT_AI_ENFORCE_OLLAMA_FIRST", True))
|
||||
)
|
||||
|
||||
@@ -1144,9 +1150,12 @@ class OpenClawService:
|
||||
exec_context = dict(alert_context) if alert_context else {}
|
||||
if decision.intent == IntentType.DIAGNOSE:
|
||||
exec_context["task_type"] = "diagnose"
|
||||
if self._is_incident_alert_context(alert_context):
|
||||
exec_context["ollama_model"] = getattr(settings, "ALERT_OLLAMA_MODEL", "qwen3:14b")
|
||||
exec_context["allow_gcp_heavy_model"] = True
|
||||
if self._alert_enforces_ollama_first(alert_context):
|
||||
exec_context.setdefault("task_type", "diagnose")
|
||||
exec_context.setdefault("ollama_model", getattr(settings, "ALERT_OLLAMA_MODEL", "qwen3:14b"))
|
||||
exec_context["allow_gcp_heavy_model"] = bool(
|
||||
exec_context.get("allow_gcp_heavy_model", True)
|
||||
)
|
||||
exec_context["alert_requires_ollama_before_cloud"] = True
|
||||
|
||||
result = await executor.execute(
|
||||
|
||||
Reference in New Issue
Block a user