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
Think of the context window like a whiteboard that only holds so much. As you process more files, early instructions slide off the edge. Periodically write a tight summary of the rules back onto the board so the agent always has them in view.
Full Explanation
Large language model-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.
The correct fix is injecting a compact conventions summary, such as a condensed rules block, at regular checkpoints, every fixed number of files or tokens, to keep the most important context fresh and within the active window. This is a standard technique for long-horizon agent tasks.
The idea that the agent's model weights are corrupted during long runs and the model server must be restarted is wrong because model weights are not modified during inference. Corrupting model weights is not a real failure mode for standard hosted models. The issue is runtime context, not weight storage.
The idea that the agent is encountering merge conflicts that reset its working memory and all conflicts must be resolved before starting is wrong because merge conflicts are a file system and version control issue unrelated to the agent's working memory or context window. Resolving conflicts does not restore lost context.
The idea that long tasks require more compute and the runner machine must be scaled up to maintain consistency is wrong because 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.