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

The Rise of Multi-Agent Architectures
In recent years, frameworks like AutoGen and LangGraph have surged in popularity, promising to revolutionize how software handles complex reasoning tasks. By allowing multiple autonomous agents to interact, developers can simulate a collaborative environment where one agent proposes a solution, another critiques it, and a final arbiter ensures the output meets quality standards. This architecture, often termed the Proposer-Critic-Judge (PCJ) pattern, is inspired by human peer-review processes.
However, the industry has reached a point of diminishing returns. When developers deploy three distinct, large-scale LLMs to fulfill these roles, the memory requirements often exceed the capacity of consumer-grade hardware or standard cloud instances like the Nvidia T4 GPUs commonly available on platforms such as Google Colab. The challenge for modern engineers, therefore, is not merely architectural, but tactical: how can we implement these sophisticated loops while maintaining efficiency?
The Technical Constraint: Memory and Latency
The fundamental barrier to widespread multi-agent adoption is the "token tax." Every additional node in a graph-based agent workflow necessitates new prompt processing, generation time, and API costs. When each agent is treated as a separate instance, the latency compounds, often leading to a degradation in user experience that outweighs the improvements in model accuracy.
To solve this, a technique known as "persona multiplexing" has emerged. Rather than loading three independent, resource-heavy models, developers can utilize a single, high-performance open-source model—such as the Qwen2.5-7B-Instruct—and dynamically swap system prompts to shift the model’s behavioral persona. By employing 4-bit quantization, the model’s footprint is reduced to fit within the 16GB of VRAM available on standard GPU instances, allowing a single LLM to play the role of Proposer, Critic, and Judge sequentially.
Implementation Chronology and Methodology
The implementation of a PCJ loop requires a rigorous, step-by-step orchestration. The initial phase involves the selection of a capable foundation model. Qwen2.5-7B-Instruct has become a preferred choice due to its high reasoning capability relative to its parameter count. The process begins with the installation of essential libraries, specifically transformers, accelerate, and bitsandbytes, which facilitate the loading and quantization of the model.
Once the environment is configured, the instrumentation of a measurement utility is required. A generate_and_measure function serves as the backbone of the system, capturing raw input/output token counts and precise latency metrics. This data is vital for developers to quantify the "token tax" against the actual quality of the output.
The three roles are then defined through distinct system prompts:
- The Proposer: Tasked with providing an immediate, concise solution to the user’s prompt.
- The Critic: Required to ignore the Proposer’s answer initially, perform independent calculations, compare the results, and identify specific logical fallacies.
- The Judge: Responsible for the final synthesis, either confirming the proposal or enforcing the corrections derived by the Critic.
Evidence of Efficacy: A Case Study
To test this framework, researchers utilized a classic logical trap: "Bob is 20 years old. Alice is half Bob’s age. When Bob is 100 years old, how old will Alice be?"
When processed by a baseline single-agent model, the system often defaults to a superficial, proportion-based calculation (100 / 2 = 50), failing to account for the static nature of age differences. In a multi-agent loop, the Critic acts as a circuit breaker. By forcing the Critic to calculate the age gap (20 – 10 = 10) and then apply that constant to Bob’s future age (100 – 10 = 90), the system exposes the Proposer’s initial error.
The data gathered from this test provides a stark insight into the cost-benefit analysis of multi-agent loops. The baseline, single-agent execution took 2.63 seconds and utilized 85 tokens. The full PCJ loop took 16.67 seconds and consumed 660 tokens. This represents a 6.3x increase in latency and a 7.8x increase in the "token tax." While the raw metrics suggest a significant overhead, the qualitative outcome—shifting from a logical fallacy to a factually correct answer—demonstrates that the investment of time and tokens is a necessary cost for reliability.
Industry Implications and Future Outlook
The broader implications for software engineering are clear: multi-agent loops should not be treated as a universal solution but as a tool for high-stakes reasoning. In tasks where accuracy is paramount, such as financial analysis, medical coding, or complex legal summarization, the "token tax" is an acceptable investment for the robustness it provides. Conversely, for routine, low-stakes queries, the overhead is prohibitive.
Industry observers note that as models become more efficient, the overhead of these loops will likely decrease. We are seeing a move toward "smaller, smarter" models that are pre-optimized for specific roles, potentially eliminating the need for complex prompt-swapping multiplexing. Furthermore, hardware acceleration improvements, such as enhanced quantization techniques and faster inference engines, are expected to bring the latency costs of multi-agent loops down from seconds to milliseconds.
Conclusion
The Proposer-Critic-Judge verification loop represents a significant step forward in the quest for self-correcting AI systems. By leveraging persona multiplexing on small, open-source models, developers can now implement robust, high-accuracy workflows on hardware that was previously considered insufficient for multi-agent tasks. While the computational overhead remains a tangible factor, the ability to turn a failure into a verified success is a trade-off that will undoubtedly drive the next wave of AI development. As the ecosystem matures, the focus will shift from simply wiring agents together to optimizing the cost of their collaboration, ensuring that the promise of multi-agent intelligence is realized with both precision and efficiency.







