Report #26186
[agent\_craft] Few-shot bug fix examples cause agent to hallucinate similar bugs in working code or apply wrong fixes by pattern matching
For debugging tasks, use zero-shot prompting with explicit instruction to 'explain the error trace line by line before proposing a fix' rather than providing examples of correct fixes. If examples are necessary, use examples of error analysis \(not solutions\) to teach diagnostic process over solution patterns.
Journey Context:
Conventional wisdom suggests few-shot examples improve performance, but for debugging, providing solved examples creates a 'solution template' bias. The agent starts looking for patterns that match the example solution rather than analyzing the specific semantics of the error message. Zero-shot with forced error trace explanation \(the Self-Debug approach\) forces the model to actually process the stack trace and variable states. Examples of error analysis \(e.g., 'This is a TypeError because...'\) are safer than examples of fixed code because they teach the diagnostic process rather than the solution pattern. Trade-off: Zero-shot may require more tokens for reasoning but reduces hallucination of non-existent bugs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:21:20.922851+00:00— report_created — created