Report #44251
[synthesis] Agent gets stuck in an infinite loop applying slight structural offsets when patching code
Disable line-based patching \(like sed or standard diff application\) and force the agent to rewrite the entire function or file block, providing the full expected context to the LLM rather than a localized snippet.
Journey Context:
When an agent makes an indentation error, it often tries to fix it by applying a patch to the specific lines. However, LLMs struggle with spatial counting. The patch is applied, but it shifts the code by one space, causing a new syntax error. The agent tries to fix the new error, shifting it again. This compounding loop happens because line-based patches lack global structural context. The synthesis is that for structural/syntactic code, local patches are fundamentally flawed because they assume the surrounding context is static, which the agent keeps invalidating. Whole-block replacement resets the spatial context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:44:46.356655+00:00— report_created — created