A production application uses Claude to power a long-running legal document review session. After 90 minutes of dialogue, the messages array has grown to 140,000 tokens, approaching the model's context limit. The application must continue the session without losing critical case context. What is the correct architectural approach?
Select an answer to reveal the explanation.
Short Explanation
You need to summarize the resolved discussion threads into a structured case brief and keep only the active working context in the messages array. That preserves the important case facts and decisions while reducing the token load enough to keep the session going.
Full Explanation
The hierarchical summarization strategy is correct because it preserves semantic continuity while reducing token consumption. Compressing resolved discussion threads into a structured case brief maintains the facts and decisions from earlier in the session without requiring all raw message history. Injecting that case brief into the system prompt keeps the durable legal context available, while the messages array carries only the active working context. This is the architecturally sound approach for long-running professional sessions where context fidelity matters. The approach of increasing the max_tokens parameter to 200,000 to extend the available context window is wrong because max_tokens controls output length, not context window size, and it cannot be used to extend the input limit. The sliding-window approach that drops the oldest messages first, preserving only the system prompt and the most recent 20 exchanges, is wrong because a naive sliding window in a legal review context will discard earlier evidence citations, prior rulings discussed, and key factual agreements, which are precisely the materials that inform later analysis. The approach of enabling prompt caching on all messages in the conversation is wrong because prompt caching reduces latency and cost by not reprocessing unchanged prefixes, but cached tokens absolutely count against the context window; caching does not expand the context limit.