Report #83041
[agent\_craft] Agent generates code that includes commented-out reasoning steps or 'Let me think...' prose inside the final code output
Explicitly instruct in the system prompt: 'Do not include chain-of-thought commentary inside code blocks. Place all reasoning outside code fences or in a separate block before the solution.' Use stop sequences or output parsers to strip any text between and from the final artifact.
Journey Context:
When reasoning models \(Claude 3.7 Sonnet with extended thinking, o1, o3-mini\) or even regular models with CoT prompting are used for coding, they often leak reasoning steps into code comments or docstrings. This pollutes the codebase and can break syntax highlighting or static analysis. The root cause is ambiguous output structure: the model thinks it should 'show its work' inside the code because the prompt didn't specify where reasoning belongs. Anthropic's extended thinking docs warn that reasoning content may leak into artifacts if not explicitly constrained.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:58:25.884060+00:00— report_created — created