Domain 4 — Prompt Engineering & Structured Output
CCA Foundations course · Page 5 of 8 · ← Back to all courses · Weight: 20%. Mark complete at the bottom to advance.
4.1 — Explicit Criteria Over Vague Instructions · Core
- Use categorical inclusion + exclusion lists ("flag X; never flag Y") — not "be conservative".
- False-positive trust cascade: one noisy category undermines trust in accurate ones → disable the bad category first, fix its prompt separately.
- Severity calibration with concrete code examples per level.
4.2 — Few-Shot Prompting · Core
- Show the reasoning, not just the answer.
- 2–4 examples, on ambiguous cases only.
- Five useful types: ambiguous · format · positive-negative · varied-structure · informal.
4.3 — JSON Schemas & Structured Output · Core
- Nullable fields + remove them from
required→ prevents the model fabricating values to satisfy the schema. - Add
"unclear"/"other"enum values for ambiguous cases. - Self-correction fields: extract
stated_totalandcalculated_total, plus aconflict_detectedboolean.
4.5 — Message Batches API · Core
- 50% cost savings, 24-hour window, NO latency SLA, NO multi-turn tools.
custom_idcorrelates requests and enables failure resubmission.- Use the synchronous API if anyone is waiting on the result, or if tool loops are needed.
4.6 — Prompt Chaining & Multi-Instance Review · Core
- Attention dilution beyond ~14 files → split into per-file passes + a cross-file integration pass.
- Pydantic retry only for format/structural errors — NOT when data is simply absent from the source.
⚠ Often-missed — Multi-Instance Verification Architecture (VIP routing) · Gap
- Pass 1 generates; Pass 2 is an independent instance that verifies and outputs a confidence score.
- Route on that score: send / human_review / regenerate.
- Use tiered thresholds per customer segment.
Exam reflexes for Domain 4
- "Absent data causing retry loop" → nullable fields + remove from
required. - "Conflicting / can't-sum totals" → self-correction fields (
calculated_total,conflict_detected). - "High volume, can wait" → Batches API (50% / 24h / no SLA / no tools).
- "Self-review bias" → independent instance, zero prior context.
- "Misrouting" → fix descriptions, not few-shot (Domain 2).