All notes
9 min read

From M1 to M7: Building AgentOps with Controlled Ablations, Evidence Ledgers, and Live Model Measurements

How we built and measured AgentOps across milestones M1 to M7—from rule and single-shot baselines to a bounded investigation loop, a 79/87 live DeepSeek failure postmortem, 54-run memory ablations, and LangGraph checkpoint recovery.

From Diagnostic Standards to Controlled Engineering (M1–M7)

In Before Building AgentOps: What Makes a Diagnosis Good Enough? and AgentOps at M4, I set out five requirements before writing the agent loop: separate symptoms from root causes, trace every claim back to a verifiable evidence_key, make every tool call narrow down competing hypotheses, distinguish mitigation/verification/remediation, and allow honest UNKNOWN conclusions when evidence is insufficient.

When implementation started, the main engineering temptation was to wire up LangGraph, a vector store, and a complex multi-step prompt all at once. Doing so makes it impossible to answer basic engineering questions:

  • How much of the accuracy comes from the multi-step loop versus simple deterministic threshold rules?
  • Does episodic/semantic memory genuinely improve multi-hop diagnosis, or does it contaminate new incidents with stale or misleading past conclusions?
  • Does migrating a hand-written loop to LangGraph introduce regressions, and how many duplicate tool executions does step-level checkpoint recovery actually save?

In AgentOps, we progressed strictly through M1 $\rightarrow$ M2 $\rightarrow$ M3 $\rightarrow$ M4 $\rightarrow$ M5 $\rightarrow$ M6 $\rightarrow$ M7, introducing one variable per milestone and measuring it against frozen scenario manifests, deterministic cassette replays, and live deepseek-flash (k=3) runs.


1. Engineering & Verification Summary (M0–M7)

All metrics below are reproduced from committed artifacts in evals/baselines/ and immutable live measurements in evals/measurements/. Offline deterministic harness baselines (offline-harness) and live deepseek-flash API measurements are reported in separate tables and never mixed.

DimensionQuantitative MetricVerification / Artifact
Completed Milestones8 / 10 (M0–M7)M0 Skeleton, M1 Simulator & Rule Baseline, M2 Async API/SSE/Postgres, M3 Single-Shot LLM, M4 Investigation Loop, M5 CI Gates/Nightly/OTel, M6 Episodic & Semantic Memory, M7 LangGraph/Checkpoints/HITL
Automated Test Suite123 passed (0 failures)pytest (SQLite unit/integration + real PostgreSQL 16 + Alembic 0001_m2 -> 0002_m6 -> 0003_m7 restart acceptance)
Versioned Eval Scenarios35 scenarios (29 frozen-v1 + 6 m6-v1)SHA-256 locked in frozen-manifest.json (9 holdouts strictly isolated) and m6-manifest.json
Cassette Replay Gate29 / 29 scenarios (0 drift)evals/cassettes/m4-frozen.json verified on every PR via python -m app.eval check
Evidence Citation Safety0.0000 accepted illegal citation rateEnforced across all offline baselines (M3, M4, M6, M7) and all 165 live deepseek-flash runs

2. Step-by-Step Development Workflow (M1–M7)

M1: Scenario Simulator, Read-Only ToolPort, and Rule Baseline (Top-1 = 0.6500)

  • Hexagonal ToolPort: 6 read-only tools (query_metrics, search_logs, get_service_status, get_recent_changes, get_dependency_health, query_db_health) with automatic secret/email/IP redaction (<ip-1>) and <untrusted_data> wrapping.
  • 29 Frozen Scenarios (frozen-v1, 9 Holdouts): Includes single-service faults, red-herring conflicts (cpu-with-disk-herring, db-pool-with-cpu-herring), multi-hop downstream faults (multihop-checkout-payments-pool, multihop-checkout-pricing-dns), 20-line truncated log drill-downs (drilldown-truncated-dns), and healthy/unavailable-telemetry (NOT_A_FAULT / UNKNOWN) cases. The 9 holdout: true scenarios are never inspected when designing rules or prompts.
  • Result: diagnose_with_rules() achieves Top-1 = 0.6500, Top-3 = 0.8000, showing where static priority rules fail (red herrings and cross-service drill-downs).

M2: Async Run Executor, SSE Timeline Streaming, and PostgreSQL Persistence

  • POST /v1/incidents/{id}/runs returns 202 Accepted with Idempotency-Key replay (202 active / 200 terminal) and 409 Conflict on concurrent active runs or archived incidents.
  • GET /v1/runs/{id}/events streams RunEvent rows over SSE with Last-Event-ID resumption; client disconnects do not cancel the background investigation.
  • fail_runs_after_restart() transitions leftover PENDING/RUNNING rows to FAILED(restart) on startup, verified against a real PostgreSQL 16 + Uvicorn subprocess restart test.

M3: Single-Shot Code-Swept LLM Baseline (Top-1 = 0.8500)

  • Removed all root-cause/herring spoilers from incident.title and incident.description across all 29 scenarios (Issue #30).
  • Sweeps all 6 tools across every service in scenario.world.services upfront in code, passes the evidence ledger to LLMPort in a single turn, and validates every cited evidence_key (with at most 1 retry on illegal citations).
  • Result: Offline Top-1 rises from 0.6500 to 0.8500 (+0.2000), but averages 12.90 tool calls per run (up to 33) and still fails drilldown-truncated-dns where the default time window truncates the decisive DNS log line.

M4: Bounded Investigation Loop, ReadOnlyVerifier, and Cassette Replay

  • 5-Stage Loop (investigate()):
    1. Triage (Code): Resolves service and default window [detected_at - 15m, detected_at + 5m].
    2. Hypothesize & Investigate (Model, <= 8 tool calls): Updates HypothesisBoard (PROPOSED / TESTING / LEADING / REJECTED), caches duplicate tool calls without charging budget, and narrows time windows or pivots across services.
    3. ReadOnlyVerifier (0 tool calls): Constructed without a ToolPort reference; verifies citation existence, non-empty supporting evidence, cross-tool corroboration, and absence of unaddressed contradictions.
    4. Graceful Partial Reports: Emits schema-valid TIMED_OUT / BUDGET_EXCEEDED partial reports when limits are hit.
  • Result: Offline harness achieves Top-1 = 1.0000 while cutting average tool calls from 12.90 to 6.17 (-52.2%).

M5: First Live deepseek-flash Measurement — From a 79/87 Failure to 87/87 Completion

  • Initial Live Failure (2026-10-29-deepseek-initial.json, Run 40804677634): On 29 scenarios × k=3 (87 runs/version), M3 completed 84/87 (Top-1 = 0.8333), but M4 failed 79/87 runs (9.2% completion, Top-1 = 0.0000).
  • Root Cause & Contract Repair (2026-10-30-deepseek-repaired.json, Run 40988173433): Diagnostic reproduction (cpu-saturation-checkout, k=3) showed that M4’s prompt omitted the 6 tool input schemas and DiagnosisReport JSON schema (extra="forbid"), which InvestigativeFakeLLM had masked. Injecting the public tool catalog and report contract schemas lifted M4 completion from 8/87 (9.2%) to 87/87 (100.0%), with 0.0000 accepted illegal citations, 48.1% fewer tool calls than M3 (6.69 vs. 12.90), and +20.0 percentage points higher severity accuracy (0.8333 vs. 0.6333).

M6: Evidence-Checked Episodic & Semantic Memory + 54-Run Live 3-Way Ablation

Reporting scope: 54 runs = 6 scenarios × 3 repeats × 3 modes. Top-1, evidence, memory, and tool metrics use only the first repeat (n=6 per mode); only agreement uses all repeats. Semantic memory adds no Top-1 gain; live layer gating enables episodic only.

  • 5-Table Schema (0002_m6): hypotheses, hypothesis_evidence, feedback, memory_items, and memory_recalls, with write-time redact_text, similarity deduplication (>= 0.85), and hybrid 0.65 * vector_cosine + 0.35 * Okapi BM25 ranking weighted by time decay, trust level (CONFIRMED / CANDIDATE / QUARANTINED), and service_version staleness.
  • Citation-Only Feedback (POST /v1/runs/{id}/feedback): verdict="correct" promotes only the run’s produced CANDIDATE memory and recalled memories with cited=true; recalled-but-uncited memories are never promoted.
  • Live deepseek-flash 3-Way Ablation (2026-11-04-deepseek-m6-ablation.json, Run 41819885445, 54 runs on m6-v1):
    • no_memory (Top-1 = 0.5000) $\rightarrow$ episodic (Top-1 = 1.0000, +0.5000) $\rightarrow$ episodic_plus_semantic (Top-1 = 1.0000, evidence_recall = 0.7222, evidence_precision = 0.7778, avg_tool_calls = 5.50).
    • Explicit contamination refusal is 0.0 (0/4 first-repeat cases) for each memory-enabled mode; no-memory is N/A. Correct predictions do not establish explicit refusal.

M7: LangGraph StateGraph Migration, Checkpoint Recovery Experiment, and HITL Approvals

  • Explicit StateGraph (app/agent/langgraph_investigator.py): triage -> recall -> investigate_step <-> tool_dispatch -> verify -> finalize, preserving Top-1 = 1.0000 (top1_delta = 0.0, changed_cases = [], verifier_tool_calls = 0) across all 29 frozen-v1 scenarios.
  • Checkpoint Recovery vs. M2 Restart-Fail (0003_m7, run_checkpoints): Default checkpoint_policy="fail" preserves M2’s RUNNING -> FAILED(restart) behavior; opt-in checkpoint_policy="resume" enables POST /v1/runs/{id}/resume (with row-level locking and conditional status transition) to resume from the latest saved step with 0.00 re-executed tool calls.
  • Human-in-the-Loop Approvals (action_approvals): GET /v1/runs/{id}/approvals and POST /v1/runs/{id}/approve record operator decisions and append RECOMMENDATION_APPROVED / RECOMMENDATION_REJECTED events to the run’s SSE timeline.

3. Quantitative Results Tables

Table 1: Offline Deterministic Harness Baselines (frozen-v1, 29 Scenarios, 9 Holdouts)

Milestone & ModeAgent IdentifierFAULT Top-1FAULT Top-3Evidence RecallEvidence PrecisionVerdict Accuracy (FAULT / NOT_A_FAULT / UNKNOWN)Avg Tool Calls (Max)Accepted Illegal Citations
M1 Rule Baselinerule-baseline0.65000.80000.80000.66270.90 / 0.80 / 1.006.00 (6)0.0000
M3 Single-Shot LLMsingle-shot-llm0.8500 (+0.2000)0.9500 (+0.1500)0.95000.81670.95 / 1.00 / 1.0012.90 (33)0.0000
M4 Hand-Written Loopinvestigation-loop1.0000 (+0.1500)1.0000 (+0.0500)1.00001.00001.00 / 1.00 / 1.006.17 (8, -52.2%)0.0000
M7 LangGraph StateGraphlanggraph-investigator1.0000 (0.0000 vs M4)1.0000 (0.0000 vs M4)1.00001.00001.00 / 1.00 / 1.006.17 (8, Verifier 0)0.0000

Table 2: Live deepseek-flash 29-Scenario No-Memory Measurement (frozen-v1, k=3 = 87 Runs/Version)

Live Version (deepseek-flash, k=3)Completed RunsFAULT Top-1FAULT Top-3Evidence RecallEvidence PrecisionFAULT Severity Accuracyagreement@3Avg Tool Calls (Max)First-Output / Accepted Illegal Citations
M4 Pre-Contract Fix (2026-10-29)8 / 87 (9.2%)0.00000.00000.00000.00000.00000.09206.50 (8)N/A / 0.0000
M3 Single-Shot (2026-10-30)86 / 87 (98.9%)0.85000.93330.93330.72920.63330.977012.90 (33)0.0000 / 0.0000
M4 No-Memory Agent (2026-10-30 Repaired)87 / 87 (100.0%)0.73330.76670.74720.67500.8333 (+0.2000)0.94256.69 (8, -48.1%)0.0230 / 0.0000

Table 3: M6 3-Way Memory Ablation (m6-v1, 6 Scenarios, Offline Baseline + Live deepseek-flash k=3 = 54 Runs)

Ablation Mode (m6-v1 Suite)Offline Harness Top-1 (k=1)Live deepseek-flash Top-1 (k=3, 18 runs/mode)Live agreement@3Live Evidence RecallLive Evidence PrecisionLive memory_recall@kLive memory_citation_precisionContamination / Staleness Refusal (12 runs)Live Avg Tool Calls
no_memory0.3333 (2/6)0.5000 (3/6)0.94440.38890.36110.00001.0000N/A6.17
episodic (+Episodic)0.6667 (+0.3334)1.0000 (6/6, +0.5000)1.00000.6667 (+0.2778)0.6500 (+0.2889)1.00001.00000 / 4 (0.0000)5.67
episodic_plus_semantic (+Episodic +Semantic)1.0000 (+0.6667)1.0000 (6/6, +0.5000)1.00000.7222 (+0.3333)0.7778 (+0.4167)1.00001.00000 / 4 (0.0000)5.50

Table 4: M7 Checkpoint Recovery vs. M2 Restart-Fail Controlled Experiment (5 Scenarios)

Recovery PolicyInterrupted Run Status After RestartResumed Run Completion RateResumed FAULT Top-1Avg Re-Executed Tool CallsAvg Total Tool Executions to Complete
Control: M2 Restart-Fail (checkpoint_policy='fail', default)FAILED (restart) (/resume blocked with 409)0.0000 (requires manual full rerun)N/A (manual rerun: 1.0000)1.008.00
Treatment: M7 Checkpoint Recovery (checkpoint_policy='resume', opt-in)FAILED (restart) $\rightarrow$ RUNNING $\rightarrow$ COMPLETED1.0000 (5 / 5)1.0000 (5 / 5)0.00 (-100%)7.00 (-12.5%)