· 2 min read
Building Agentic Loops That Write, Verify and Ship Code
How I design multi-agent workflows with Claude and GPT that plan, build, review and test code, and why the verification step matters more than the generation step.
By Sai Ram Sana
Most teams start with AI by pasting code into a chat window. That's useful, but it isn't agentic. An agentic system owns a goal from start to finish: it plans, acts through tools, checks its own work and decides what happens next.
Here's the loop I use in production.
1. Plan: decompose before you generate
A planner agent gets the goal plus context (relevant files, conventions, the ticket) and returns a short, ordered task list. Keeping the plan explicit makes every later step auditable.
2. Act: give the agent real tools
The builder agent doesn't just "write code". It reads files, runs commands, calls APIs and edits the repo through well-defined tools. Tool design is prompt design: narrow, well-named tools produce far more reliable behaviour than one giant "do anything" tool.
3. Verify: never trust a single model
This is where most setups fall short. My verification stage stacks independent checks:
- Deterministic gates: tests, type-checks and linters must pass.
- Cross-model review: a reviewer on a different model (for example GPT reviewing Claude's output) catches blind spots a model has about its own work.
- Schema and policy checks: structured outputs are validated before anything touches production data.
4. Decide: confidence-based routing
Not every change needs a human, and not every change should skip one. The loop scores confidence and routes accordingly: auto-ship, retry with feedback, or escalate to a human with a concise summary.
5. Learn: close the loop
Every run is logged. Failures become evaluation cases, so the same mistake is caught automatically next time.
The same pattern powers sales automation
The exact same Plan → Act → Verify → Decide loop drives my sales automation. Agents research accounts, score fit against specific ICP profiles and draft outreach, with verification and routing rules deciding what goes out automatically and what a rep reviews first.
Agentic AI isn't about the smartest model. It's about the most reliable system around the model.
Building something agentic?
I share build notes and connect with builders on LinkedIn.