doc/agents/common-mistakes.md
Patterns observed across multiple AI agent interactions on the ProxySQL codebase, with root cause analysis and prevention strategies.
Symptom: PR targets v3.0 (main) instead of the feature branch.
Root cause: Agents prioritize technical content over administrative instructions. Even when branch info is present in the issue, agents often skim past it while focusing on code requirements, then use heuristics (e.g., most recent branch, default branch) to fill the gap they don't realize they have.
Prevention: Place git workflow instructions at the very top of the issue, before the technical description. Agents read top-down with decreasing attention — administrative details buried after exciting code specs will be skipped.
### FIRST: Git workflow (do this before reading anything else)
- Create branch `v3.0-XXXX` from `v3.0-5473`
- PR target: `v3.0-5473`
Detection: Check gh pr view <number> --json baseRefName after PR creation.
Symptom: Test file contains copy-pasted reimplementations of the functions under test. Tests validate the copy, not the real production code.
Root cause: Agent doesn't know the build system links tests against libproxysql.a, so it creates standalone tests that don't depend on the library.
Prevention:
libproxysql.a (the real functions are available at link time)Detection: grep -c "static.*calculate_eviction\|static.*evaluate_pool" test_file.cpp — if > 0, functions were reimplemented.
Symptom: Test placed in test/tap/tests/ (E2E test directory) instead of test/tap/tests/unit/ (unit test directory).
Root cause: Agent sees existing test files in test/tap/tests/ and follows that pattern. Doesn't know about the unit/ subdirectory.
Prevention: Specify the exact file path including directory in the issue deliverables.
Detection: ls test/tap/tests/*unit* should return nothing — unit tests belong in test/tap/tests/unit/.
Symptom: Test file manually defines noise_failures, noise_failure_mutex, stop_noise_tools(), get_noise_tools_count().
Root cause: Agent compiles tap.cpp which references these symbols. Without the harness, the agent must define them. This is a signal the agent isn't using the harness.
Prevention:
test_globals.cpp already provides all TAP stubsDetection: grep -c "noise_failures\|stop_noise_tools" test_file.cpp — if > 0, harness not used.
Symptom: PR diff includes dozens of unrelated files because the agent ran git merge <upstream> into its branch.
Root cause: Agent's default strategy for incorporating upstream changes is merge. This creates a merge commit that brings all upstream changes into the PR diff.
Prevention: Explicit instruction: "Use git rebase, NOT git merge."
Detection: git log --merges <branch> --not <base> — any merge commits indicate merging.
Symptom: Production code compiles on the agent's machine (or doesn't get tested) but fails in CI or on other platforms with "unknown type name" errors.
Root cause: ProxySQL has circular include chains (proxysql.h → cpp.h → MySQL_HostGroups_Manager.h → Base_HostGroups_Manager.h → proxysql.h). Placing new declarations in these headers can result in the declarations being invisible depending on include order.
Prevention:
ConnectionPoolDecision.h)make build_lib -j4 as a verification stepDetection: Compilation failure with "unknown type name" for a type that clearly exists in a header.
Symptom: Agent adds tests to an existing test file instead of creating a new one for the new feature.
Root cause: Agent sees a test file for a related component and assumes new tests belong there.
Prevention: Specify the exact test file name in the issue: "Create test/tap/tests/unit/my_feature_unit-t.cpp."
Symptom: PR contains code that doesn't compile. Agent submitted without building.
Root cause: Some agents don't have access to the build environment, or don't run the build as part of their workflow.
Prevention:
make build_lib -j4 must exit with code 0"Symptom: Agent refactors callers, updates documentation, fixes unrelated bugs, or "improves" code outside the task scope.
Root cause: Agent optimizes for perceived quality/completeness and makes changes it considers beneficial.
Prevention:
<list of files>"Quick checks to run on any agent-generated PR:
# Wrong base branch?
gh pr view <PR> --json baseRefName -q '.baseRefName'
# Test in wrong directory?
gh pr diff <PR> | grep "^+++ b/test/tap/tests/[^u]"
# Reimplemented functions?
gh pr diff <PR> | grep "^+static.*calculate_\|^+static.*evaluate_\|^+static.*should_"
# Manual TAP stubs?
gh pr diff <PR> | grep "^+.*noise_failures\|^+.*stop_noise_tools"
# Merge commits?
gh pr view <PR> --json commits --jq '.commits[].messageHeadline' | grep -i merge
# Unrelated files changed?
gh pr diff <PR> | grep "^+++ b/" | grep -v "<expected_files_pattern>"