M9-029M9: Senior ML & AI System DesignLLM Serving, RAG & Agent SysDesignHard
⚡Flashcard Drill➔Mastery:

Design a Long-Horizon Checkpointed Multi-Agent DAG Orchestrator with Saga Compensation

🎯 Active Recall Self-Check (Draft First, Verify After)
Login-free practice tracker: recall core answer, audit pitfalls, and log review status.
Step 1 · Draft your concise answer & assumptions
Step 2 · Check Pitfalls & Follow-up Inquiries
Next: M9-030 →
📐 Mathematical Definition
Statek+1=T(Statek,Effectk),IdemKey=SHA256(RunID∥NodeID∥Step)\text{State}_{k+1} = \mathcal{T}(\text{State}_k, \text{Effect}_k),\quad \text{IdemKey} = \text{SHA256}(\text{RunID} \parallel \text{NodeID} \parallel \text{Step})
⚡ One-Sentence Core Answer
Replace fragile in-memory agent loops with an event-sourced DAG engine featuring durable Postgres/WAL checkpoints, idempotency keys, and Saga rollback handlers.

📌 Key Takeaways

  • •
    L1 Durability Problem: multi-hour DAGs with 40+ tool calls and HITL pauses cannot rely on ephemeral worker RAM
  • •
    L2 Atomic Checkpointing: persist state transitions and tool receipts to durable WAL/Postgres after every super-step for exact resume
  • •
    L2 Idempotency & Sagas: attach deterministic Idempotency-Key to external writes and register reverse compensate() handlers for partial failure rollback
  • •
    L3 Fan-Out/Fan-In Control: bound parallel subagent branches with barrier timeouts, per-branch token budgets, and DLQ replay

📐 Mathematical Derivations

Replay preserves deterministic equivalence: given event log H\mathcal{H}, any step whose IdemKey exists in ledger L\mathcal{L} returns recorded output rir_i without re-executing side effects.

🏭 Production Trade-offs

1) Per-step Postgres checkpointing adds ~15ms overhead, negligible next to multi-second LLM calls; 2) Restrict strict Saga compensators to external-mutation nodes.
⚠️ Common Interview Pitfalls
  • ✕
    Using non-deterministic timestamps or random UUIDs inside replayable DAG transition logic
  • ✕
    Storing raw multi-megabyte tool payloads inline inside state rows instead of S3/blob pointers
🎯 Interviewer Follow-up Inquiries
  • ?
    How do you safely resume a 3-day-old paused workflow after deploying new DAG code or prompts?
  • ?
    How do you prevent parallel fan-out subagents from clobbering shared graph state keys?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

← PreviousM9-028: Design a Billion-Scale Multimodal Video Frame-Level Embedding Search System📋 Back to BankNext →M9-030: Design a Real-Time Flink + Redis Feature Store with Zero Training-Serving Skew