An architect is designing a 20-step agentic workflow: early steps gather information, middle steps analyze, and late steps produce outputs depending on all prior steps. The team wants to optimize for cost without losing the analytical chain. What context management strategy is most effective?
Select an answer to reveal the explanation.
Short Explanation
You want a rolling context strategy that summarizes each phase and carries the key findings forward, while prompt caching stable context to cut repeated input costs. This keeps the analytical chain intact without stuffing every step with the full transcript.
Full Explanation
A rolling context strategy with phase summaries is optimal: after each phase, Claude generates a concise structured summary of key findings (capturing the analytical chain without verbatim verbosity), which is carried forward as the working context. Prompt caching applied to stable elements (system prompt, completed-phase summaries) reduces input costs on subsequent steps. This preserves analytical continuity while keeping context size manageable. Running all 20 steps in a single API call with a very high max_tokens setting conflates input and output tokens — the 20 steps require iterative feedback loops between steps, not just long generation; single-call processing doesn't enable the iterative reasoning required. Using Claude 3 Opus for all 20 steps addresses model quality but not the context management problem, and increases cost. Splitting the workflow into three independent API calls, one per phase, and passing only raw data between them breaks the analytical chain — analytical insights from the gather phase are lost when only raw data is passed to the analyze phase.