Skip to content
Claude Certified Developer – Foundations (CCDV-F) Exam Prep

Lesson 15 of 25 · 7 min

x
15/25

Context Engineering

Video lesson: CCDV-F 15/25: Context Engineering (Domain 6, 3.8%)

Official scope (Exam Guide v1.0): context window management, drift and bloat prevention (tool output pruning, compaction), and isolation through subagents or multi-step workflows.

What counts

System prompt, every message, tool definitions, tool results, images, documents, and the model's own output including thinking. Cached tokens still occupy the window: caching changes price, not size. Windows are 1M tokens on current models.

More is not better

As tokens grow, accuracy and recall degrade: context rot. Curate; do not fill.

Overflow

  • Input alone over the window → 400 ("prompt is too long").
  • Input plus max_tokens over the window (Claude 4.5+) → accepted, may stop with stop_reason: model_context_window_exceeded.
  • Estimate first with the token counting API.

Drift and bloat (design guidance on symptoms, verified tools)

  • Drift: early instructions lose influence over a long task. Keep critical rules in the stable system prompt, restate them, or keep a short persistent facts block (ids, decisions, constraints).
  • Bloat: stale tool output, whole files where a section would do, oversized tool results.
RemedyWhat it does
Trim tool outputReturn only high-signal fields; cap result size
Context editing (verified)Server-side clearing of old tool results or thinking blocks, with trigger, keep, clear_at_least, exclude_tools; clearing invalidates the cached prefix
Compaction (verified, beta)A summary replaces older turns, on demand or at a token threshold; keep decisions, open questions and state, drop dead ends
Just-in-time retrievalKeep identifiers; fetch detail when needed instead of preloading
Memory tool (verified)Client-side files Claude reads and writes; survives resets; you implement and secure it

Isolation

Run noisy work (search, exploration, large reads) in a subagent or a separate workflow step; only its final summary enters the main context.

Structured handoff (design guidance)

For multi-session work, end a session by writing state: goal, done, next, constraints, key files. A fresh session recovers quickly from it.

Prompt vs context (design guidance)

The prompt says what to do; the context is what the model knows while doing it. Fix the right one.

Exam traps

  • "Use the biggest window" instead of curating.
  • Assuming cached tokens do not use the window.
  • Letting tool results accumulate unbounded.
  • Relying on a summary to preserve exact ids, with no facts block.
  • Treating the memory tool as Anthropic-hosted storage.

References

  1. Context windows — checked Oct 16, 2026
  2. Context editing — checked Oct 16, 2026
  3. Compaction — checked Oct 16, 2026
  4. Memory tool — checked Oct 16, 2026
  5. Subagents in the SDK — checked Oct 16, 2026
  6. Handling stop reasons — checked Oct 16, 2026

Check your understanding

  • Late in a long session the agent ignores a constraint from the start. Cause and two remedies?Show answer

    Answer

    Drift/context rot; move the rule to the system prompt or a facts block, and compact or clear stale context.
  • Tool results from 30 steps ago still sit in context. Cheapest fix?Show answer

    Answer

    Clear old tool results (context editing).
  • 500-file codebase. Load everything or retrieve per task?Show answer

    Answer

    Retrieve just in time; explore in a subagent.
  • Input fits, but input plus max_tokens does not. What can happen?Show answer

    Answer

    Generation may stop with model_context_window_exceeded.
Previous

Progress is saved in this browser.

Next Lesson