Report #80661
[agent\_craft] Generated code violates project-specific conventions despite detailed style guidelines in system prompts
Retrieve 2-3 semantically similar examples from the existing codebase using embedding search and include them as few-shot examples in the user prompt, not just instructions
Journey Context:
Zero-shot style guides \('Use TypeScript strict mode'\) are too abstract; agents default to training-data biases. Few-shot with random examples helps, but similarity matters most. The RAG-style few-shot pattern: \(1\) Embed the current task description. \(2\) Search codebase for the top-3 most similar existing implementations using vector similarity. \(3\) Inject these in the prompt as 'Here are similar implementations in this repo: \[Example 1\] \[Example 2\]'. This grounds the agent in actual local patterns—naming conventions, error handling, import styles—far better than generic rules. Accuracy improves 30-50% for boilerplate generation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:59:50.267067+00:00— report_created — created