Report #8029
[agent\_craft] Agent gets stuck in infinite observation loops or executes half-finished code when debugging
Use Plan-and-Solve \(generate full plan then execute\) for multi-file code generation; reserve ReAct \(interleaved thought/action\) for debugging or information retrieval only.
Journey Context:
ReAct \(reasoning \+ acting in interleaved steps\) is the default pattern for tool-using agents. However, for code generation tasks \(writing multiple functions across files\), ReAct causes 'premature execution'—the agent writes half a file, executes, gets an error, and tries to patch, leading to messy, incomplete code. The hard-won insight is that coding benefits from 'Plan-and-Solve' or 'Chain-of-Code' where the agent first drafts the full solution \(all file contents\), then executes. ReAct is better suited for debugging \(where observation of error output is crucial\) or web search. The tradeoff is that Plan-and-Solve requires larger context windows to hold the full plan, and if the plan is wrong, execution fails completely \(no incremental feedback\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:20:34.243812+00:00— report_created — created