Building a Multi-Agent Verification Loop in Python with Small Open Models

The modern era of artificial intelligence is defined by the rapid proliferation of multi-agent frameworks, a technological paradigm shift that has moved beyond the capabilities of monolithic, single-query systems. Industry-standard architectures such as AutoGen and LangGraph have set the stage for complex problem-solving by allowing large language models (LLMs) to interact, critique, and refine their own outputs. However, this transition toward modular, multi-step workflows has introduced a significant architectural challenge: the "token tax." As developers stack models in sequential graphs to improve output accuracy, they face a compounding cost in both computational resources and end-to-end latency. This article examines the technical implementation of a Proposer-Critic-Judge verification loop using small open-source models, providing a framework for engineers to balance the trade-off between reasoning robustness and operational efficiency.
The Architectural Shift Toward Agentic Workflows
The current AI landscape is shifting away from simple prompt-response interactions toward iterative, agentic workflows. By incorporating a verification loop—specifically the Proposer-Critic-Judge architecture—developers can force a model to simulate multiple cognitive stages. The Proposer initiates a solution, the Critic evaluates that solution for logical consistency, and the Judge aggregates these inputs to provide a final, verified response.
This methodology mirrors the "Chain-of-Thought" (CoT) prompting techniques that have become standard for improving performance in reasoning tasks. However, implementing these as distinct agents usually requires significant VRAM overhead, as loading three separate model instances would exceed the capacity of most consumer-grade hardware. For instance, while a standard Nvidia T4 GPU on cloud platforms like Google Colab provides 16GB of VRAM, running three instances of a 7-billion-parameter model simultaneously is technically infeasible without extreme quantization or model offloading.
Implementing Persona Multiplexing
To overcome these memory limitations, engineers have turned to "persona multiplexing." This technique involves loading a single, highly capable base model—such as the Qwen2.5-7B-Instruct—and dynamically swapping its system prompt to redefine its behavioral role at each stage of the loop. By employing 4-bit quantization via the bitsandbytes library, developers can drastically reduce the memory footprint of the model, enabling the execution of a multi-agent loop within a single, constrained environment.
The process begins by installing the necessary dependencies, including transformers, accelerate, and torch. After initializing the model in a 4-bit precision format, the system relies on a unified function—generate_and_measure()—to handle inference. This function serves a dual purpose: it executes the generation task while simultaneously acting as an instrumentation layer. By tracking input tokens, output tokens, and the execution time (latency), this function provides the granular data required to calculate the true cost of the agentic process.
Defining Cognitive Roles: The Proposer, Critic, and Judge
The efficacy of the multi-agent loop hinges on the specificity of the system prompts assigned to each persona. In this architecture:
- The Proposer: Tasked with providing a concise, direct answer. It operates as the baseline agent, often prone to the common "fast-thinking" errors found in small models when faced with complex logic.
- The Critic: Acting as a rigorous verifier, the Critic is instructed to perform independent, step-by-step calculations. It must compare its internal logic against the Proposer’s output. If it detects a flaw, it explains the discrepancy; if it finds the logic sound, it outputs a "No flaws found" signal.
- The Judge: The final arbiter. The Judge reviews the original task, the Proposer’s initial attempt, and the Critic’s analysis. If the Critic flags an error, the Judge integrates the corrected logic to generate the final, reliable response.
Empirical Testing and the "Token Tax"
To evaluate the system, one might use a classic reasoning trap: "Bob is 20 years old. Alice is half Bob’s age. When Bob is 100 years old, how old will Alice be?"
A single-agent (baseline) model frequently fails this test by performing a simple arithmetic operation (100 / 2 = 50), ignoring the fact that the age gap between two individuals remains constant over time. When running this through the verification loop, the Proposer often falls into this trap. However, the Critic, when forced to calculate the difference (20 – 10 = 10) independently, identifies the flaw in the Proposer’s logic. The Judge then synthesizes these findings to reach the correct answer: 90 years.
The data reveals a stark reality regarding the cost of this reliability. While the baseline model produced an answer in approximately 2.63 seconds using 85 tokens, the multi-agent loop required 16.67 seconds and 660 tokens. This represents a 6.3x increase in latency and a 7.8x "token tax."
Implications for AI Engineering
The analysis of these metrics suggests that the Proposer-Critic-Judge architecture is not a panacea for all AI tasks. For simple, high-frequency queries, the overhead of the verification loop is unjustifiable. The latency incurred by sequential processing could lead to poor user experiences in real-time applications.
However, in domains where accuracy is non-negotiable—such as legal documentation, medical triage, or complex mathematical problem-solving—the trade-off is often essential. The "token tax" is effectively the price paid for robustness. By moving from a "fast-thinking" single agent to a "slow-thinking" multi-agent verification loop, developers can effectively mitigate the hallucinations and logical failures that remain the Achilles’ heel of smaller, more efficient open-source models.
Future Perspectives in Multi-Agent Design
The successful implementation of this architecture on hardware as constrained as a T4 GPU signals a broader trend in the industry: the decentralization of intelligence. Rather than relying on massive, monolithic models that require exorbitant infrastructure, developers are increasingly finding ways to extract high-level reasoning from smaller, specialized models through clever orchestration.
As the ecosystem matures, we expect to see further optimization of these loops. Potential advancements include "caching" the critique phase, where identical or similar logic patterns are recognized, or using distilled models specifically trained for the role of "Critic." Furthermore, the integration of asynchronous processing may allow for the parallelization of verification steps, potentially reducing the latency impact that currently hinders these systems.
In conclusion, building a multi-agent verification loop requires a disciplined approach to prompt engineering and a clear understanding of the operational costs involved. While the computational overhead is significant, the ability to turn a predictable failure into a verified success provides a blueprint for building reliable, agent-driven systems in an increasingly complex AI-integrated world. The "token tax" is not merely an expense, but a measurable investment in the integrity of the final output.







