Sub topic 9
Requesting changes and revising
This chapter covers the part of the pipeline where a reviewer rejects a draft and the draft comes back improved. It assumes you have read the earlier chapters on workflow states, approval gates, and review rubrics. You should also be comfortable reading short Python scripts.
Why the loop needs design
A review that ends in "needs work" is the normal case, not a failure. Without structure, the loop produces four problems:
- Vague comments that the author cannot act on.
- Fixes that quietly introduce new problems.
- Drafts that cycle between "in review" and "changes requested" forever.
- Edits made after approval that nobody re-checks.
Each problem has a mechanical remedy. This chapter builds those remedies into the state machine and the feedback format.
The states involved
Three states and four transitions make up the loop:
IN_REVIEWtoCHANGES_REQUESTED, made by the reviewer.CHANGES_REQUESTEDtoIN_REVIEW, made by whoever revised the text, after resubmitting.IN_REVIEWtoAPPROVED, made by the reviewer when nothing blocking is left.DRAFTtoIN_REVIEW, for the first submission.
There is deliberately no path from CHANGES_REQUESTED straight to APPROVED. A reviewer cannot approve text they have not seen again. The revise method from the earlier code only allows edits in DRAFT and CHANGES_REQUESTED, so text cannot change while a reviewer is reading it.
Escalated is not part of the base state machine from earlier chapters. It is an optional addition, described under "Stopping endless loops" below.
Writing change requests that can be acted on
A request that says "make it better" forces the author, or the model, to guess. A usable comment has four parts:
- The criterion from the rubric that the draft fails, such as accuracy, tone, or completeness.
- The location in the text.
- The requested change, stated as an outcome.
- Whether it blocks approval.
The fourth part matters most. Without it, a reviewer's preference ("consider a shorter sentence") carries the same weight as a factual error, and drafts stall on trivia. Blocking comments must be resolved before approval. Non-blocking comments are suggestions the author may take or leave.
import difflib
from dataclasses import dataclass
MAX_ROUNDS = 3
@dataclass
class Comment:
criterion: str
location: str
request: str
blocking: bool = True
resolved: bool = False
def open_blocking(comments):
return [c for c in comments if c.blocking and not c.resolved]
def next_step(round_number, comments):
if not open_blocking(comments):
return "approve"
if round_number >= MAX_ROUNDS:
return "escalate"
return "request changes"
v1 = "Our plan is guaranteed to work.\nPricing starts at $10.\n"
v2 = "Our plan is designed to work for most teams.\nPricing starts at $10 per month.\n"
comments = [
Comment("accuracy", "line 1", "Remove the guarantee; we cannot promise it."),
Comment("clarity", "line 2", "State the billing period."),
Comment("tone", "line 1", "Consider a shorter sentence.", blocking=False),
]
print(next_step(1, comments))
for c in comments[:2]:
c.resolved = True
print(next_step(2, comments))
for line in difflib.unified_diff(v1.splitlines(), v2.splitlines(), "v1", "v2", lineterm=""):
print(line)The first call prints request changes because two blocking comments are open. After the author addresses them, the second call prints approve. The unresolved non-blocking comment does not hold up the draft. The last loop prints a unified diff of the two versions, which is what the reviewer should read on the second pass.
Revising with an AI model
When the revision is done by a model, the way you prompt matters. There are two approaches:
| Approach | What you send | Risk |
|---|---|---|
| Regenerate | The original brief again | Fixed problems can return, and untouched parts change |
| Targeted revision | Current text, the comments, and an instruction to change only what is requested | Smaller edits, but the model may apply a comment too literally |
Prefer targeted revision. A prompt for it contains four things:
- The current text.
- The blocking comments, each with its criterion and location.
- The original brief, so the model keeps the audience and constraints.
- An instruction such as "Change only what the comments require. Leave every other sentence as it is."
Regeneration discards the work the reviewer already accepted. A reviewer who approved paragraphs one to four on round one should not have to re-verify them on round two because the model rephrased them.
After the model revises, run the same automated checks you ran before the first review. A fix for one comment can add a banned phrase or a TODO marker elsewhere, and a script catches that more cheaply than a person does.
A human can also do the revision. The pipeline should not care who edits, only that the edit goes through revise and is logged.
What the reviewer checks on resubmission
The second review is narrower than the first, but not empty. The reviewer should do these things:
- Read the diff to see every change, including ones nobody asked for.
- Confirm each blocking comment is resolved, and mark it so.
- Look at the text around each change, since a fix can break a sentence's context.
- Read any passage the diff shows as changed but that had no comment against it.
Step 4 catches the most common regression with model revisions: unrequested edits. If the diff shows changes with no matching comment, send them back or ask why.
Handling several reviewers
When two reviewers comment on the same draft, their requests can conflict. One wants a shorter introduction and the other wants more context added. Do not let the author pick silently. Define one of these rules in advance:
- A named lead reviewer decides which comment wins.
- The conflict goes back to the reviewers to settle, and the draft waits.
Record the outcome as a note on the transition so the log shows why a comment was not applied.
Stopping endless loops
Some drafts never converge. The brief may be unclear, the reviewer's standard may keep moving, or the source material may be inadequate. The usual guard is a round limit, like MAX_ROUNDS in the code above. When a draft reaches the limit with blocking comments still open, it is not rejected again. It goes to a person with authority over the brief, who decides whether to rewrite the brief, change the reviewer, or drop the piece.
Three rounds is a reasonable default. If you see many drafts hit the limit, the problem is upstream, in the brief or the rubric, and not in the drafting.
Edits after approval
Once an item is APPROVED, its text is fixed. If someone spots a typo, the correct path is to move the item back through review, not to edit it in place. In the earlier state machine, the stored approved_digest makes publish fail whenever the text differs from what was approved, so an in-place edit blocks publishing and never slips past it.
For a trivial fix you may allow a lighter path: a reviewer re-approves after reading only the diff. That is a policy choice. Make it explicit, restrict it to low-risk tiers, and log it. Do not leave it as an unwritten habit.
Keeping revisions traceable
Each trip around the loop should add log entries for:
- Who requested changes, and the comments they gave.
- Who revised the text, and the digest of the new version.
- Who resubmitted, and when.
The revise method records a digest of each edit. That lets you later show that the text published is the text approved, and also lets you reconstruct how the draft got there. Store the comments themselves with the item, not in a chat thread, so the reason for a change survives.
Common errors
- Approving without reading the diff. The reviewer trusts that the fixes match the comments. Make the diff the default view.
- Treating every comment as blocking. Drafts stall on style preferences. Require reviewers to mark which comments block.
- Regenerating instead of revising. Accepted passages change and review effort is repeated.
- Skipping automated checks on revisions. Fixes reintroduce mechanical problems.
- No round limit. One unclear draft can sit in the loop for weeks.
- Resolving comments silently. The author marks them done with no note, and the reviewer cannot tell how.
Exercise
A reviewer requests changes on a draft. The author, using a model, regenerates the whole piece from the original brief and resubmits. On round two the reviewer finds a factual error in a paragraph they had accepted in round one. What went wrong, and what should change in the process?
Show answer
Regenerating from the brief discarded the accepted text, so the model produced new wording that included a new error. The process should use targeted revision: give the model the current text, the blocking comments, and an instruction to change only what the comments require. The reviewer should also read the diff, which would have shown the unrequested changes.
Exercise
In the code above, next_step(3, comments) is called with one blocking comment still open. What does it return, and why is that better than returning "request changes" again?
Show answer
It returns "escalate", because the round number has reached MAX_ROUNDS. Sending the draft back a fourth time would repeat a loop that has already failed to converge. Escalation hands the decision to someone who can fix the underlying cause, such as an unclear brief or conflicting reviewer standards.