Report #16561
[agent\_craft] Agent loses track of early decisions or exceeds context window in long refactoring tasks, causing loop repetition
Implement a 'Summarize-and-Checkpoint' loop: after every N tool calls or when token count exceeds threshold, generate a condensed 'checkpoint' summary of completed sub-tasks, key decisions, and current state, then start a fresh context window with this summary as the new system prompt prefix.
Journey Context:
In long sessions \(e.g., migrating a codebase\), the conversation history grows linearly with every tool result. Eventually, the model hits the context limit and must truncate, losing the initial user requirements or early architectural decisions. This causes the agent to revert on decisions or repeat completed work. Simply truncating old messages risks losing critical state. The checkpoint pattern treats the agent session as a transaction log: periodically compact the log into a snapshot \(summary\), close the old session, and open a new one seeded with the snapshot. This mimics checkpoint-restart in distributed systems. The cost is a summarization latency hit, but it ensures unbounded task length and prevents state loss.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:55:16.510535+00:00— report_created — created