r/opencodeCLI • • 6d ago

Having a second agent review the plan before OpenCode writes any code

When an agent builds straight from a prompt, the misunderstandings show up late, as a diff that touches files nobody meant to change or skips a case that seemed obvious. By then the fix is a debugging session.

Splitting the work into a plan step and a build step works much better. The agent first asks what done means, reads the relevant code and writes a plan: the files it will touch, the steps, what is out of scope, and the checks that prove each point. Before I approve it, a different installed agent reads that plan cold and lists what is missing or risky, so the gaps get answered while they are still cheap.

After approval the build runs test first in small slices. Agents that did not write the code then check the result against every agreed point and record evidence, and I approve the finished change before a pull request opens. Nothing gets merged or pushed without my yes.

I built QualityLayer around this loop, and it runs natively in OpenCode. I'm the developer: https://github.com/maxritter/qualitylayer

8 Upvotes

13 comments sorted by

3

u/SirRobinBlibs 6d ago

A cold second agent is useful, but only if it has to reject something. I'd give the reviewer a short fail checklist (scope creep, missing tests, files outside the plan) and require it to either request changes or sign the plan, not just say it looks good.

I'd also keep that review in a fresh session so it doesn't see the first agent's chain of thought, otherwise it tends to agree with the plan it just watched being written.

1

u/m-ritter 6d ago

Thanks, that matches what I see. A reviewer that is allowed to just say looks good mostly does exactly that. Forcing it to either list concrete changes or sign off, and keeping it out of the first agent's session, is what makes it useful. Which item on your fail list catches the most in practice?

1

u/SirRobinBlibs 6d ago

I'd bet on files outside the plan, because it's the one a reviewer can check mechanically: list the files the plan names, diff that against what the build touched, and anything extra needs a reason. Missing tests is next. Scope creep is the fuzziest, so it's the one a reviewer lets slide most easily.

1

u/m-ritter 6d ago

Good point, that one is cheap to check and hard to argue with. Diffing the files the plan names against what the build touched turns a judgment call into a list. Scope creep is where I still want to look myself, because the agent usually has a plausible reason for every extra change, and that is exactly the part I want an engineer to decide.

1

u/Praistaly 2d ago

100%, letting the reviewer see the original chain of thought basically ruins the whole point of a cold review

1

u/Senior-Assumption864 6d ago

do you keep the reviewer in a fresh session every time or only for bigger changes?

1

u/m-ritter 6d ago

Every time, not only for big changes. The reviewer gets the written plan and the code, never the planning chat, so it has no reason to agree with what it watched being written. On a small change the review is short anyway.

1

u/Senior-Assumption864 6d ago

makes sense, thanks for explaining

1

u/ChemicalExcellent463 6d ago

i use a different model in a fresh session too, but cap plan review at 5 rounds. how many rounds does a plan usually take before you approve it?

1

u/perfektcrash 5d ago

Not OP but I cap it at one round. The reviewer either approves or hands back one patch, and if that still doesn't fit, it stops and asks me instead of the two agents going back and forth. Past the first round it's mostly the two of them negotiating, not either one checking.

One OpenCode-specific thing that bit me: run the reviewer as --agent plan. With a local model behind it, my reviewer edited the files itself to fix what it found, then said APPROVE. That's the reviewer marking its own homework. The plan agent can't edit, so the fix has to come back as text and go through the same checks as everything else.

(I build a small tool that runs this build-then-review setup, Atlas ADE, free and MIT: https://atlas-ade.dev/docs/how-it-flies)

1

u/ChemicalExcellent463 5d ago

a reviewer fixing the files and then approving its own fix is a nasty one. has a hosted model ever done that to you?

0

u/[deleted] 6d ago

[removed] — view removed comment

1

u/m-ritter 6d ago

Same experience here. The same model reviewing its own plan shares its blind spots, so it nods along. A different model family finds the gaps much faster. Which pairing works best for you?