Decide when a summary agent should stay quiet

Agent buildEasy10 minMicrosoft and Anthropic style

Your task

An agent writes a summary for every pull request. A fluent wrong summary is worse than none, because it steers reviewers away from the code, so the agent has to know when to hold back.

Write pr_summary_decision(files_changed, lines_changed, generated_files, distinct_areas, has_linked_ticket): the rule your agent follows for each pull request.

  • files_changed, lines_changed (int): the size of the diff.
  • generated_files (int): how many of the changed files are generated (lockfiles, snapshots, build output).
  • distinct_areas (int): how many unrelated parts of the codebase the change touches.
  • has_linked_ticket (bool): the pull request links a ticket that explains why.

It returns one of the values in the rules below. Apply them in order. The first one that matches decides:

  1. files_changed or lines_changed is 0 or less: "withhold-no-evidence".
  2. More than 40 files, or more than 800 lines: "withhold-oversized".
  3. Half the files or more are generated (generated_files * 2 >= files_changed): "withhold-generated".
  4. 4 or more distinct areas: "withhold-mixed".
  5. A linked ticket, at most 1 area and at most 200 lines: "post-high".
  6. A linked ticket, or else both at most 2 areas and at most 400 lines: "post-medium".
  7. Otherwise: "post-low".

Examples

pr_summary_decision(files_changed: int, lines_changed: int, generated_files: int, distinct_areas: int, has_linked_ticket: bool) -> str
Example 1
Inputpr_summary_decision(3, 120, 0, 1, True)
Output"post-high"
Example 2
Inputpr_summary_decision(12, 600, 0, 5, True)
Output"withhold-mixed"
Example 3
Inputpr_summary_decision(30, 900, 0, 2, True)
Output"withhold-oversized"