This is the reference solution for the AI110 Module 5 Tinker BugHound. BugHound already ran
end-to-end in the starter — this lab is about judgment, so the solution applies one deliberate
design change per part on top of the working system and documents the reasoning in
model_card.md. It is one reasonable set of choices, not the only correct one.
Starter repo:
ai110-module5tinker-bughound-starter
- [Part 2 — reliability]
analyze()now falls back to the heuristic analyzer if the LLM returns an issue whoseseverityisn't one ofLow/Medium/High(_severities_valid). - [Part 3 — risk policy]
should_autofixnow also requires that no High-severity issue is present, regardless of the numeric score. - [Part 4 — guardrail + test]
assess_riskrefuses to auto-apply a fix that rewrites more than 50% of the lines (MAX_AUTOFIX_CHANGE_RATIO); new tests cover the invalid-severity fallback and the over-editing guardrail. - [Part 5]
model_card.mdis filled in with grounded observations from the sample files.
All changes are small, single-purpose, and produce a different decision on the same input —
which is the point of the lab. pytest shows 10 passing tests (8 original + 2 new), all offline.
Given a short Python snippet, BugHound:
-
Analyzes the code for potential issues
- Uses heuristics in offline mode
- Uses Gemini when API access is enabled
-
Proposes a fix
- Either heuristic-based or LLM-generated
- Attempts minimal, behavior-preserving changes
-
Assesses risk
- Scores the fix
- Flags high-risk changes
- Decides whether the fix should be auto-applied or reviewed by a human
-
Shows its work
- Displays detected issues
- Shows a diff between original and fixed code
- Logs each agent step
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# or
.venv\Scripts\activate # Windowspip install -r requirements.txtNo API key required.
streamlit run bughound_app.pyIn the sidebar, select:
- Model mode: Heuristic only (no API)
This mode uses simple pattern-based rules and is useful for testing the workflow without network access.
Copy the example file:
cp .env.example .envEdit .env and add your Gemini API key:
GEMINI_API_KEY=your_real_key_here
streamlit run bughound_app.pyIn the sidebar, select:
- Model mode: Gemini (requires API key)
- Choose a Gemini model and temperature
BugHound will now use Gemini for analysis and fix generation, while still applying local reliability checks.
Tests focus on reliability logic and agent behavior, not the UI.
pytestYou should see tests covering:
- Risk scoring and guardrails
- Heuristic fallbacks when LLM output is invalid
- End-to-end agent workflow shape