a2a-source-edit: write agent.py
This commit is contained in:
2
agent.py
2
agent.py
@@ -164,7 +164,7 @@ def build_hypotheses(title: str, symptoms: list[str], services: list[str], evide
|
||||
if any(t in blob for t in ["sync", "argocd", "drift"]): out.append(_make_hypothesis("Declared and live state diverged through Argo CD drift or failed sync.", .62, refs, ["Read Argo sync status"], len(out) + 1))
|
||||
if any(t in blob for t in ["500", "5xx", "latency", "timeout", "errors"]): out.append(_make_hypothesis("User-visible service path is failing or degraded under load.", .58, refs, ["Run health checks", "Query allowlisted metrics"], len(out) + 1))
|
||||
if not out: out.append(_make_hypothesis("Evidence is insufficient for a single root cause; continue scoped evidence collection.", .35, refs, ["Collect Kubernetes, health, and metric evidence"], 1))
|
||||
return sorted(out, key=lambda h: h.confidence, reverse=True)
|
||||
return sorted(out, key=attrgetter("confidence"), reverse=True)
|
||||
def build_timeline(started_at: str, evidence: list[EvidenceEnvelope], title: str) -> list[TimelineEntry]: return [TimelineEntry(at=started_at or _now(), source="intake", description=title)] + [TimelineEntry(at=e.observed_at, source=e.source, description=e.summary[:500], evidence_refs=[e.id]) for e in evidence[:30]]
|
||||
def recommend_actions(h: list[Hypothesis]) -> list[str]: return ["Preserve evidence dossier before any mutation", "Run verification against user-visible health checks and metrics"] + (["Prepare a rollback plan for the named Deployment after operator approval"] if any("crashing container" in x.statement for x in h) else [])
|
||||
def _diagnosis_markdown(d: IncidentDiagnosis) -> str: return f"# Incident {d.incident_id} Diagnosis\n\nStatus: {d.status}\nRoot cause: {d.likely_root_cause or 'Inconclusive'}\n"
|
||||
|
||||
Reference in New Issue
Block a user