fix: prevent false-positive missing-import findings
The LLM was treating the diff as complete file context and flagging "missing imports" for symbols that exist in unchanged portions of the file. Added explicit instructions to the system prompt: - Clarify that the diff is partial; unchanged code already exists - Explicitly instruct: do not flag missing imports/types unless the diff introduces a new usage without a corresponding addition - Add rule: never flag undefined symbols that could exist in the unchanged portions
This commit is contained in:
@@ -10,6 +10,11 @@ func BuildSystemPrompt(conventions string) string {
|
||||
var sb strings.Builder
|
||||
|
||||
sb.WriteString("You are an expert code reviewer. Review the provided pull request diff carefully.\n\n")
|
||||
sb.WriteString("IMPORTANT CONTEXT:\n")
|
||||
sb.WriteString("- You are reviewing a DIFF, not the complete file. Code not shown in the diff already exists in the repository.\n")
|
||||
sb.WriteString("- Imports, type definitions, functions, and other declarations that do not appear in the diff are already present in the file.\n")
|
||||
sb.WriteString("- Do NOT flag missing imports, missing type definitions, or undefined references unless the diff itself introduces a new usage without a corresponding addition in the same diff.\n")
|
||||
sb.WriteString("- Only flag issues with code that is actually being ADDED or MODIFIED in this diff.\n\n")
|
||||
sb.WriteString("Your task:\n")
|
||||
sb.WriteString("1. Review the diff for correctness, idiomatic code, potential bugs, and design issues.\n")
|
||||
sb.WriteString("2. Consider the CI status — if CI has failed, that is an automatic REQUEST_CHANGES regardless of code quality.\n")
|
||||
@@ -35,6 +40,7 @@ func BuildSystemPrompt(conventions string) string {
|
||||
sb.WriteString("- Be thorough but fair. Don't nitpick style unless it impacts readability significantly.\n")
|
||||
sb.WriteString("- Line numbers should reference the new file line numbers from the diff headers.\n")
|
||||
sb.WriteString("- If the diff is empty or trivial (only formatting/whitespace), APPROVE with no findings.\n")
|
||||
sb.WriteString("- Never flag 'missing imports' or 'undefined' errors for symbols that could exist in the unchanged portions of the file.\n")
|
||||
|
||||
if conventions != "" {
|
||||
sb.WriteString(fmt.Sprintf("\n\nThe repository has the following coding conventions that should be respected:\n\n%s\n", conventions))
|
||||
|
||||
Reference in New Issue
Block a user