<map version="1.0.1">
<node ID="ID_1335" TEXT="Chapter 3 — Model selection, cost optimisation, prompt and context engineering"><richcontent TYPE="NOTE"><html><head></head><body><p>2026-09-21 → 2026-09-27</p><p>Model Selection &amp; Optimisation · Prompt &amp; Context Engineering</p></body></html></richcontent><node ID="ID_980" TEXT="🎯 Goal"><richcontent TYPE="NOTE"><html><head></head><body><p>Pick the right model and the cheapest configuration for a workload, and write prompts the Anthropic way. This chapter is ~28% of the exam.</p></body></html></richcontent></node><node ID="ID_983" TEXT="Exam domains"><node ID="ID_981" TEXT="Model Selection &amp; Optimisation — 16.8%"></node><node ID="ID_982" TEXT="Prompt &amp; Context Engineering — 11%"></node></node><node ID="ID_1068" TEXT="📅 Daily plan"><node ID="ID_995" TEXT="09-21 · Model family: Opus / Sonnet / Haiku trade-offs, context window, mod…"><node ID="ID_984" TEXT="Learn: Model family: Opus / Sonnet / Haiku trade-offs, context window, model IDs vs aliases, deprecations"></node><node ID="ID_989" TEXT="Build: Run one task on three models; table of latency, tokens, cost"><node ID="ID_985" TEXT="Copy the current model table (name, ID, alias, context window, max output, price in/out) into notes/models-prompting.md."></node><node ID="ID_986" TEXT="ch3/compare.py: run the same 5 prompts (a classification, an extraction, a code fix, a summary, a reasoning puzzle) on Haiku, Sonnet, Opus; record latency, tokens, cost via your cost() helper."></node><node ID="ID_987" TEXT="Mark which tasks Haiku got right — that is your evidence for 'smallest model that passes'."></node><node ID="ID_988" TEXT="Read the deprecation policy: how much notice, what happens to a retired ID."></node></node><node ID="ID_990" TEXT="✔ Done when: A 5×3 table with cost and correctness; you can state each tier's sweet spot."></node><node ID="ID_994" TEXT="Read"><node ID="ID_991" TEXT="Models overview" LINK="https://docs.claude.com/en/docs/about-claude/models/overview"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/about-claude/models/overview</p></body></html></richcontent></node><node ID="ID_992" TEXT="Choosing a model" LINK="https://docs.claude.com/en/docs/about-claude/models/choosing-a-model"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/about-claude/models/choosing-a-model</p></body></html></richcontent></node><node ID="ID_993" TEXT="Model deprecations" LINK="https://docs.claude.com/en/docs/about-claude/model-deprecations"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/about-claude/model-deprecations</p></body></html></richcontent></node></node></node><node ID="ID_1006" TEXT="09-22 · Cost: token counting endpoint, pricing per model, the optimisation …"><node ID="ID_996" TEXT="Learn: Cost: token counting endpoint, pricing per model, the optimisation order (prompt → cache → batch → smaller model)"></node><node ID="ID_1001" TEXT="Build: Build a cost calculator script"><node ID="ID_997" TEXT="Call client.messages.count_tokens(model, system, messages, tools) and compare to the usage of the real call."></node><node ID="ID_998" TEXT="ch3/cost.py: given model, input, output, cache read/write tokens and batch flag → USD. Cover the 1h-TTL write multiplier."></node><node ID="ID_999" TEXT="Model a workload: 10k calls/day, 3k-token stable prefix, 200-token question, 300-token answer. Compute cost for: baseline Sonnet; + caching; + Haiku; + batch. Put the four numbers in notes."></node><node ID="ID_1000" TEXT="Write the optimisation ladder in your own words with one sentence on why each rung comes before the next."></node></node><node ID="ID_1002" TEXT="✔ Done when: Calculator matches the pricing page; the four-scenario table shows caching and model choice dominate."></node><node ID="ID_1005" TEXT="Read"><node ID="ID_1003" TEXT="Token counting" LINK="https://docs.claude.com/en/docs/build-with-claude/token-counting"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/token-counting</p></body></html></richcontent></node><node ID="ID_1004" TEXT="Pricing" LINK="https://docs.claude.com/en/docs/about-claude/pricing"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/about-claude/pricing</p></body></html></richcontent></node></node></node><node ID="ID_1020" TEXT="09-23 · Prompt engineering: clear instructions, examples, XML tags, role in…"><node ID="ID_1007" TEXT="Learn: Prompt engineering: clear instructions, examples, XML tags, role in system prompt, output format"></node><node ID="ID_1012" TEXT="Build: Rewrite a weak prompt three ways; compare"><node ID="ID_1008" TEXT="Take a weak prompt from your dev project ('summarise this log'). Version 1: clear and direct with success criteria and audience. Version 2: add 2 few-shot examples in &lt;example&gt; tags. Version 3: add a role in system and an &lt;output_format&gt;."></node><node ID="ID_1009" TEXT="Run each 5 times at temperature 0.7 on Sonnet; score consistency and usefulness."></node><node ID="ID_1010" TEXT="Try the Console Workbench prompt improver / generator on version 1 and diff what it added."></node><node ID="ID_1011" TEXT="Record which technique gave the biggest jump — usually clarity, then examples."></node></node><node ID="ID_1013" TEXT="✔ Done when: Three versions committed with a short scored comparison; you can recite Anthropic's technique order."></node><node ID="ID_1019" TEXT="Read"><node ID="ID_1014" TEXT="Prompt engineering overview" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/overview"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/overview</p></body></html></richcontent></node><node ID="ID_1015" TEXT="Be clear and direct" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/be-clear-and-direct"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/be-clear-and-direct</p></body></html></richcontent></node><node ID="ID_1016" TEXT="Use examples (multishot)" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/multishot-prompting"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/multishot-prompting</p></body></html></richcontent></node><node ID="ID_1017" TEXT="Use XML tags" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/use-xml-tags</p></body></html></richcontent></node><node ID="ID_1018" TEXT="System prompts / role" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/system-prompts"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/system-prompts</p></body></html></richcontent></node></node></node><node ID="ID_1032" TEXT="09-24 · Extended thinking (manual budget_tokens vs adaptive + effort): when…"><node ID="ID_1021" TEXT="Learn: Extended thinking (manual budget_tokens vs adaptive + effort): when it helps, cost; chain-of-thought prompts"></node><node ID="ID_1026" TEXT="Build: Compare thinking on and off on a reasoning task"><node ID="ID_1022" TEXT="Pick a multi-step task (plan a zero-downtime DB migration with constraints). On Haiku 4.5 run with thinking={type:&quot;enabled&quot;, budget_tokens:4000} and without; on Sonnet 5 run thinking={type:&quot;adaptive&quot;} with output_config effort low vs high. Compare quality, output tokens, cost, latency."></node><node ID="ID_1023" TEXT="Read the thinking block in content; note it is billed as output and that budget_tokens must be &lt; max_tokens."></node><node ID="ID_1024" TEXT="Try the same with a prompt-only chain of thought ('Think step by step inside &lt;thinking&gt; tags, then answer in &lt;answer&gt;') on a model without thinking on."></node><node ID="ID_1025" TEXT="Note the incompatibilities: no prefill with thinking; temperature fixed at 1 with thinking; tool use works but requires passing thinking blocks back."></node></node><node ID="ID_1027" TEXT="✔ Done when: You can say when thinking pays for itself (multi-step reasoning, maths, planning) and when it is waste (lookups, classification)."></node><node ID="ID_1031" TEXT="Read"><node ID="ID_1028" TEXT="Extended thinking" LINK="https://docs.claude.com/en/docs/build-with-claude/extended-thinking"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/extended-thinking</p></body></html></richcontent></node><node ID="ID_1029" TEXT="Let Claude think (chain of thought)" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/chain-of-thought"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/chain-of-thought</p></body></html></richcontent></node><node ID="ID_1030" TEXT="Effort parameter (where supported)" LINK="https://docs.claude.com/en/docs/build-with-claude/effort"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/effort</p></body></html></richcontent></node></node></node><node ID="ID_1045" TEXT="09-25 · Context engineering: window management, summarisation, what goes in…"><node ID="ID_1033" TEXT="Learn: Context engineering: window management, summarisation, what goes in system vs user, long-context tips (docs first, question last)"></node><node ID="ID_1038" TEXT="Build: Add conversation summarisation to chat.py past N tokens"><node ID="ID_1034" TEXT="In chat.py, count tokens before each call; when history exceeds N, ask Haiku to summarise the older turns into one assistant/user pair and keep the last 4 turns verbatim."></node><node ID="ID_1035" TEXT="Test a 30-turn conversation; watch input tokens plateau instead of climbing."></node><node ID="ID_1036" TEXT="Long-doc experiment: put a 40-page PDF text in &lt;document&gt; tags at the top with the question at the bottom, and ask Claude to quote relevant passages in &lt;quotes&gt; before answering. Compare with question-first."></node><node ID="ID_1037" TEXT="Write the 'what lives where' rule: system = role, rules, stable reference (cached); user = task, data, question; assistant = prefill."></node></node><node ID="ID_1039" TEXT="✔ Done when: Summarisation kicks in automatically and quality holds; the long-doc experiment shows why docs go first."></node><node ID="ID_1044" TEXT="Read"><node ID="ID_1040" TEXT="Context windows" LINK="https://docs.claude.com/en/docs/build-with-claude/context-windows"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/context-windows</p></body></html></richcontent></node><node ID="ID_1041" TEXT="Long context tips" LINK="https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/long-context-tips"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/prompt-engineering/long-context-tips</p></body></html></richcontent></node><node ID="ID_1042" TEXT="Context editing / compaction (where available)" LINK="https://docs.claude.com/en/docs/build-with-claude/context-editing"><richcontent TYPE="NOTE"><html><head></head><body><p>https://docs.claude.com/en/docs/build-with-claude/context-editing</p></body></html></richcontent></node><node ID="ID_1043" TEXT="Effective context engineering (Anthropic engineering blog)" LINK="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents"><richcontent TYPE="NOTE"><html><head></head><body><p>https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents</p></body></html></richcontent></node></node></node><node ID="ID_1058" TEXT="09-26 · Academy modules on prompting; Console Workbench prompt improver"><node ID="ID_1046" TEXT="Learn: Academy modules on prompting; Console Workbench prompt improver"></node><node ID="ID_1050" TEXT="Build: Build a 'which model when' decision sheet"><node ID="ID_1047" TEXT="Complete the prompting modules and quizzes."></node><node ID="ID_1048" TEXT="Build a one-page decision sheet: workload → model → optimisations → why. Cover at least: high-volume classification, customer chat, code review agent, legal document analysis, batch summarisation, real-time voice-ish latency."></node><node ID="ID_1049" TEXT="Add a second sheet: 'symptom → fix' (too expensive, too slow, inconsistent format, hallucinating, truncated)."></node></node><node ID="ID_1051" TEXT="✔ Done when: Both sheets in notes; each row names a model, a technique and a reason."></node><node ID="ID_1057" TEXT="Read"><node ID="ID_1052" TEXT="Course: Claude Platform 101" LINK="https://academy.claude.com/courses/claude-platform-101"><richcontent TYPE="NOTE"><html><head></head><body><p>https://academy.claude.com/courses/claude-platform-101</p></body></html></richcontent></node><node ID="ID_1053" TEXT="Library: appdesign"></node><node ID="ID_1054" TEXT="Library: techfund"></node><node ID="ID_1055" TEXT="Prompt generator / improver in Console" LINK="https://platform.claude.com/workbench"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/workbench</p></body></html></richcontent></node><node ID="ID_1056" TEXT="Prompt engineering interactive tutorial" LINK="https://github.com/anthropics/prompt-eng-interactive-tutorial"><richcontent TYPE="NOTE"><html><head></head><body><p>https://github.com/anthropics/prompt-eng-interactive-tutorial</p></body></html></richcontent></node></node></node><node ID="ID_1067" TEXT="09-27 · Review day"><node ID="ID_1059" TEXT="Learn: Review day"></node><node ID="ID_1063" TEXT="Build: Write notes/models-prompting.md"><node ID="ID_1060" TEXT="Finish notes/models-prompting.md: model table, ladder, technique order, thinking rules, context rules, decision sheets."></node><node ID="ID_1061" TEXT="Self-check; then the Model Selection and Prompt &amp; Context Engineering quizzes in the Question bank."></node><node ID="ID_1062" TEXT="Weekly retrospective."></node></node><node ID="ID_1064" TEXT="✔ Done when: Notes committed; both quizzes recorded; retrospective filled."></node><node ID="ID_1066" TEXT="Read"><node ID="ID_1065" TEXT="Study material below"></node></node></node></node><node ID="ID_1113" TEXT="📖 Study material"><node ID="ID_1076" TEXT="Model selection"><node ID="ID_1069" TEXT="Haiku"><richcontent TYPE="NOTE"><html><head></head><body><p>fastest, cheapest · classification, extraction, routing, moderation pre-checks, high-volume simple Q&amp;A, sub-agents doing narrow jobs · lowest</p></body></html></richcontent></node><node ID="ID_1070" TEXT="Sonnet"><richcontent TYPE="NOTE"><html><head></head><body><p>best balance · default for apps, coding, RAG chat, agents with tools · middle</p></body></html></richcontent></node><node ID="ID_1071" TEXT="Opus"><richcontent TYPE="NOTE"><html><head></head><body><p>deepest reasoning · complex multi-step agents, hard analysis, orchestrator in multi-agent systems, when quality dominates cost · highest</p></body></html></richcontent></node><node ID="ID_1072" TEXT="Start small: pick the smallest model that passes your eval; escalate only on measured…"><richcontent TYPE="NOTE"><html><head></head><body><p>Start small: pick the smallest model that passes your eval; escalate only on measured failure. Route: cheap model first, escalate on low confidence or a &quot;needs expert&quot; classification.</p></body></html></richcontent></node><node ID="ID_1073" TEXT="Current lineup (Sep 2026): Fable 5.1, Opus 5 and Sonnet 5 have a 1M context window and…"><richcontent TYPE="NOTE"><html><head></head><body><p>Current lineup (Sep 2026): Fable 5.1, Opus 5 and Sonnet 5 have a 1M context window and 128K max output; Haiku 4.5 has 200K / 64K. No long-context surcharge. Prices per MTok in/out: Fable 5.1 $10/$50 · Opus 5 $5/$25 · Sonnet 5 $2/$10 · Haiku 4.5 $1/$5.</p></body></html></richcontent></node><node ID="ID_1074" TEXT="Pin model IDs in production so behaviour is stable. Pre-4.6 models have dated…"><richcontent TYPE="NOTE"><html><head></head><body><p>Pin model IDs in production so behaviour is stable. Pre-4.6 models have dated snapshots (claude-sonnet-4-5-20250929) plus rolling aliases (claude-sonnet-4-5) — aliases are for experiments; 4.6+ IDs (claude-sonnet-5) are dateless but already pinned snapshots. Deprecations get ≥60 days' notice; migrate by re-running evals on the new snapshot. All Claude 3.x models are retired.</p></body></html></richcontent></node><node ID="ID_1075" TEXT="Cloud availability: the same models are on Amazon Bedrock, Google Vertex AI and…"><richcontent TYPE="NOTE"><html><head></head><body><p>Cloud availability: the same models are on Amazon Bedrock, Google Vertex AI and Microsoft Foundry — model IDs differ per platform; the SDK has platform-specific clients.</p></body></html></richcontent></node></node><node ID="ID_1083" TEXT="Cost ladder (do in this order, measure between rungs)"><node ID="ID_1077" TEXT="Trim the prompt and outputs: remove boilerplate, cap max_tokens, ask for terse formats."></node><node ID="ID_1078" TEXT="Cache the stable prefix (system, tools, documents) — biggest win for repeated context."></node><node ID="ID_1079" TEXT="Batch anything non-interactive — flat 50% off."></node><node ID="ID_1080" TEXT="Downgrade the model where the eval still passes; route the hard cases up."></node><node ID="ID_1081" TEXT="Reduce thinking budget or effort on tasks that do not need it."></node><node ID="ID_1082" TEXT="Measure with usage and count_tokens first — do not optimise blind. Output tokens cost…"><richcontent TYPE="NOTE"><html><head></head><body><p>Measure with usage and count_tokens first — do not optimise blind. Output tokens cost ~5× input; thinking is output.</p></body></html></richcontent></node></node><node ID="ID_1092" TEXT="Prompt engineering — Anthropic's technique order"><node ID="ID_1084" TEXT="Be clear and direct: state the task, audience, success criteria, constraints; give…"><richcontent TYPE="NOTE"><html><head></head><body><p>Be clear and direct: state the task, audience, success criteria, constraints; give context on why. Imagine handing it to a capable new colleague.</p></body></html></richcontent></node><node ID="ID_1085" TEXT="Examples (multishot): 3–5 diverse, relevant examples wrapped in &lt;example&gt; tags — the…"><richcontent TYPE="NOTE"><html><head></head><body><p>Examples (multishot): 3–5 diverse, relevant examples wrapped in &lt;example&gt; tags — the single most effective lever for format and tone.</p></body></html></richcontent></node><node ID="ID_1086" TEXT="Let Claude think: chain of thought — &quot;think step by step&quot; or structured…"><richcontent TYPE="NOTE"><html><head></head><body><p>Let Claude think: chain of thought — &quot;think step by step&quot; or structured &lt;thinking&gt;/&lt;answer&gt; tags; or turn on extended thinking.</p></body></html></richcontent></node><node ID="ID_1087" TEXT="XML tags: separate instructions, context, examples, documents (&lt;document&gt;,…"><richcontent TYPE="NOTE"><html><head></head><body><p>XML tags: separate instructions, context, examples, documents (&lt;document&gt;, &lt;instructions&gt;) so nothing is confused for anything else. Tags are also the safe way to fence untrusted content.</p></body></html></richcontent></node><node ID="ID_1088" TEXT="Give Claude a role via the system prompt (&quot;You are a senior SRE reviewing Terraform…&quot;)…"><richcontent TYPE="NOTE"><html><head></head><body><p>Give Claude a role via the system prompt (&quot;You are a senior SRE reviewing Terraform…&quot;) — changes tone, depth, and what it notices.</p></body></html></richcontent></node><node ID="ID_1089" TEXT="Prefill the response to force format or skip preamble."></node><node ID="ID_1090" TEXT="Chain prompts: split complex work into sequential calls, each verifiable."></node><node ID="ID_1091" TEXT="Long-context tips: documents at the top (~20k+ tokens), query at the bottom; ask for…"><richcontent TYPE="NOTE"><html><head></head><body><p>Long-context tips: documents at the top (~20k+ tokens), query at the bottom; ask for quotes first; structure multiple docs with metadata tags.</p></body></html></richcontent></node></node><node ID="ID_1097" TEXT="Extended thinking and effort"><node ID="ID_1093" TEXT="Manual mode: thinking: {type:&quot;enabled&quot;, budget_tokens: N}; N ≥ 1,024 and below…"><richcontent TYPE="NOTE"><html><head></head><body><p>Manual mode: thinking: {type:&quot;enabled&quot;, budget_tokens: N}; N ≥ 1,024 and below max_tokens (Haiku 4.5 and 4.5-era models). Adaptive mode: thinking: {type:&quot;adaptive&quot;} plus output_config: {effort: low|medium|high|xhigh|max} on 4.6+ — manual budget_tokens is a 400 on 4.7+/Opus 5/Sonnet 5. Thinking blocks come back in content (summarised) and are billed as output tokens.</p></body></html></richcontent></node><node ID="ID_1094" TEXT="Helps: maths, multi-step planning, complex analysis, agentic decisions. Wastes money:…"><richcontent TYPE="NOTE"><html><head></head><body><p>Helps: maths, multi-step planning, complex analysis, agentic decisions. Wastes money: lookups, classification, formatting, retrieval-style Q&amp;A.</p></body></html></richcontent></node><node ID="ID_1095" TEXT="Constraints: no prefill; with tool use you pass thinking blocks back unchanged…"><richcontent TYPE="NOTE"><html><head></head><body><p>Constraints: no prefill; with tool use you pass thinking blocks back unchanged (signature validated); tool_choice any/tool is not allowed with manual thinking; interleaved thinking (between tool calls) is automatic in adaptive mode. 4.6+ keeps prior-turn thinking in context (billed as input).</p></body></html></richcontent></node><node ID="ID_1096" TEXT="Effort (low / medium / high / xhigh / max, default high) shapes the whole response —…"><richcontent TYPE="NOTE"><html><head></head><body><p>Effort (low / medium / high / xhigh / max, default high) shapes the whole response — text, tool calls and thinking depth; it is a signal, not a hard budget; changing it at the top level invalidates the message cache.</p></body></html></richcontent></node></node><node ID="ID_1110" TEXT="Context engineering"><node ID="ID_1098" TEXT="The window is a budget: system + tools + history + documents + output must fit.…"><richcontent TYPE="NOTE"><html><head></head><body><p>The window is a budget: system + tools + history + documents + output must fit. Exceeding it is a 400 error (or a truncation with some settings).</p></body></html></richcontent></node><node ID="ID_1099" TEXT="Strategies: summarise or drop old turns; keep the last N turns verbatim; store…"><richcontent TYPE="NOTE"><html><head></head><body><p>Strategies: summarise or drop old turns; keep the last N turns verbatim; store long-term facts in a retrieval layer and inject only what is relevant (RAG); keep the system prompt stable so it caches; put volatile content last.</p></body></html></richcontent></node><node ID="ID_1100" TEXT="Newer platform features automate this: context editing (auto-clear old tool results),…"><richcontent TYPE="NOTE"><html><head></head><body><p>Newer platform features automate this: context editing (auto-clear old tool results), compaction, and memory tools for agents.</p></body></html></richcontent></node><node ID="ID_1101" TEXT="Attention degrades with size — &quot;lost in the middle&quot; — so place the most important…"><richcontent TYPE="NOTE"><html><head></head><body><p>Attention degrades with size — &quot;lost in the middle&quot; — so place the most important material at the start and end, and ask for quotes to ground answers.</p></body></html></richcontent></node><node ID="ID_1109" TEXT="⚠ Exam traps"><node ID="ID_1102" TEXT="&quot;Fastest way to cut cost&quot; is caching or a smaller model, not lowering temperature."></node><node ID="ID_1103" TEXT="Temperature controls randomness, not length or cost (and is rejected on Claude 4.7+)."></node><node ID="ID_1104" TEXT="Thinking tokens are billed as output; budget_tokens ≥ 1,024 and &lt; max_tokens."></node><node ID="ID_1105" TEXT="Aliases are not pinned."></node><node ID="ID_1106" TEXT="Cached tokens still count toward the context window."></node><node ID="ID_1107" TEXT="The first technique to try is always clearer instructions, not examples or thinking."></node><node ID="ID_1108" TEXT="Docs go before the question, not after."></node></node></node><node ID="ID_1112" TEXT="Structured prompt template"><node ID="ID_1111" TEXT="{ } code sample"><richcontent TYPE="NOTE"><html><head></head><body><p>system = &quot;&quot;&quot;You are a senior SRE. Review Terraform plans for risk.</p><p>&lt;rules&gt;</p><p>- Flag any destroy of a stateful resource as HIGH.</p><p>- Output only the JSON described in &lt;output_format&gt;.</p><p>&lt;/rules&gt;</p><p>&lt;output_format&gt;{&quot;risk&quot;:&quot;LOW|MEDIUM|HIGH&quot;,&quot;findings&quot;:[{&quot;resource&quot;:&quot;&quot;,&quot;why&quot;:&quot;&quot;}]}&lt;/output_format&gt;</p><p>&lt;example&gt;…&lt;/example&gt;&quot;&quot;&quot;</p><p>user = f&quot;&lt;plan&gt;{plan_text}&lt;/plan&gt;\nClassify the risk of this plan.&quot;</p></body></html></richcontent></node></node></node><node ID="ID_1283" TEXT="📚 Library digests"><node ID="ID_1127" TEXT="Models overview and IDs" LINK="https://platform.claude.com/docs/en/about-claude/models/overview"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/about-claude/models/overview</p></body></html></richcontent><node ID="ID_1120" TEXT="Key facts"><node ID="ID_1114" TEXT="Current lineup (Sep 2026): Claude Fable 5.1 claude-fable-5-1 (1M context, 128K max output,…"><richcontent TYPE="NOTE"><html><head></head><body><p>Current lineup (Sep 2026): Claude Fable 5.1 claude-fable-5-1 (1M context, 128K max output, adaptive thinking always on, $10/$50); Claude Opus 5 claude-opus-5 (1M, 128K, adaptive, $5/$25); Claude Sonnet 5 claude-sonnet-5 (1M, 128K, adaptive, $2/$10, fast); Claude Haiku 4.5 claude-haiku-4-5-20251001 (200K, 64K, manual extended thinking, $1/$5, fastest).</p></body></html></richcontent></node><node ID="ID_1115" TEXT="Recommendations: Opus 5 for most workloads; Fable 5.1 for the hardest reasoning/agentic work;…"><richcontent TYPE="NOTE"><html><head></head><body><p>Recommendations: Opus 5 for most workloads; Fable 5.1 for the hardest reasoning/agentic work; Sonnet 5 for speed/cost balance; Haiku 4.5 for budget and speed. Default effort is high on the 5-series; effort is not supported on Haiku 4.5.</p></body></html></richcontent></node><node ID="ID_1116" TEXT="All support text+image input, tool use, vision, multilingual output."></node><node ID="ID_1117" TEXT="ID formats: 4.6 and later are dateless and pinned (claude-sonnet-4-6, claude-opus-5) — they are…"><richcontent TYPE="NOTE"><html><head></head><body><p>ID formats: 4.6 and later are dateless and pinned (claude-sonnet-4-6, claude-opus-5) — they are snapshots, not evergreen aliases. Pre-4.6: dated IDs (claude-sonnet-4-5-20250929) plus rolling aliases (claude-sonnet-4-5). Bedrock: anthropic.claude-opus-5; Vertex: same as API.</p></body></html></richcontent></node><node ID="ID_1118" TEXT="Weights never change for a given ID. GET /v1/models returns max_input_tokens, max_tokens and…"><richcontent TYPE="NOTE"><html><head></head><body><p>Weights never change for a given ID. GET /v1/models returns max_input_tokens, max_tokens and capabilities.</p></body></html></richcontent></node><node ID="ID_1119" TEXT="Same models on Amazon Bedrock, Google Vertex AI, Microsoft Foundry with platform-specific IDs…"><richcontent TYPE="NOTE"><html><head></head><body><p>Same models on Amazon Bedrock, Google Vertex AI, Microsoft Foundry with platform-specific IDs and SDK clients.</p></body></html></richcontent></node></node><node ID="ID_1124" TEXT="⚠ Exam traps"><node ID="ID_1121" TEXT="claude-sonnet-4-6 is a fixed snapshot; claude-sonnet-4-5 is an alias that rolls forward — only pre-4.6 IDs have alias/snapshot pairs."></node><node ID="ID_1122" TEXT="Haiku 4.5 is the only current model with 200K context / 64K output; the 5-series is 1M / 128K."></node><node ID="ID_1123" TEXT="Fable 5.1's adaptive thinking cannot be turned off."></node></node><node ID="ID_1125" TEXT="Then vs now"><richcontent TYPE="NOTE"><html><head></head><body><p>Exam questions naming 'Opus / Sonnet / Haiku' tiers are about trade-offs (quality vs latency vs cost), which are unchanged. If a stem uses older IDs (claude-3-5-…, claude-sonnet-4-…), answer on the tier logic; all Claude 3.x models are retired as of 2026.</p></body></html></richcontent></node><node ID="ID_1126" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>for m in client.models.list():</p><p>    print(m.id, m.display_name)</p></body></html></richcontent></node></node><node ID="ID_1140" TEXT="Pricing" LINK="https://platform.claude.com/docs/en/about-claude/pricing"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/about-claude/pricing</p></body></html></richcontent><node ID="ID_1134" TEXT="Key facts"><node ID="ID_1128" TEXT="USD per million tokens — input / 5-min cache write / 1-h cache write / cache read / output:…"><richcontent TYPE="NOTE"><html><head></head><body><p>USD per million tokens — input / 5-min cache write / 1-h cache write / cache read / output: Fable 5.1 $10 / 12.50 / 20 / 0.25 / 50 · Opus 5 (and 4.5–4.8) $5 / 6.25 / 10 / 0.50 / 25 · Sonnet 5 $2 / 2.50 / 4 / 0.20 / 10 · Sonnet 4.5–4.6 $3 / 3.75 / 6 / 0.30 / 15 · Haiku 4.5 $1 / 1.25 / 2 / 0.10 / 5.</p></body></html></richcontent></node><node ID="ID_1129" TEXT="Multipliers: 5-min cache write 1.25×, 1-hour write 2×, cache read 0.1× (0.025× on Fable/Mythos…"><richcontent TYPE="NOTE"><html><head></head><body><p>Multipliers: 5-min cache write 1.25×, 1-hour write 2×, cache read 0.1× (0.025× on Fable/Mythos 5.1). Batch API: 50% off input AND output (Opus 5 $2.50/$12.50; Sonnet 5 $1/$5; Haiku 4.5 $0.50/$2.50).</p></body></html></richcontent></node><node ID="ID_1130" TEXT="No long-context premium above 200K — the full 1M window is billed at standard rates. Data…"><richcontent TYPE="NOTE"><html><head></head><body><p>No long-context premium above 200K — the full 1M window is billed at standard rates. Data residency inference_geo 'us' = 1.1×.</p></body></html></richcontent></node><node ID="ID_1131" TEXT="Fast mode (Opus 5/4.8, preview): $10/$50; stacks with caching; not available in Batch."></node><node ID="ID_1132" TEXT="Server tools: web search $10 per 1,000 searches (+ tokens, errors free); web fetch free beyond…"><richcontent TYPE="NOTE"><html><head></head><body><p>Server tools: web search $10 per 1,000 searches (+ tokens, errors free); web fetch free beyond tokens; code execution free alongside web search/fetch, otherwise 1,550 free container-hours/month then $0.05/hour (5-min minimum).</p></body></html></richcontent></node><node ID="ID_1133" TEXT="Tool-use system prompt overhead: Opus 5 286 tokens (auto/none) / 406 (any/tool); Sonnet 5…"><richcontent TYPE="NOTE"><html><head></head><body><p>Tool-use system prompt overhead: Opus 5 286 tokens (auto/none) / 406 (any/tool); Sonnet 5 354/474; Haiku 4.5 496/588.</p></body></html></richcontent></node></node><node ID="ID_1138" TEXT="⚠ Exam traps"><node ID="ID_1135" TEXT="Cache write costs MORE than base input (1.25× or 2×); reads cost 0.1× — caching pays only with reuse (break-even ≈ 2 reads)."></node><node ID="ID_1136" TEXT="Batch discount is 50% on input and output but cannot combine with fast mode."></node><node ID="ID_1137" TEXT="Output tokens are ~5× input price; thinking tokens are output."></node></node><node ID="ID_1139" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>PRICE = {&quot;claude-opus-5&quot;: (5, 25), &quot;claude-sonnet-5&quot;: (2, 10), &quot;claude-haiku-4-5-20251001&quot;: (1, 5)}</p><p>def cost(model, u, batch=False):</p><p>    i, o = PRICE[model]</p><p>    c = (u.input_tokens*i + u.cache_creation_input_tokens*i*1.25</p><p>         + u.cache_read_input_tokens*i*0.1 + u.output_tokens*o) / 1e6</p><p>    return c*0.5 if batch else c</p></body></html></richcontent></node></node><node ID="ID_1151" TEXT="Model deprecations" LINK="https://platform.claude.com/docs/en/about-claude/model-deprecations"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/about-claude/model-deprecations</p></body></html></richcontent><node ID="ID_1146" TEXT="Key facts"><node ID="ID_1141" TEXT="Minimum 60 days' notice before retiring a publicly released model; email to orgs with active…"><richcontent TYPE="NOTE"><html><head></head><body><p>Minimum 60 days' notice before retiring a publicly released model; email to orgs with active usage plus docs updates.</p></body></html></richcontent></node><node ID="ID_1142" TEXT="States: Active → Legacy (no updates) → Deprecated (still serves, retirement date set) → Retired…"><richcontent TYPE="NOTE"><html><head></head><body><p>States: Active → Legacy (no updates) → Deprecated (still serves, retirement date set) → Retired (requests fail).</p></body></html></richcontent></node><node ID="ID_1143" TEXT="All Claude 3.x models are retired (3.5 Haiku and 3.7 Sonnet retired Feb 2026; 3 Haiku Apr 2026);…"><richcontent TYPE="NOTE"><html><head></head><body><p>All Claude 3.x models are retired (3.5 Haiku and 3.7 Sonnet retired Feb 2026; 3 Haiku Apr 2026); Opus 4 / Sonnet 4 retired Jun 2026; Opus 4.1 retired Aug 2026. Oldest still-active: Sonnet 4.5 and Haiku 4.5.</p></body></html></richcontent></node><node ID="ID_1144" TEXT="Parameter deprecation: temperature/top_p/top_k → 400 on Opus 4.7+."></node><node ID="ID_1145" TEXT="Audit your usage by model: Console Usage page → export CSV by API key and model."></node></node><node ID="ID_1150" TEXT="⚠ Exam traps"><node ID="ID_1147" TEXT="Deprecated models still work; only Retired ones fail."></node><node ID="ID_1148" TEXT="Notice period is 60 days, not 30 or 90."></node><node ID="ID_1149" TEXT="Migrate by re-running your evals on the replacement snapshot before switching IDs."></node></node></node><node ID="ID_1162" TEXT="Token counting" LINK="https://platform.claude.com/docs/en/build-with-claude/token-counting"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/token-counting</p></body></html></richcontent><node ID="ID_1156" TEXT="Key facts"><node ID="ID_1152" TEXT="POST /v1/messages/count_tokens; SDK client.messages.count_tokens(...) → {input_tokens: N}. Free,…"><richcontent TYPE="NOTE"><html><head></head><body><p>POST /v1/messages/count_tokens; SDK client.messages.count_tokens(...) → {input_tokens: N}. Free, but rate-limited separately (Start 5,000 RPM, Build 10,000, Scale 20,000).</p></body></html></richcontent></node><node ID="ID_1153" TEXT="Counts system, messages, tools, images, PDFs and thinking blocks — it is not text-only; input…"><richcontent TYPE="NOTE"><html><head></head><body><p>Counts system, messages, tools, images, PDFs and thinking blocks — it is not text-only; input tokens only, no output estimate.</p></body></html></richcontent></node><node ID="ID_1154" TEXT="Claude 4.7+ uses a new tokenizer yielding ~30% more tokens for the same text — don't reuse older…"><richcontent TYPE="NOTE"><html><head></head><body><p>Claude 4.7+ uses a new tokenizer yielding ~30% more tokens for the same text — don't reuse older counts.</p></body></html></richcontent></node><node ID="ID_1155" TEXT="Result is an estimate; billing excludes system-added tokens. Request cap 32 MB."></node></node><node ID="ID_1160" TEXT="⚠ Exam traps"><node ID="ID_1157" TEXT="Token counting is free but has its own RPM limit."></node><node ID="ID_1158" TEXT="Counts input only — never an output estimate."></node><node ID="ID_1159" TEXT="4.7+ tokenizer counts ≈30% higher than 4.5/4.6 for identical text."></node></node><node ID="ID_1161" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>r = client.messages.count_tokens(model=&quot;claude-sonnet-5&quot;,</p><p>    system=&quot;You are a scientist&quot;,</p><p>    messages=[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Hello, Claude&quot;}])</p><p>print(r.input_tokens)</p></body></html></richcontent></node></node><node ID="ID_1173" TEXT="Prompt engineering overview" LINK="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview</p></body></html></richcontent><node ID="ID_1168" TEXT="Key facts"><node ID="ID_1163" TEXT="Prerequisites before prompt engineering: clear success criteria, empirical evals against them, a…"><richcontent TYPE="NOTE"><html><head></head><body><p>Prerequisites before prompt engineering: clear success criteria, empirical evals against them, a first-draft prompt.</p></body></html></richcontent></node><node ID="ID_1164" TEXT="Prompt engineering beats fine-tuning for most needs: faster, cheaper, preserves general…"><richcontent TYPE="NOTE"><html><head></head><body><p>Prompt engineering beats fine-tuning for most needs: faster, cheaper, preserves general knowledge, transparent, easy to iterate.</p></body></html></richcontent></node><node ID="ID_1165" TEXT="Prompting does not fix latency or cost — choose a different model or architecture for those."></node><node ID="ID_1166" TEXT="Technique order (broad → specialised): be clear and direct → examples (few-shot) → XML structure…"><richcontent TYPE="NOTE"><html><head></head><body><p>Technique order (broad → specialised): be clear and direct → examples (few-shot) → XML structure → role via system prompt → let Claude think → chain prompts → long-context tips.</p></body></html></richcontent></node><node ID="ID_1167" TEXT="Resources: prompt generator/improver in the Console Workbench, the interactive GitHub tutorial,…"><richcontent TYPE="NOTE"><html><head></head><body><p>Resources: prompt generator/improver in the Console Workbench, the interactive GitHub tutorial, model-specific best-practice pages.</p></body></html></richcontent></node></node><node ID="ID_1172" TEXT="⚠ Exam traps"><node ID="ID_1169" TEXT="Cost/latency problems → change model, not prompt."></node><node ID="ID_1170" TEXT="Success criteria and evals must exist before you start iterating on prompts."></node><node ID="ID_1171" TEXT="Clarity comes before examples; examples before thinking."></node></node></node><node ID="ID_1190" TEXT="Claude prompting best practices (clarity, examples, XML, roles, thinking, long context)" LINK="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices</p></body></html></richcontent><node ID="ID_1184" TEXT="Key facts"><node ID="ID_1174" TEXT="Golden rule: show the prompt to a colleague with minimal context — if they'd be confused, so…"><richcontent TYPE="NOTE"><html><head></head><body><p>Golden rule: show the prompt to a colleague with minimal context — if they'd be confused, so will Claude. Treat Claude as a brilliant new employee who lacks your context.</p></body></html></richcontent></node><node ID="ID_1175" TEXT="Be specific about output format and constraints; use numbered lists when order matters; explain…"><richcontent TYPE="NOTE"><html><head></head><body><p>Be specific about output format and constraints; use numbered lists when order matters; explain WHY ('a text-to-speech engine will read this, so no ellipses' beats 'NEVER use ellipses'). Tell Claude what to do rather than what not to do.</p></body></html></richcontent></node><node ID="ID_1176" TEXT="Examples: 3–5, relevant and diverse, wrapped in &lt;example&gt; inside &lt;examples&gt;; include &lt;thinking&gt;…"><richcontent TYPE="NOTE"><html><head></head><body><p>Examples: 3–5, relevant and diverse, wrapped in &lt;example&gt; inside &lt;examples&gt;; include &lt;thinking&gt; inside examples to demonstrate reasoning style.</p></body></html></richcontent></node><node ID="ID_1177" TEXT="XML: consistent descriptive tag names; nest for hierarchy (&lt;documents&gt; → &lt;document index='n'&gt;);…"><richcontent TYPE="NOTE"><html><head></head><body><p>XML: consistent descriptive tag names; nest for hierarchy (&lt;documents&gt; → &lt;document index='n'&gt;); separate &lt;instructions&gt;, &lt;context&gt;, &lt;input&gt;.</p></body></html></richcontent></node><node ID="ID_1178" TEXT="Role: set it in the system parameter — even one sentence makes a difference; put task-specific…"><richcontent TYPE="NOTE"><html><head></head><body><p>Role: set it in the system parameter — even one sentence makes a difference; put task-specific data in the user turn.</p></body></html></richcontent></node><node ID="ID_1179" TEXT="Thinking: prefer general instructions ('think thoroughly') over prescriptive steps; adaptive…"><richcontent TYPE="NOTE"><html><head></head><body><p>Thinking: prefer general instructions ('think thoroughly') over prescriptive steps; adaptive thinking on 4.6+ (always on for Fable/Mythos 5.x); when thinking is off, use manual chain of thought with &lt;thinking&gt; and &lt;answer&gt; tags.</p></body></html></richcontent></node><node ID="ID_1180" TEXT="Long context (20k+ tokens): documents at the TOP, query at the END — up to 30% better; wrap each…"><richcontent TYPE="NOTE"><html><head></head><body><p>Long context (20k+ tokens): documents at the TOP, query at the END — up to 30% better; wrap each in &lt;document&gt; with &lt;source&gt; and &lt;document_content&gt;; ask Claude to quote relevant parts first.</p></body></html></richcontent></node><node ID="ID_1181" TEXT="Prefill on the last assistant turn is unsupported from Claude 4.6 (400 error); use explicit…"><richcontent TYPE="NOTE"><html><head></head><body><p>Prefill on the last assistant turn is unsupported from Claude 4.6 (400 error); use explicit format instructions, XML output tags or structured outputs.</p></body></html></richcontent></node><node ID="ID_1182" TEXT="Prompt chaining remains useful when you must inspect intermediate outputs or enforce a pipeline…"><richcontent TYPE="NOTE"><html><head></head><body><p>Prompt chaining remains useful when you must inspect intermediate outputs or enforce a pipeline (draft → review → refine).</p></body></html></richcontent></node><node ID="ID_1183" TEXT="Tool-use prompting: be explicit ('Change this function' vs 'Can you suggest'); require…"><richcontent TYPE="NOTE"><html><head></head><body><p>Tool-use prompting: be explicit ('Change this function' vs 'Can you suggest'); require confirmation before destructive or irreversible actions.</p></body></html></richcontent></node></node><node ID="ID_1188" TEXT="⚠ Exam traps"><node ID="ID_1185" TEXT="Long documents go ABOVE the question, not below."></node><node ID="ID_1186" TEXT="Recommended few-shot count is 3–5, not 'as many as possible'."></node><node ID="ID_1187" TEXT="Role goes in system; prefill on the last assistant turn is a 400 on Claude 4.6+."></node></node><node ID="ID_1189" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>system = &quot;You are a senior SRE reviewing Terraform plans for risk.&quot;</p><p>user = &quot;&quot;&quot;&lt;documents&gt;&lt;document index=&quot;1&quot;&gt;&lt;source&gt;plan.txt&lt;/source&gt;</p><p>&lt;document_content&gt;{plan}&lt;/document_content&gt;&lt;/document&gt;&lt;/documents&gt;</p><p>First quote the lines relevant to stateful resources inside &lt;quotes&gt;, then classify the risk in &lt;answer&gt;.&quot;&quot;&quot;</p></body></html></richcontent></node></node><node ID="ID_1205" TEXT="Extended thinking" LINK="https://platform.claude.com/docs/en/build-with-claude/extended-thinking"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/extended-thinking</p></body></html></richcontent><node ID="ID_1198" TEXT="Key facts"><node ID="ID_1191" TEXT="Manual mode: thinking={type:'enabled', budget_tokens:N} — N ≥ 1,024 and &lt; max_tokens; budget is…"><richcontent TYPE="NOTE"><html><head></head><body><p>Manual mode: thinking={type:'enabled', budget_tokens:N} — N ≥ 1,024 and &lt; max_tokens; budget is a target, max_tokens the hard ceiling. Adaptive mode: thinking={type:'adaptive'} plus output_config.effort.</p></body></html></richcontent></node><node ID="ID_1192" TEXT="Support: manual only on 4.5 and earlier (and Haiku 4.5); deprecated on 4.6; rejected (400) on…"><richcontent TYPE="NOTE"><html><head></head><body><p>Support: manual only on 4.5 and earlier (and Haiku 4.5); deprecated on 4.6; rejected (400) on 4.7+, Opus 5, Sonnet 5, Fable 5.1 — those are adaptive-only.</p></body></html></richcontent></node><node ID="ID_1193" TEXT="Thinking tokens are billed as OUTPUT; breakdown in usage.output_tokens_details.thinking_tokens."></node><node ID="ID_1194" TEXT="Response: thinking block (summarised) then text; redacted_thinking may appear; blocks carry a…"><richcontent TYPE="NOTE"><html><head></head><body><p>Response: thinking block (summarised) then text; redacted_thinking may appear; blocks carry a signature and must be passed back unmodified with tool results.</p></body></html></richcontent></node><node ID="ID_1195" TEXT="Interleaved thinking (thinking between tool calls) is automatic in adaptive mode (beta header in…"><richcontent TYPE="NOTE"><html><head></head><body><p>Interleaved thinking (thinking between tool calls) is automatic in adaptive mode (beta header in manual mode).</p></body></html></richcontent></node><node ID="ID_1196" TEXT="Incompatible with prefill and with max_tokens:0 cache pre-warm; changing thinking config between…"><richcontent TYPE="NOTE"><html><head></head><body><p>Incompatible with prefill and with max_tokens:0 cache pre-warm; changing thinking config between requests misses the cache. Claude 4.6+ keeps prior-turn thinking in context (billed as input); 4.5 and earlier strip it.</p></body></html></richcontent></node><node ID="ID_1197" TEXT="Use Batches for budgets above ~32k to avoid timeouts; stream for large max_tokens."></node></node><node ID="ID_1202" TEXT="⚠ Exam traps"><node ID="ID_1199" TEXT="budget_tokens &lt; 1,024 → error; budget_tokens ≥ max_tokens → error."></node><node ID="ID_1200" TEXT="Thinking tokens are output tokens for billing."></node><node ID="ID_1201" TEXT="Manual enabled + budget_tokens is a 400 on 4.7+ — use adaptive + effort."></node></node><node ID="ID_1203" TEXT="Then vs now"><richcontent TYPE="NOTE"><html><head></head><body><p>The blueprint's 'extended thinking / budget tokens' wording matches the manual mode. Expect questions framed that way; know both the manual rules (≥1024, &lt; max_tokens, billed as output) and the modern adaptive + effort replacement.</p></body></html></richcontent></node><node ID="ID_1204" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>r = client.messages.create(model=&quot;claude-haiku-4-5-20251001&quot;, max_tokens=16000,</p><p>    thinking={&quot;type&quot;:&quot;enabled&quot;,&quot;budget_tokens&quot;:8000},</p><p>    messages=[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Plan a zero-downtime Postgres major upgrade.&quot;}])</p><p>for b in r.content:</p><p>    if b.type == &quot;thinking&quot;: print(&quot;THINK:&quot;, b.thinking[:200])</p><p>    elif b.type == &quot;text&quot;:  print(&quot;ANSWER:&quot;, b.text)</p><p># On Sonnet 5 / Opus 5: thinking={&quot;type&quot;:&quot;adaptive&quot;}, output_config={&quot;effort&quot;:&quot;high&quot;}</p></body></html></richcontent></node></node><node ID="ID_1216" TEXT="Effort parameter" LINK="https://platform.claude.com/docs/en/build-with-claude/effort"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/effort</p></body></html></richcontent><node ID="ID_1210" TEXT="Key facts"><node ID="ID_1206" TEXT="output_config={effort: low | medium | high | xhigh | max}; default high. Supported on Opus 4.5+,…"><richcontent TYPE="NOTE"><html><head></head><body><p>output_config={effort: low | medium | high | xhigh | max}; default high. Supported on Opus 4.5+, Sonnet 4.6+, Fable/Mythos; not Haiku 4.5.</p></body></html></richcontent></node><node ID="ID_1207" TEXT="Effort shapes all output — text length, number of tool calls, thinking depth; it is a…"><richcontent TYPE="NOTE"><html><head></head><body><p>Effort shapes all output — text length, number of tool calls, thinking depth; it is a behavioural signal, not a strict budget. thinking controls whether thinking happens; effort controls how much.</p></body></html></richcontent></node><node ID="ID_1208" TEXT="Lower effort → fewer/combined tool calls, terse output; xhigh for long-horizon work; max…"><richcontent TYPE="NOTE"><html><head></head><body><p>Lower effort → fewer/combined tool calls, terse output; xhigh for long-horizon work; max unconstrained. On Opus 5, xhigh/max require thinking enabled.</p></body></html></richcontent></node><node ID="ID_1209" TEXT="Changing top-level effort between requests invalidates the message cache; a per-message effort…"><richcontent TYPE="NOTE"><html><head></head><body><p>Changing top-level effort between requests invalidates the message cache; a per-message effort via a system turn (beta) preserves it. No separate pricing — cost changes only through tokens.</p></body></html></richcontent></node></node><node ID="ID_1214" TEXT="⚠ Exam traps"><node ID="ID_1211" TEXT="Five levels, default high — not three."></node><node ID="ID_1212" TEXT="Effort is set under output_config, not inside thinking."></node><node ID="ID_1213" TEXT="Changing effort mid-conversation at the top level busts the cache."></node></node><node ID="ID_1215" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>r = client.messages.create(model=&quot;claude-sonnet-5&quot;, max_tokens=2048,</p><p>    output_config={&quot;effort&quot;:&quot;low&quot;},</p><p>    messages=[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:&quot;Classify: 'pod stuck in CrashLoopBackOff'&quot;}])</p></body></html></richcontent></node></node><node ID="ID_1230" TEXT="Context windows" LINK="https://platform.claude.com/docs/en/build-with-claude/context-windows"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/context-windows</p></body></html></richcontent><node ID="ID_1224" TEXT="Key facts"><node ID="ID_1217" TEXT="1M-token window with 128K max output on the 5-series and 4.6+ Opus/Sonnet; 200K on Sonnet 4.5…"><richcontent TYPE="NOTE"><html><head></head><body><p>1M-token window with 128K max output on the 5-series and 4.6+ Opus/Sonnet; 200K on Sonnet 4.5 and older, and Haiku 4.5. 1M is the default (no beta header, no surcharge).</p></body></html></richcontent></node><node ID="ID_1218" TEXT="Everything counts: system, all messages, tool definitions, tool results, images/documents,…"><richcontent TYPE="NOTE"><html><head></head><body><p>Everything counts: system, all messages, tool definitions, tool results, images/documents, generated output; cached tokens still count.</p></body></html></richcontent></node><node ID="ID_1219" TEXT="Input alone &gt; window → 400 'prompt is too long'. Input + max_tokens &gt; window → generation stops…"><richcontent TYPE="NOTE"><html><head></head><body><p>Input alone &gt; window → 400 'prompt is too long'. Input + max_tokens &gt; window → generation stops with stop_reason 'model_context_window_exceeded' (Claude 4.5+).</p></body></html></richcontent></node><node ID="ID_1220" TEXT="Thinking: models that strip prior thinking (Opus &lt;4.5, Sonnet &lt;4.6, all Haiku) bill it once as…"><richcontent TYPE="NOTE"><html><head></head><body><p>Thinking: models that strip prior thinking (Opus &lt;4.5, Sonnet &lt;4.6, all Haiku) bill it once as output; models that keep it (Opus 4.5+, Sonnet 4.6+, 5.x) count prior thinking as input each turn — clear with context editing.</p></body></html></richcontent></node><node ID="ID_1221" TEXT="Tool-use turns must return the unmodified thinking block (signature validated)."></node><node ID="ID_1222" TEXT="Context awareness: Sonnet 4.5+/Haiku 4.5 receive token-budget warnings after tool calls;…"><richcontent TYPE="NOTE"><html><head></head><body><p>Context awareness: Sonnet 4.5+/Haiku 4.5 receive token-budget warnings after tool calls; server-side compaction (beta, 4.6+) summarises earlier turns to continue past the limit. 'Context rot' degrades accuracy as tokens grow even below the limit.</p></body></html></richcontent></node><node ID="ID_1223" TEXT="Max 600 images/PDF pages per request (100 on 200K models)."></node></node><node ID="ID_1228" TEXT="⚠ Exam traps"><node ID="ID_1225" TEXT="Input too long = 400; input + max_tokens too long = truncated response with model_context_window_exceeded."></node><node ID="ID_1226" TEXT="Cached tokens count toward the window; caching changes billing only."></node><node ID="ID_1227" TEXT="On Opus 4.5+/Sonnet 4.6+ prior thinking persists and is billed as input."></node></node><node ID="ID_1229" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>resp = client.messages.count_tokens(model=&quot;claude-sonnet-5&quot;, system=SYSTEM, messages=history)</p><p>if resp.input_tokens &gt; 150_000:</p><p>    history = summarise_older_turns(history, keep_last=6)</p></body></html></richcontent></node></node><node ID="ID_1242" TEXT="Context editing (server-side clearing)" LINK="https://platform.claude.com/docs/en/build-with-claude/context-editing"><richcontent TYPE="NOTE"><html><head></head><body><p>https://platform.claude.com/docs/en/build-with-claude/context-editing</p></body></html></richcontent><node ID="ID_1236" TEXT="Key facts"><node ID="ID_1231" TEXT="Beta header context-management-2025-06-27; request param context_management={edits:[…]}; use…"><richcontent TYPE="NOTE"><html><head></head><body><p>Beta header context-management-2025-06-27; request param context_management={edits:[…]}; use client.beta.messages.create.</p></body></html></richcontent></node><node ID="ID_1232" TEXT="Strategy clear_tool_uses_20250919: clears old tool results (replaced by a placeholder) once…"><richcontent TYPE="NOTE"><html><head></head><body><p>Strategy clear_tool_uses_20250919: clears old tool results (replaced by a placeholder) once context grows. Fields: trigger (default input_tokens 100,000; or tool_uses N), keep (default tool_uses 3), clear_at_least (input_tokens N), exclude_tools, clear_tool_inputs (default false).</p></body></html></richcontent></node><node ID="ID_1233" TEXT="Strategy clear_thinking_20251015: keep {thinking_turns: N} or 'all'. When combining, list…"><richcontent TYPE="NOTE"><html><head></head><body><p>Strategy clear_thinking_20251015: keep {thinking_turns: N} or 'all'. When combining, list clear_thinking first.</p></body></html></richcontent></node><node ID="ID_1234" TEXT="Response includes context_management.applied_edits (type, cleared_tool_uses,…"><richcontent TYPE="NOTE"><html><head></head><body><p>Response includes context_management.applied_edits (type, cleared_tool_uses, cleared_input_tokens). Edits are server-side; your stored history is untouched.</p></body></html></richcontent></node><node ID="ID_1235" TEXT="Clearing tool results invalidates the prompt cache from that point — use clear_at_least to make…"><richcontent TYPE="NOTE"><html><head></head><body><p>Clearing tool results invalidates the prompt cache from that point — use clear_at_least to make it worthwhile. Pair with the memory tool to persist critical facts before clearing; count_tokens accepts context_management to preview.</p></body></html></richcontent></node></node><node ID="ID_1240" TEXT="⚠ Exam traps"><node ID="ID_1237" TEXT="Default trigger 100,000 input tokens; default keep 3 tool uses."></node><node ID="ID_1238" TEXT="Server-side: the client's conversation history is unchanged."></node><node ID="ID_1239" TEXT="Thinking-clearing must precede tool-clearing in the edits list."></node></node><node ID="ID_1241" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>r = client.beta.messages.create(model=&quot;claude-sonnet-5&quot;, max_tokens=4096,</p><p>    betas=[&quot;context-management-2025-06-27&quot;],</p><p>    tools=[{&quot;type&quot;:&quot;web_search_20250305&quot;,&quot;name&quot;:&quot;web_search&quot;}],</p><p>    messages=history,</p><p>    context_management={&quot;edits&quot;:[{&quot;type&quot;:&quot;clear_tool_uses_20250919&quot;,</p><p>        &quot;trigger&quot;:{&quot;type&quot;:&quot;input_tokens&quot;,&quot;value&quot;:30000},</p><p>        &quot;keep&quot;:{&quot;type&quot;:&quot;tool_uses&quot;,&quot;value&quot;:3},</p><p>        &quot;clear_at_least&quot;:{&quot;type&quot;:&quot;input_tokens&quot;,&quot;value&quot;:5000}}]})</p></body></html></richcontent></node></node><node ID="ID_1255" TEXT="Effective context engineering for AI agents (engineering blog)" LINK="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents"><richcontent TYPE="NOTE"><html><head></head><body><p>https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents</p></body></html></richcontent><node ID="ID_1250" TEXT="Key facts"><node ID="ID_1243" TEXT="Context engineering = curating the whole context state (system prompt, tools, external data,…"><richcontent TYPE="NOTE"><html><head></head><body><p>Context engineering = curating the whole context state (system prompt, tools, external data, history) — a superset of prompt engineering.</p></body></html></richcontent></node><node ID="ID_1244" TEXT="Context rot: performance degrades as tokens grow; attention is a finite budget (n² pairwise); a…"><richcontent TYPE="NOTE"><html><head></head><body><p>Context rot: performance degrades as tokens grow; attention is a finite budget (n² pairwise); a gradient, not a cliff.</p></body></html></richcontent></node><node ID="ID_1245" TEXT="System prompt at the right altitude: not brittle if/else rules, not vague; specific heuristics…"><richcontent TYPE="NOTE"><html><head></head><body><p>System prompt at the right altitude: not brittle if/else rules, not vague; specific heuristics in organised sections; minimal high-signal tokens.</p></body></html></richcontent></node><node ID="ID_1246" TEXT="Tools: self-contained, non-overlapping, token-efficient — 'if a human engineer can't say which…"><richcontent TYPE="NOTE"><html><head></head><body><p>Tools: self-contained, non-overlapping, token-efficient — 'if a human engineer can't say which tool to use, an agent can't either'.</p></body></html></richcontent></node><node ID="ID_1247" TEXT="Few-shot: diverse canonical examples, not laundry lists of edge cases."></node><node ID="ID_1248" TEXT="Just-in-time context: lightweight references (paths, URLs, queries) loaded at runtime; hybrid…"><richcontent TYPE="NOTE"><html><head></head><body><p>Just-in-time context: lightweight references (paths, URLs, queries) loaded at runtime; hybrid with upfront context (Claude Code loads CLAUDE.md then greps).</p></body></html></richcontent></node><node ID="ID_1249" TEXT="Long-horizon techniques: compaction (summarise history — maximise recall first, then precision),…"><richcontent TYPE="NOTE"><html><head></head><body><p>Long-horizon techniques: compaction (summarise history — maximise recall first, then precision), structured note-taking (persistent notes outside context, e.g. Claude Code memory), sub-agent architectures (clean context per subagent, 1–2k-token summaries back).</p></body></html></richcontent></node></node><node ID="ID_1254" TEXT="⚠ Exam traps"><node ID="ID_1251" TEXT="Compaction: maximise recall first, then tune precision."></node><node ID="ID_1252" TEXT="Few-shot ≠ exhaustive edge cases."></node><node ID="ID_1253" TEXT="Sub-agents return condensed summaries, not transcripts."></node></node></node><node ID="ID_1269" TEXT="Claude application design: schemas, sessions, interface hygiene — blueprint 8.6%"><node ID="ID_1263" TEXT="Key facts"><node ID="ID_1256" TEXT="Interface interpretation: read a Messages request/response like a contract — which blocks are…"><richcontent TYPE="NOTE"><html><head></head><body><p>Interface interpretation: read a Messages request/response like a contract — which blocks are present (text, tool_use, thinking), what stop_reason implies, what usage costs; never assume content[0] is text.</p></body></html></richcontent></node><node ID="ID_1257" TEXT="Schema design for tools and outputs: small, flat objects; explicit enums instead of free text;…"><richcontent TYPE="NOTE"><html><head></head><body><p>Schema design for tools and outputs: small, flat objects; explicit enums instead of free text; required vs optional deliberate; descriptions on every property; unambiguous names (user_id); avoid deeply nested or union-heavy schemas (structured outputs has limits on unions/optionals); version schemas when you change them.</p></body></html></richcontent></node><node ID="ID_1258" TEXT="Session hygiene: the API is stateless — your app owns the history. Store it server-side keyed by…"><richcontent TYPE="NOTE"><html><head></head><body><p>Session hygiene: the API is stateless — your app owns the history. Store it server-side keyed by session id; cap history length; summarise or drop old turns; keep the system prompt stable (cacheable) and put per-request data last; never leak one user's context into another's; clear or rephrase after a refusal; strip tool results that are no longer needed (context editing).</p></body></html></richcontent></node><node ID="ID_1259" TEXT="Conversation state vs application state: the model sees only what you send — keep authoritative…"><richcontent TYPE="NOTE"><html><head></head><body><p>Conversation state vs application state: the model sees only what you send — keep authoritative state (orders, balances) in your database and pass snapshots, not the other way round.</p></body></html></richcontent></node><node ID="ID_1260" TEXT="Defensive parsing (blueprint 'Output Handling'): check stop_reason first; validate JSON against…"><richcontent TYPE="NOTE"><html><head></head><body><p>Defensive parsing (blueprint 'Output Handling'): check stop_reason first; validate JSON against a schema; handle max_tokens truncation; retry once with the error message; fail closed on unparsable output; log the raw response with request id.</p></body></html></richcontent></node><node ID="ID_1261" TEXT="Multi-tenant design: one workspace/key per tenant for Files and spend isolation; opaque…"><richcontent TYPE="NOTE"><html><head></head><body><p>Multi-tenant design: one workspace/key per tenant for Files and spend isolation; opaque metadata.user_id for abuse tracking; per-tenant rate-limit budgets.</p></body></html></richcontent></node><node ID="ID_1262" TEXT="Configuration management (blueprint 4.1%): model ID, max_tokens, effort, tool list and prompt…"><richcontent TYPE="NOTE"><html><head></head><body><p>Configuration management (blueprint 4.1%): model ID, max_tokens, effort, tool list and prompt versions live in config (not scattered in code); CLAUDE.md and settings.json versioned with the repo; environment-specific settings (dev/staging/prod keys and models).</p></body></html></richcontent></node></node><node ID="ID_1267" TEXT="⚠ Exam traps"><node ID="ID_1264" TEXT="The API is stateless: session state is your responsibility, keyed and isolated per user."></node><node ID="ID_1265" TEXT="Check stop_reason before parsing; treat max_tokens and refusal as distinct failure paths."></node><node ID="ID_1266" TEXT="Flat schemas with enums and good descriptions beat clever nested ones — for both tools and structured outputs."></node></node><node ID="ID_1268" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p>def parse_reply(r, schema):</p><p>    if r.stop_reason == &quot;refusal&quot;:        return None, &quot;refused&quot;</p><p>    if r.stop_reason == &quot;max_tokens&quot;:     return None, &quot;truncated&quot;</p><p>    text = &quot;&quot;.join(b.text for b in r.content if b.type == &quot;text&quot;)</p><p>    try:</p><p>        return schema.model_validate_json(text), None</p><p>    except Exception as e:</p><p>        return None, f&quot;invalid: {e}&quot;</p></body></html></richcontent></node></node><node ID="ID_1282" TEXT="Technical fundamentals: SDK integration, streaming transports, websockets — blueprint 6.1%"><node ID="ID_1276" TEXT="Key facts"><node ID="ID_1270" TEXT="Transport reality: the Messages API is HTTPS request/response; streaming uses server-sent events…"><richcontent TYPE="NOTE"><html><head></head><body><p>Transport reality: the Messages API is HTTPS request/response; streaming uses server-sent events (SSE) over that same HTTP response — one-way, text/event-stream, reconnect by resending. There is no WebSocket endpoint on the Messages API; WebSockets appear in YOUR app tier (browser ↔ your server) to relay SSE tokens to a UI, or in voice/realtime products.</p></body></html></richcontent></node><node ID="ID_1271" TEXT="Pattern: browser ⇄ (WebSocket or SSE) ⇄ your backend ⇄ (SSE) ⇄ Claude. Keep the API key on the…"><richcontent TYPE="NOTE"><html><head></head><body><p>Pattern: browser ⇄ (WebSocket or SSE) ⇄ your backend ⇄ (SSE) ⇄ Claude. Keep the API key on the backend only; never call the API from the browser.</p></body></html></richcontent></node><node ID="ID_1272" TEXT="SDK integration: sync client for scripts/batch, async client for servers; configure max_retries…"><richcontent TYPE="NOTE"><html><head></head><body><p>SDK integration: sync client for scripts/batch, async client for servers; configure max_retries and timeout; use with_options per call; catch typed exceptions; use messages.stream() helper for token streaming; read _request_id for support.</p></body></html></richcontent></node><node ID="ID_1273" TEXT="Timeouts: non-streaming calls have a ~10-minute limit; stream long outputs; use Batches for long…"><richcontent TYPE="NOTE"><html><head></head><body><p>Timeouts: non-streaming calls have a ~10-minute limit; stream long outputs; use Batches for long offline work; set TCP keep-alive on long connections.</p></body></html></richcontent></node><node ID="ID_1274" TEXT="Idempotency and retries: the SDK retries transient errors (408/409/429/5xx); design tool side…"><richcontent TYPE="NOTE"><html><head></head><body><p>Idempotency and retries: the SDK retries transient errors (408/409/429/5xx); design tool side effects to be safe under retry.</p></body></html></richcontent></node><node ID="ID_1275" TEXT="Environment: ANTHROPIC_API_KEY from env/secret manager; separate keys per environment; spend…"><richcontent TYPE="NOTE"><html><head></head><body><p>Environment: ANTHROPIC_API_KEY from env/secret manager; separate keys per environment; spend limits per workspace; region/data residency via inference_geo where required.</p></body></html></richcontent></node></node><node ID="ID_1280" TEXT="⚠ Exam traps"><node ID="ID_1277" TEXT="Claude streams via SSE; WebSockets are something your app adds between browser and backend."></node><node ID="ID_1278" TEXT="Never expose the API key to a browser client — proxy through your backend."></node><node ID="ID_1279" TEXT="Streaming is for perceived latency and long outputs; it doesn't change token cost."></node></node><node ID="ID_1281" TEXT="{ } code"><richcontent TYPE="NOTE"><html><head></head><body><p># FastAPI relay: browser gets SSE, key stays server-side</p><p>@app.get(&quot;/chat&quot;)</p><p>async def chat(q: str):</p><p>    async def gen():</p><p>        async with aclient.messages.stream(model=&quot;claude-sonnet-5&quot;, max_tokens=800,</p><p>                messages=[{&quot;role&quot;:&quot;user&quot;,&quot;content&quot;:q}]) as s:</p><p>            async for text in s.text_stream:</p><p>                yield f&quot;data: {json.dumps(text)}\n\n&quot;</p><p>    return StreamingResponse(gen(), media_type=&quot;text/event-stream&quot;)</p></body></html></richcontent></node></node></node><node ID="ID_1304" TEXT="❓ Self-check"><node ID="ID_1285" TEXT="A support bot answers FAQs from a 30-page policy doc, 10k calls/day. Model and optimisations?"><node ID="ID_1284" TEXT="→ Haiku (or Sonnet if eval demands), policy doc cached as a system-prompt prefix, short max_tokens, temperature 0, eval to confirm quality."></node></node><node ID="ID_1287" TEXT="Which prompting technique should you try first?"><node ID="ID_1286" TEXT="→ Clear, direct instructions with success criteria — before examples or thinking."></node></node><node ID="ID_1289" TEXT="Opus answers correctly but costs too much for a classification task. Next step?"><node ID="ID_1288" TEXT="→ Run the eval on Haiku; if it passes, switch; if borderline, route only low-confidence items to a bigger model."></node></node><node ID="ID_1291" TEXT="Where do long documents go relative to the question?"><node ID="ID_1290" TEXT="→ Documents at the top in XML tags, question at the bottom; ask for relevant quotes first."></node></node><node ID="ID_1293" TEXT="budget_tokens=8000 and max_tokens=4000 — what happens?"><node ID="ID_1292" TEXT="→ Invalid: budget_tokens must be less than max_tokens."></node></node><node ID="ID_1295" TEXT="Why prefer a dated model ID in production?"><node ID="ID_1294" TEXT="→ Behaviour and evals stay stable; an alias silently upgrades to a new snapshot."></node></node><node ID="ID_1297" TEXT="A chat's input tokens climb every turn until a 400 error. Fix?"><node ID="ID_1296" TEXT="→ Context management: summarise older turns, keep the last N verbatim, or use context editing/compaction; cache the stable prefix."></node></node><node ID="ID_1299" TEXT="Which parameter does NOT reduce cost: max_tokens, temperature, model, caching?"><node ID="ID_1298" TEXT="→ temperature — it only changes randomness."></node></node><node ID="ID_1301" TEXT="When is extended thinking a waste?"><node ID="ID_1300" TEXT="→ Simple lookups, classification, formatting — pay for it only on multi-step reasoning."></node></node><node ID="ID_1303" TEXT="Which is cheaper per token: input or output?"><node ID="ID_1302" TEXT="→ Input by roughly 5×; cached input reads are cheaper still (~0.1× base input)."></node></node></node><node ID="ID_1319" TEXT="⚠ Traps to drill"><node ID="ID_1306" TEXT="Cheapest quick win for a high-volume prompt with a big stable system prompt?"><node ID="ID_1305" TEXT="→ Prompt caching (then batch if offline, then a smaller model). Not temperature."></node></node><node ID="ID_1308" TEXT="Thinking tokens are billed as…"><node ID="ID_1307" TEXT="→ Output tokens, at output price; budget_tokens &lt; max_tokens."></node></node><node ID="ID_1310" TEXT="First prompt-engineering technique to try?"><node ID="ID_1309" TEXT="→ Be clear and direct with success criteria — before few-shot, CoT or role."></node></node><node ID="ID_1312" TEXT="Long document placement?"><node ID="ID_1311" TEXT="→ Top of the prompt in &lt;document&gt; tags; question last; ask for quotes first."></node></node><node ID="ID_1314" TEXT="Alias vs dated model ID in prod?"><node ID="ID_1313" TEXT="→ Dated ID. Aliases move to new snapshots without warning."></node></node><node ID="ID_1316" TEXT="Which tier for classification at scale?"><node ID="ID_1315" TEXT="→ Haiku — smallest model that passes the eval; route hard cases upward."></node></node><node ID="ID_1318" TEXT="Temperature changes cost or length?"><node ID="ID_1317" TEXT="→ Neither. Randomness only."></node></node></node><node ID="ID_1327" TEXT="🗒 Cheat sheet"><node ID="ID_1320" TEXT="Haiku = volume/classify/route · Sonnet = default apps/coding/agents · Opus = hardest reasoning/orchestration. Smallest model that passes the eval."></node><node ID="ID_1321" TEXT="Cost ladder: trim → cache → batch → smaller model → less thinking. Measure with usage + count_tokens. Output ≈ 5× input price."></node><node ID="ID_1322" TEXT="Technique order: clear &amp; direct → examples → let it think → XML tags → role (system) → prefill → chain prompts → long-context tips"></node><node ID="ID_1323" TEXT="Thinking: manual budget_tokens ≥1024 and &lt; max_tokens (Haiku 4.5) · adaptive + effort low/medium/high/xhigh/max on 4.6+ (default high) · billed as output · no prefill · pass thinking blocks back with tools"></node><node ID="ID_1324" TEXT="Long context: docs first in tags, question last, ask for quotes; lost-in-the-middle → important stuff at start/end"></node><node ID="ID_1325" TEXT="Context mgmt: summarise old turns, keep last N, RAG for facts, stable prefix cached, volatile last; context editing/compaction on newer models"></node><node ID="ID_1326" TEXT="Pin IDs in prod (dated pre-4.6, dateless-but-pinned 4.6+); aliases for experiments; ≥60 days deprecation notice; 3.x retired; same models on Bedrock / Vertex / Foundry with platform IDs"></node></node><node ID="ID_1334" TEXT="☑ Chapter checklist"><node ID="ID_1328" TEXT="Can justify Haiku vs Sonnet vs Opus for five different workloads"></node><node ID="ID_1329" TEXT="Know the cost-optimisation ladder in order"></node><node ID="ID_1330" TEXT="Used XML tags and few-shot examples in a real prompt"></node><node ID="ID_1331" TEXT="Know when extended thinking is worth paying for and when not"></node><node ID="ID_1332" TEXT="Summarisation strategy implemented in chat.py"></node><node ID="ID_1333" TEXT="notes/models-prompting.md written"></node></node></node>
</map>
