Skip to content

git-diff Evaluator

The git-diff evaluator analyzes Git changes made by the AI agent and provides assertion-based pass/fail thresholds.

evaluators:
- name: git-diff

Without configuration, git-diff reports metrics without enforcing any limits.

evaluators:
- name: git-diff
config:
assertions:
max_files_changed: 5 # Maximum files that can be modified
max_lines_added: 100 # Maximum lines that can be added
max_lines_removed: 50 # Maximum lines that can be removed
max_total_changes: 150 # Maximum total changes (additions + deletions)
min_change_entropy: 0.5 # Minimum entropy (enforce distributed changes)
max_change_entropy: 2.0 # Maximum entropy (enforce focused changes)
AssertionDescriptionExample
max_files_changedMaximum number of files the agent can modify5
max_lines_addedMaximum lines that can be added100
max_lines_removedMaximum lines that can be removed50
max_total_changesMaximum total line changes (add + remove)150
min_change_entropyMinimum change distribution (prevents all changes in one file)0.5
max_change_entropyMaximum change distribution (prevents scattered changes)2.0

The evaluator produces the following metrics:

MetricTypeDescription
files_changednumberCount of modified files
lines_addednumberTotal lines added
lines_removednumberTotal lines removed
total_changesnumberSum of additions and deletions
change_entropynumberDistribution of changes across files
changed_filesstring[]Array of file paths
file_metricsobjectPer-file change statistics

Change entropy measures how distributed changes are across files:

  • Low entropy (< 1.0): Changes concentrated in few files
  • High entropy (> 2.0): Changes scattered across many files

Use entropy assertions to enforce:

# Require focused changes (single feature)
assertions:
max_change_entropy: 1.5
# Require distributed changes (refactoring)
assertions:
min_change_entropy: 1.0
{
"name": "git-diff",
"status": "passed",
"metrics": {
"files_changed": 3,
"lines_added": 45,
"lines_removed": 12,
"total_changes": 57,
"change_entropy": 1.23,
"changed_files": [
"src/auth/login.ts",
"src/auth/middleware.ts",
"tests/auth.test.ts"
],
"file_metrics": {
"src/auth/login.ts": { "added": 20, "removed": 5 },
"src/auth/middleware.ts": { "added": 15, "removed": 7 },
"tests/auth.test.ts": { "added": 10, "removed": 0 }
}
},
"assertions": {
"max_files_changed": { "expected": 5, "actual": 3, "passed": true },
"max_lines_added": { "expected": 100, "actual": 45, "passed": true }
}
}

Prevent agents from making excessive changes:

evaluators:
- name: git-diff
config:
assertions:
max_files_changed: 3
max_total_changes: 50

Ensure changes are focused on one file:

evaluators:
- name: git-diff
config:
assertions:
max_files_changed: 1

Allow more files but limit per-file changes:

evaluators:
- name: git-diff
config:
assertions:
max_files_changed: 20
max_lines_added: 500
min_change_entropy: 1.5
  1. Start permissive - Begin without assertions to understand typical change sizes
  2. Review metrics - Use results to set appropriate thresholds
  3. Combine with other evaluators - Use alongside agentic-judge for quality assessment
  4. Document thresholds - Explain why limits exist for future reference