Skip to content

fix(agent): inject repo context and file contents during self-correction - #4

Merged
andrewevans0102 merged 1 commit into
mainfrom
fix/repo-context-and-self-correction
Nov 3, 2026
Merged

andrewevans0102 merged 1 commit into
mainfrom
fix/repo-context-and-self-correction

Conversation

@andrewevans0102

Copy link
Copy Markdown
Owner

Problem

When GitHound handles new issues or review comments:

  1. handleIssueIntake was never passed repoContext from index.ts, forcing the model to generate file edits in the dark without awareness of existing code structure, exports, or test suites.
  2. During the self-correction gate loop (generateCorrection), only the raw test failure summary was provided. The model was not given the current on-disk contents of previously edited files, nor the failing test files.
  3. This frequently caused the model to oscillate between fixing test assertions and breaking module exports or foundational structures, exhausting the retry limit (e.g. repeatedly failing npm test with missing exports or missing assertions).

Solution

  • Automatic Repo Context Extraction (extractRepoContext): Automatically gathers the repository file tree and readable source/test files to give the LLM upfront visibility into existing functions, types, and test expectations.
  • Enhanced Failure File Detection (extractFailureRelatedFiles): Inspects test and compiler error outputs and reads any referenced test or source files into the prompt.
  • On-Disk File Snapshot for Self-Correction: Passes current on-disk contents of modified files and failing test files to generateCorrection.
  • Target File Content in PR Reviews: Includes full target file contents in ReviewContext to prevent truncation of imports and exports.
  • Explicit Prompt Guardrails: Instructs the model to inspect existing exports and tests and preserve required module signatures.

@andrewevans0102
andrewevans0102 merged commit eae6fae into main Nov 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant