A GitHub Copilot agent running a long refactoring task begins producing inconsistent edits after processing 40 files. The agent seems to 'forget' the coding conventions it followed earlier. What is the most likely cause and the correct fix?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Think of the context window like a whiteboard that only holds so much. As the agent processes more files, early instructions slide off the edge. The fix is to periodically write a tight summary of the rules back onto the board so the agent always has them in view.
Full explanation below image
Full Explanation
LLM-based agents operate within a finite context window. As a long task accumulates tool outputs, file contents, and intermediate reasoning, the earliest tokens — including the original system prompt instructions, coding conventions, and success criteria — can be pushed beyond the active context window. This causes the agent to behave as if it never received those instructions.
Why B is correct: Injecting a compact conventions summary (e.g., a condensed rules block) at regular checkpoints — every N files or every M tokens — keeps the most important context fresh and within the active window. This is a standard technique for long-horizon agent tasks.
Why A is wrong: Model weights are not modified during inference. A 'corrupting' model weight is not a real failure mode for standard hosted models. The issue is runtime context, not weight storage.
Why C is wrong: Merge conflicts are a file system / version control issue unrelated to the agent's working memory or context window. Resolving conflicts does not restore lost context.
Why D is wrong: Context window capacity is determined by the model architecture, not the runner's compute resources. Scaling up the runner machine changes throughput and speed, not the model's context limit.
Practical patterns for long-horizon tasks include: rolling summaries, structured memory stores written to a file and injected at each step, and splitting the task into smaller batches that each fit comfortably within the context window.