Report #75958
[agent\_craft] CoT reasoning interleaved with code generation produces unexecutable pseudo-code or excessive comments
Split into two calls: first, generate a structured plan \(JSON outline\), then generate code with the plan as context but without CoT instructions in the final prompt.
Journey Context:
Asking the model to 'think step by step' inside a single code generation prompt seems efficient, but it trains the model to output natural language explanations between lines of code, breaking syntax. We tried regex cleanup, but it's fragile. The robust pattern is a 'plan-then-execute' pipeline: Call 1 generates a structured plan \(nodes/edges or steps\), which is injected into Call 2's context. This keeps the generation prompt clean of 'thinking' instructions, yielding pure, parseable code. The latency cost is worth the accuracy gain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:05:39.345957+00:00— report_created — created