Question 36
Domain 5An iterative refactor agent edits the same file repeatedly across many turns and contexts pile up. Which discipline aligns with documented practice for keeping iterations efficient at scale?
Correct answer: A
Explanation
This matches the documented context-management discipline of keeping the working state compact between phases so the agent does not carry every prior turn forward. Using a checkpoint summary, plus “view-by-range” and “trim-tool-output,” preserves the needed refactor state while reducing context growth and keeping iterations efficient at scale.
Why each option is right or wrong
A. Compact at checkpoints between iteration phases (e.g., end of each major refactor pass), summarising the previous turns into the agent's working state and continuing iteration from the summary; combine with view-by-range and trim-tool-output disciplines from context-management.
The documented practice is to checkpoint at phase boundaries and replace the accumulated turn history with a concise working summary, rather than letting every prior edit remain in context; that is the mechanism that keeps repeated refactors from becoming quadratic in prompt size. In the same context-management discipline, view-by-range limits inspection to the relevant file segment and trim-tool-output suppresses verbose tool traces, so the agent preserves only the active refactor state while controlling context growth across many iterations.
B. Always retain every turn; compaction loses information.
Keeping every turn increases context bloat; summaries are meant to retain essential state efficiently.
C. Restart the agent from scratch on each iteration; restart is the simplest mechanism.
Restarting each iteration throws away useful working state and usually adds repeated setup overhead.
D. Disable iteration; long loops are unreliable.
Iteration itself is valuable; the issue is unmanaged context growth, not looping as a concept.