Skip to content
Domain 6
11%

Glossary: Prompt and Context Engineering

Quick-lookup definitions for the 11% exam domain. Each entry includes a concise definition and exam context. Follow the lesson links to dive deeper.

Context Engineering

The set of strategies for curating and maintaining the optimal set of tokens during inference. Prompt engineering asks what the instructions say; context engineering asks what is in the window at all, including everything an agentic run put there on its own.

Exam context: The tested decisions are curation decisions, and they are tested on long agentic runs, because that is where a window fills without anyone deciding it should. One of them is just-in-time loading (Anthropic's engineering guidance, as of September 2026): the agent keeps lightweight identifiers such as file paths, stored queries and links, and loads the data through tools when the task needs it rather than having everything pasted in up front.

See also: 6.1 Context Engineering


Bloat

The volumetric fault: full API payloads, whole file contents and complete search results accumulating in the window long after their useful content was extracted. Symptoms are cost and latency climbing per step, ending in a request that no longer fits.

Exam context: Rising cost, latency and request size describe bloat and nothing else. The keyed fixes are pruning spent tool output, compacting the settled transcript, and isolating the sprawling step.

See also: 6.1 Context Engineering


Drift

The behavioural fault: standing rules stated once, now sitting hundreds of turns back, and no longer honoured. Formats vary, a rule gets skipped, an established fact gets contradicted, while token counts stay flat.

Exam context: Half the sub-skill turns on separating this from bloat. An item describes one or the other, never both, and offering a pruning answer for wandering behaviour is the classic mismatch.

See also: 6.1 Context Engineering


Attention Budget

Anthropic's framing for why length degrades quality rather than merely costing more. Models draw on a finite budget when parsing large volumes of context, every new token depletes it, and recall accuracy falls as the volume grows.

Exam context: This is why a larger context window is the standing distractor in every degradation item. It moves the ceiling and leaves recall exactly where it was.

See also: 6.1 Context Engineering


Context Editing

The Messages API implementation of tool output pruning, a beta behind the header context-management-2025-06-27. Clearing happens server-side before the prompt reaches Claude, so the client keeps its full unmodified history.

Exam context: Distractors describe client-side bookkeeping or silent deletion. Neither is the mechanism: nothing is dropped without a placeholder, and nothing is asked of your stored history.

See also: 6.1 Context Engineering


clear_tool_uses_20250919

The context-editing strategy that clears spent tool uses and results. Its parameters are trigger (default 100,000 input tokens), keep (default 3 tool uses), clear_at_least, exclude_tools and clear_tool_inputs (default false).

Exam context: The defaults are keyed facts, and so is the direction of clear_tool_inputs: the call's arguments stay unless you opt in to clearing them, which is what lets Claude still see what it asked for.

See also: 6.1 Context Engineering


clear_at_least

The minimum number of tokens a clearing pass must reclaim before it runs at all.

Exam context: Its reason for existing is the tested part. Clearing invalidates the cached prefix from the clearing point, so a pass that reclaims a trivial amount costs a cache write and saves nothing.

See also: 6.1 Context Engineering


exclude_tools

The context-editing parameter naming tools whose uses and results are never cleared.

Exam context: The escape hatch for a result still cited later in the run. A design that clears a result the agent must keep quoting is fixed here, not by turning clearing off.

See also: 6.1 Context Engineering


applied_edits

The context_management.applied_edits field on the response, reporting what clearing actually did, with cleared_tool_uses and cleared_input_tokens per edit.

Exam context: The only honest record of what was removed, and the pair of numbers worth logging per step. The token-counting endpoint previews the same effect, returning original_input_tokens beside the post-clearing count.

See also: 6.1 Context Engineering


Compaction

Replacing the settled portion of a transcript with a structured summary so the conversation can continue rather than end. As of September 2026 it comes in two beta forms. On demand (header compact-2026-09-04): your code sends the conversation with the top-level compaction parameter, gets back one compaction block, and swaps it in first in messages in place of the messages it summarises. At a token threshold (header compact-2026-01-12): a compact_20260112 edit in context_management has the API summarise inside an ordinary request once input tokens reach the trigger (minimum 50,000, default 150,000). The docs say to use on-demand compaction wherever it is available, and the compaction parameter cannot be sent with context_management.

Exam context: Compaction is not lossless and not reversible. The pre-compaction history is not archived anywhere retrievable, so anything the summary omitted is gone from the conversation for good, documents and images in the summarised turns included. A model with context awareness (Claude Sonnet 5, Claude Sonnet 4.6, Claude Sonnet 4.5 and Claude Haiku 4.5, as of September 2026) may start wrapping up as the window fills unless the prompt says the harness compacts.

See also: 6.1 Context Engineering


Compaction Block

The content block of type compaction carrying the summary. With threshold compaction you append the response to your messages as usual, and on the next request the API ignores every content block before it. With on-demand compaction your code puts the block first in messages and removes the messages it summarises.

Exam context: The mechanism behind the trap. An option claiming the original conversation is preserved and merely re-sent in shortened form inverts what the block does. An option that appends an on-demand block after the newest turn gets the swap backwards: the block goes first.

See also: 6.1 Context Engineering


Preservation Contract

The written statement of what a compaction summary must carry: decisions and their reasons, established facts and sources, constraints and prohibitions still binding, open questions, and the state of unfinished work. Raw payloads already reduced to facts and superseded attempts get dropped.

Exam context: In both forms of compaction a custom instructions string replaces the default summarisation prompt entirely rather than extending it, so anything the default kept is no longer asked for unless a narrow instruction names it. The failure surfaces as a contradiction many steps later.

See also: 6.1 Context Engineering


usage.iterations

The per-iteration usage breakdown on a compacting run. The compaction pass is billed as its own iteration and appears here; the top-level input_tokens and output_tokens exclude it, and on an on-demand compaction request they read zero.

Exam context: A cost model reading only the top-level counts undercounts every run that compacted. Summing the iterations is the correct arithmetic.

See also: 6.1 Context Engineering


Context Isolation

Running work in a separate window so it never enters the main conversation. A subagent's intermediate tool calls and results stay inside it and only its final message returns to the parent.

Exam context: The saving is that the exploration never arrives, not that it gets summarised afterwards. The documented line: use a subagent when the task produces verbose output the main context does not need, when tool restrictions must be enforced, or when the work is self-contained and can return a summary; stay in the main conversation when the task needs frequent back-and-forth, when multiple phases share significant context, when the change is quick and targeted, or when latency matters.

See also: 6.1 Context Engineering


Delegation Handover

The two-directional contract of an isolated run: everything the worker needs goes into the invoking prompt, and the return shape is specified as precisely as the inputs. A subagent context starts fresh with no parent conversation, receiving its own system prompt and the Agent tool's prompt string, and no parent history, tool results or system prompt.

Exam context: Options claiming a subagent picks the standing constraints up from the conversation, or inherits the parent's system prompt, describe an impossible mechanism.

See also: 6.1 Context Engineering


Memory Tool

Anthropic's cross-session persistence mechanism, generally available on the Messages API with no beta header, declared as a single tools entry of type memory_20250818. Claude issues view, create, str_replace, insert, delete and rename commands against paths under /memories, and your application executes them client-side.

Exam context: The alternative to replaying a transcript so the model remembers. It is also what preserves information that must survive a summarisation, which is why memory writes come before the compaction fires rather than after it.

See also: 6.1 Context Engineering


Document-First Ordering

Placing long inputs near the top of the prompt, above the query, instructions and examples. Documented for inputs over about 20k tokens, with queries at the end improving response quality by up to 30 percent in tests on complex multi-document inputs.

Exam context: The reading-order intuition points the wrong way, which is what makes question-first a convincing distractor. Wrapping each document in its own tags with source metadata, and asking for quotes before the task, are the two refinements that travel with the rule.

See also: 6.1 Context Engineering


System Field

The top-level system parameter, carrying durable material: who Claude is in this application, standing rules, tone, scope limits, refusal boundaries. It sits ahead of every message, so it is present on every turn however long the conversation runs.

Exam context: The keyed answer to drift. Emphasis, capitalisation and repetition are the distractors, because none of them changes where the rule sits relative to the turn it must govern.

See also: 6.2 Prompt Engineering


Mid-Conversation System Message

A message with role system appended to messages at the point a new instruction becomes relevant. Generally available with no beta header. As of September 2026 it works on Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8 and Claude Sonnet 5.5. Not available on Claude Sonnet 5, where the top-level system field is used instead.

Exam context: It keeps operator priority without editing the top-level field, so the earlier turns stay byte-identical and the cached prefix still hits. Its placement rules are examinable on their own, and every violation returns a 400. A turn-scoped variant (beta, clear_at set to "next_user_message") renders only until a later user message exists, then stays in the array at no token cost, which suits a per-turn reminder in a tool loop.

See also: 6.2 Prompt Engineering


System Precedence

The rule that a user message is treated as coming from the end user while a system message is treated as coming from you, the application operator, and that system instructions win when the two conflict. Later system messages take precedence over earlier ones and over the top-level field for the turns that follow.

Exam context: Authority is what makes the role worth using. It is also why untrusted content must never be placed there: system content is treated as operator instruction and followed.

See also: 6.2 Prompt Engineering


Instruction Surface

Any place an instruction can live: the system prompt, a tool description, a schema's field descriptions, or a CLAUDE.md file. The choice is mechanical: put the instruction on the surface guaranteed to be present at the moment it must apply.

Exam context: A rule stated on three surfaces in three slightly different wordings is a defect, not redundancy. It is a conflict resolved at run time, and a precedence clause makes it survivable rather than removing it.

See also: 6.2 Prompt Engineering


Instruction Clarity

A technical property, tested by showing the prompt to a colleague with minimal context. Say what to do rather than what to avoid, give the motivation so the model generalises, decompose compound instructions into ordered steps, and state audience, format and length explicitly.

Exam context: Restating the same vague rule more forcefully is the distractor, and so is moving it to another surface. Placement fixes a rule that drifts; it does nothing for one that was never precise enough to follow. As of September 2026 the docs also describe how current models read wording. Claude Sonnet 5 and Claude Opus 4.8 take scope literally, so state it. "Can you suggest" gets suggestions, so ask for the change or set a default to act. Post-tool summaries may be skipped unless you ask for them. The prompt's own style leaks into the output. And emphatic wording such as "CRITICAL: You MUST" can make Claude Opus 4.5 and Claude Opus 4.6 over-trigger.

See also: 6.2 Prompt Engineering


Few-Shot Examples

Worked input and output pairs in the prompt, the most reliable way to steer output format, tone and structure. The current recommendation is three to five, each relevant, diverse and structured, wrapped in example tags with multiple examples inside an examples wrapper.

Exam context: More is not better. Inconsistent examples teach inconsistency, examples of the wrong shape outrank your description, and an undelimited example is indistinguishable from the live task.

See also: 6.2 Prompt Engineering


max_tokens

A hard cap on generation. Reaching it truncates the response mid-sentence and reports stop_reason of max_tokens; in a tool-use turn it can leave an incomplete tool_use block.

Exam context: Never a brevity control. Responses that stop mid-sentence are a cap, not a model ignoring an instruction, and the fix is to raise the ceiling and put the length in the prompt with a worked example.

See also: 6.2 Prompt Engineering


Prefill

Providing a partial assistant message for Claude to continue from. No longer supported on the last assistant turn from Claude 4.6 models and Claude Mythos Preview onward; such requests return a 400.

Exam context: Still the most tempting wrong answer for a format problem, because it was the standard technique for years. The documented replacements are structured outputs for format and a direct system-prompt instruction for preamble suppression.

See also: 6.2 Prompt Engineering


Sampling Controls

temperature, top_p and top_k. Any non-default value on Claude Opus 4.7 or later returns a 400. As of September 2026 the Python SDK (v1.0 and later) no longer defines the fields, so passing one raises a TypeError before the request is sent.

Exam context: Wrong on mechanism first and unavailable second. Sampling never governed format, focus or caution, so the reasoning that rules the option out predates its removal.

See also: 6.2 Prompt Engineering


JSON-Encoding

Wrapping a third-party string in a JSON object rather than concatenating it into free-form text. JSON escaping provides unambiguous delimiters between the untrusted payload and the surrounding structure, so an attacker cannot close a quote or tag to break out into an instruction context.

Exam context: Stripping characters is the distractor: it destroys content the sender meant and still misses whatever class you did not think of. Encoding makes the content structurally incapable of ending the block it sits in.

See also: 6.2 Prompt Engineering


tool_result Routing

Delivering third-party content inside tool_result blocks rather than in system prompts or plain user text.

Exam context: The corollary is the part people miss. Content in a tool result is treated as untrusted data and may be ignored or flagged, so your own instructions do not belong there either. They go in the user turn that follows, or in a mid-conversation system message.

See also: 6.2 Prompt Engineering


Evaluation Set

A fixed set of real inputs, including the edge cases that actually bite, scored the same way every run. The docs put building one ahead of any prompt technique.

Exam context: The set is a variable too. Adding cases mid-experiment makes every earlier score incomparable, whichever direction the number moved, and the recovery is to re-score on the original set and re-baseline afterwards.

See also: 6.2 Prompt Engineering


Attribution

Knowing which change moved the score, which requires exactly one variable moving per run.

Exam context: Asking the model which of your changes helped is not evidence; it has no privileged access to why its own distribution shifted. Where a change targets a rare failure, sample the same case repeatedly, because one pass through a non-deterministic system cannot tell a fix from luck. A model move counts as a change too: as of September 2026, verification steps carried over to Claude Opus 5 cause over-verification, so remove them rather than reword them, then re-score.

See also: 6.2 Prompt Engineering


Structured Outputs

Constraining the response to a JSON schema through output_config.format with type json_schema. Structured outputs guarantee schema-compliant responses through constrained decoding, so on a completed response malformed JSON and missing required fields stop being a class of bug you handle (a refusal or a max_tokens cut can still break the schema; check stop_reason).

Exam context: The parameter has moved from output_format to output_config.format and beta headers are no longer required. As of September 2026 output_format is deprecated and returns a 400 unless the structured-outputs-2025-11-13 header is sent, though the Python parse() helper still takes a Pydantic model under that name. The first request with a new schema pays grammar-compilation latency, compiled grammars cache for 24 hours from last use, and changing the format invalidates the prompt cache for that thread. Required properties come first in the output, then optional ones.

See also: 6.3 Output Handling


Strict Tool Use

Applying the same constrained decoding to tool names and tool inputs by setting strict to true on a tool definition. The right choice when the structured value is an action's arguments rather than the response itself, and usable in the same request as a JSON schema.

Exam context: Distractors treat it as an alternative that also enforces ranges and lengths. It enforces the same subset, which excludes both. As of September 2026 strict schemas share request-wide complexity limits (20 strict tools, 24 optional parameters, 16 union-typed parameters), and a grammar that is still too large returns a 400.

See also: 6.3 Output Handling


Supported Schema Subset

What constrained decoding can express. Unsupported: minimum, maximum, multipleOf, minLength, maxLength, recursive schemas, complex types within enums, external $ref, and array constraints beyond minItems of 0 or 1. additionalProperties must be set to false.

Exam context: The gaps are exactly where validation still lives, and adding an unsupported keyword to the schema is rejected rather than enforced. A schema can guarantee a field is a number; it cannot guarantee the number is plausible.

See also: 6.3 Output Handling


Validation Layer

The code that runs on every response and answers "is this right?": structural checks, range and plausibility, cross-field consistency, and referential checks against the system that issues an identifier.

Exam context: Structured outputs remove the parse-failure class on a completed response and nothing else, so adopting them and deleting the validator is the standing trap. Current state (checked 6 October 2026): the structured outputs docs list cases where the output may not match the schema, among them a refusal and a max_tokens cut, so check stop_reason before parsing. On failure the layer raises, with the raw body and request id attached; substituting a default converts a loud failure into a quiet wrong record. Compare enum values case-insensitively: as of September 2026 the capitalisation of enum and const values is not guaranteed.

See also: 6.3 Output Handling


Referential Check

Verifying that an identifier names a real thing, by looking it up in the system that issues it.

Exam context: The only check that catches a confidently invented identifier, because a fabricated reference is formatted indistinguishably from a real one. Self-assessed confidence fields and second calls asking the model to check its own work consult nothing external.

See also: 6.3 Output Handling


stop_reason

The response field naming why generation ended: end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal or model_context_window_exceeded, plus compaction on a compaction request. Read before the payload, never after.

Exam context: Both max_tokens and model_context_window_exceeded mean the response is truncated, and truncated output can be syntactically valid up to the cut. A clean parse and an HTTP 200 prove nothing on their own.

See also: 6.3 Output Handling


Refusal

Claude declining to produce the response. It arrives as stop_reason of refusal on a normal HTTP 200, with a stop_details object naming the policy category.

Exam context: The one failure that never looks like one to status-code branching, so retry logic keyed to HTTP errors cannot address it. An integration that treats it as an empty success writes nothing and reports nothing.

See also: 6.3 Output Handling


Informed Retry

Re-asking with the specific validation errors attached: which field was missing, which value fell outside its range, which two fields disagreed. Capped at a small, explicit number of attempts.

Exam context: An identical retry samples the same distribution and fails the same way indefinitely, and an uncapped loop on a systematic failure is a cost incident. Repeated failure on the same field is a defect in the schema, the prompt or the validator rather than bad luck.

See also: 6.3 Output Handling


Best-of-N Verification

Running the same prompt several times and treating disagreement between the runs as a fabrication signal.

Exam context: One of the documented hallucination controls, alongside permission to decline in fixed wording and quote grounding before the task. All of them reduce the rate; none removes the need to check anything with a real-world referent against the system that issues it. For supplied documents, the Citations feature is stronger than prompting for quotes, because the API extracts cited_text itself. As of September 2026, enabling it alongside output_config.format returns a 400.

See also: 6.3 Output Handling