(This section covers deployment-pipeline mechanics specifically; the evaluation-gate design covered in Section 62 is the quality gate that sits inside this pipeline — the two are complementary, not duplicative.)
68.1 AI-Specific CI/CD Pipeline
Code Push → Lint + Unit Tests → Integration Tests
→ Model/Prompt Evaluation (Golden Dataset — see Sections 58/62)
→ Security Scan (sensitive-data leak check)
→ Build Container → Deploy to Staging
→ Staging Smoke Tests → Human Approval Gate
→ Canary Deploy (5%) → Monitor (defined window)
→ Full Rollout → Post-Deploy Verification
68.2 Deployment Strategies Compared
| Strategy | How It Works | Risk Profile | Best For |
|---|---|---|---|
| Blue/Green | Full parallel copy of the environment, instant traffic switch | Low (instant rollback by switching back) | Model version updates |
| Canary | Gradual traffic ramp — 5% → 25% → 50% → 100% | Low (gradual exposure, early detection) | Prompt changes, retrieval config changes |
| Shadow | New version runs in parallel on live traffic but doesn’t serve responses | Zero (no user-facing exposure) | Major architectural changes, validating a new model before any real exposure |
| A/B Testing | Traffic deliberately split between variants, impact measured statistically | Medium (both variants are live and user-facing) | Feature/behavior evaluation where you need a definitive impact measurement, not just safety validation |
68.3 Rollback Procedure
Incident Detected (metric degradation)
│
▼
1. Automated alert fires
2. On-call confirms degradation against dashboard
3. Diagnose: is it a model, prompt, tool, or data issue?
│
├── Model issue → Roll back to previous model version
│ (update serving endpoint / switch model ID)
│
├── Prompt issue → Roll back prompt version
│ (update deployment config to v(N-1))
│
├── Tool issue → Fix tool or disable it
│ (circuit breaker + defined fallback behavior)
│
└── Data issue → Fix the data pipeline
(may not require model/prompt rollback at all)
4. Verify rollback successful (metrics recovering toward baseline)
5. Post-incident review within 24 hours
6. Add the failure pattern to the golden evaluation dataset (closes the loop back to Sections 58/62)
68.4 Container/Artifact Packaging Considerations for AI Systems
| Concern | ML Model Artifact | LLM/Agent Artifact |
|---|---|---|
| What’s packaged | Model weights + inference code + dependencies | Prompt templates + tool definitions + orchestration graph + (optionally) fine-tuned weights or adapter |
| Versioning granularity | One artifact version per model | Composite version (Section 66) — model reference + prompt + tools + graph, each independently pinned |
| Build reproducibility | Pin exact dependency versions, freeze training data snapshot reference | Pin exact model API version (never “latest”), pin prompt file hash, pin tool/service versions |
| Rollback unit | Swap the model artifact | Swap any one of the four components independently |
68.5 Post-Deploy Verification
Post-deploy verification should include, at minimum: a smoke-test suite hitting the live endpoint with a small set of known-good requests to confirm basic health before any real traffic ramp; a check that the deployed version’s metadata (model ID, prompt version, tool versions) matches what was intended to be deployed (catching deployment tooling bugs, not just system bugs); and continuous comparison of canary-cohort metrics against the production baseline cohort for the full canary window before declaring success and proceeding to full rollout.
Interview Q&A — Section 68
Q1: Compare canary deployment and shadow deployment for rolling out a new LLM prompt version. When would you use each? A: Canary deployment exposes a small percentage of real users to the new version and measures real production impact directly — it’s the right default for most prompt changes because it validates against genuine user behavior, which a golden dataset alone can’t fully replicate, while limiting blast radius to a small traffic slice. Shadow deployment runs the new version in parallel on real traffic but never actually serves its output to users, comparing its behavior against the current production version silently — this is the right choice when the change is significant enough that any user-facing risk is unacceptable even at 5% traffic (e.g., a fundamentally different prompt structure, a new tool with unknown failure modes, or anything touching a regulated/high-stakes workflow), since it validates against real production traffic patterns with zero user exposure before committing to any live canary at all.
Q2: An automated alert fires for a quality degradation. Walk through your rollback decision process. A: First, confirm it’s a real degradation and not noise — check the dashboard against the alert threshold and recent trend, not just the single data point that triggered it. Then diagnose which of the four independently-versioned components (model, prompt, tool, data) most plausibly caused it, starting from “what changed most recently” since that’s the highest-likelihood culprit — this is exactly why AgentOps-style independent versioning (Sections 65/66) matters, because it turns this into a quick config diff rather than an open-ended investigation. Roll back only the implicated component, keeping everything else untouched, then verify the metric recovers toward baseline before declaring the incident resolved. Within 24 hours, a post-incident review captures the root cause and, critically, the specific failure pattern gets added to the golden evaluation dataset so the same regression is caught pre-deploy next time — closing the loop back into the CI/CD gate rather than treating the incident as a one-off.