This cheatsheet is a review aid, not a substitute for the module content. Every item here maps to a section in M1–M5. If any line doesn't make sense, read the source section before the exam.
M1 — MSO Foundations
Token rules:
- 1 English word ≈ 1.3 tokens · Non-Latin scripts ≈ 2–3× more · Code ≈ varies widely
- Structured output (JSON) costs tokens per brace, bracket, and colon — budget for it
- Context window = input + output combined — both consume from the same pool
Sampling:
- Temperature: low (0–0.3) for extraction/classification; high (0.7–1) for creative
- Use
temperatureORtop_p— not both temperature=0→ near-deterministic, not perfectly deterministic (hardware float drift persists)
Non-determinism sources: temperature, hardware float, model updates, token budget pressure, caching timing
Model family:
| Model | Use case |
|---|---|
| Haiku 4.5 | High-volume, latency-sensitive, classification |
| Sonnet 5 | Default — balanced capability / cost / latency |
| Opus 5 | Complex reasoning, long-horizon; fails first on eval |
| Fable 5 | Narrative, roleplay, creative generation |
Model selection rule: Start with Sonnet 5. Move to Opus if Sonnet fails eval. Move to Haiku if Sonnet passes but cost/latency fails.
Extended thinking: costs output tokens (budget_tokens cap); enable only when basic mode fails eval; pass thinking blocks back in multi-turn history.
Output modes:
- Streaming → user-facing, real-time output
- Synchronous → pipelines, programmatic processing
- Batches API → non-urgent bulk, 50% cost reduction, 24h window
M2 — Production Prompting, Agents & Tool Use
Prompting diagnosis table:
| Symptom | Missing technique |
|---|---|
| Wrong persona / off-topic | System prompt |
| Instructions confused with data | XML tags |
| Wrong format / model doesn't know "good" | Few-shot examples |
| Inconsistent structure / prose instead of JSON | Output constraints |
System prompt: operator-level, persistent — NOT a security boundary. Authorization must be in application code.
XML tags: wrap user content to prevent confusion with instructions. First-line prompt injection defence.
Few-shot rules: diversity > volume; cover edge cases; format must match production; include negative examples for classification.
Structured output: tool use with tool_choice: {type: "tool", name: "..."} forces guaranteed structured output. Prefill { works for simple schemas.
Tool design: description = routing signal. State when to use, what it returns, required preconditions. Keep under 100 words.
Six-step tool-use loop:
- Send messages + tool defs → 2. Model emits
tool_useblock → 3.stop_reason = "tool_use"→ 4. App receives → 5. App executes tool → 6. App appendstool_result, sends again
stop_reason values:
| stop_reason | Meaning |
|---|---|
end_turn |
Normal completion |
tool_use |
Tool call emitted, waiting for result |
max_tokens |
Truncation — output is incomplete |
stop_sequence |
Hit custom stop sequence |
Context engineering strategies: