Subdomain 1.2: Agent Construction with Claude
1.A long-running agent session is approaching its context window limit. The team wants two things: a full, unabridged copy of the conversation saved before the SDK summarizes older history, and a guarantee that a specific formatting rule survives every compaction event without being paraphrased away. Which combination of mechanisms addresses both needs?
- A.Register a PreCompact hook to archive the full transcript first, and put the formatting rule in CLAUDE.md so it reloads on every request instead of living only in the initial prompt.
- B.Increase max_turns so compaction never triggers, and repeat the formatting rule at the start of every single user message sent throughout the session.
- C.Rely on the automatic compaction summary alone to preserve both the transcript and the formatting rule, since summaries are designed to retain conversation details verbatim.
- D.Register a PostToolUse hook to archive the transcript after each tool call completes, and place the formatting rule inside a subagent's AgentDefinition prompt instead of the main session.
Show answer & explanation
Correct answer: A — Register a PreCompact hook to archive the full transcript first, and put the formatting rule in CLAUDE.md so it reloads on every request instead of living only in the initial prompt.
- A. Correct. A PreCompact hook fires before compaction and is the documented mechanism for archiving the full transcript first, and CLAUDE.md is reloaded and re-injected on every request, so a rule placed there survives compaction rather than being paraphrased away as an early-conversation instruction would be.
- B. Compaction triggers based on the context window approaching its limit, not on turn count, so raising max_turns does not prevent it; manually repeating the rule in every message is also fragile and does not match the documented CLAUDE.md pattern.
- C. Compaction is explicitly described as summarizing older history, which can lose specific instructions from earlier in the conversation; it is not documented as preserving details verbatim.
- D. A PostToolUse hook fires after individual tool calls, not immediately before a compaction event, so it does not reliably archive the transcript at the right moment; placing the rule in a subagent's prompt also does not affect the main session's own compaction behavior.