Dual-Agent CI Loop Protocol
- Dual-Agent CI Loop Protocol is a structured method where two specialized agents iteratively refine solutions with defined roles for synthesis and critique.
- It uses clear communication protocols and convergence criteria based on metrics like coverage improvement and error reduction to guide iterations.
- The protocol is adaptable across domains, improving software QA, multi-agent reasoning, and even clinical trial designs by ensuring continuous collective improvement.
A Dual-Agent CI Loop Protocol is a structured, iterative process in which two specialized agents—often instantiated as autonomous software, LLMs, or operational modules—interact through a closed feedback loop to incrementally solve, optimize, or evaluate complex tasks. The "CI" in this context can denote "Collective Improvement," "Circular Intelligence," or "Closed-Loop Coaching & Exemplification," depending on the application. The protocol is characterized by the alternation or collaboration between two distinct agent roles, with clearly defined interfaces, iterative refinements based on performance or feedback metrics, and convergence conditions guiding the progression and termination of the loop.
1. Formal Structure and General Principles
A Dual-Agent CI Loop comprises two agents, typically with distinct but complementary roles. The architecture and communication protocol enable iterative knowledge improvement, error reduction, optimization, or quality assurance for a target task.
General agentic structure:
| Agent | Primary Role | Typical Input/Output |
|---|---|---|
| Agent 1: Generator/Proposer/Ideal | Synthesis, Drafting, or Exemplar | Drafts, test cases, or exemplars |
| Agent 2: Critic/Analyzer/Coach | Evaluation, Feedback, or Execution | Feedback, error logs, analysis |
Communication and iteration: Agents typically interact through structured messages (often JSON), exchanging proposed solutions, performance metrics, and refinements. An external orchestrator, scheduler, or user may coordinate iterations, enforce loop limits, and determine convergence conditions.
Convergence is reached when improvement metrics stagnate, quantitative targets are met, or a maximum number of iterations is reached. Reward functions or structured feedback guide the refinement process (Naqvi et al., 5 Jan 2026, Kaesberg et al., 26 Feb 2025, Chen et al., 19 Nov 2025).
2. Agent Roles and Variants in Different Domains
Software Quality Assurance
In the context of CI/CD pipelines, the typical agentic split is:
- Test Generation & Optimization Agent (TGA): Synthesizes initial test cases from requirements, code diffs, and historic failures. Is responsible for fixing or augmenting failing tests in feedback rounds using LLM-driven prompt engineering. Outputs structured test suite payloads.
- Execution & Analysis Agent (EAA): Executes test suites in sandboxed environments, analyzes outcomes (coverage, failure types), and aggregates structured logs and metrics. Returns these results to TGA for refinement (Naqvi et al., 5 Jan 2026).
Multi-Agent Reasoning and Decision-Making
For tasks such as multi-agent debate and collective reasoning:
- Dual Agent CI (Collective Improvement) Loop: Each agent independently drafts a solution, iteratively improves their proposals after seeing both previous-round answers, without direct turn-based debate. After a fixed number of rounds, agents vote on the best proposal. The protocol fosters answer diversity and is particularly effective for reasoning-heavy tasks (Kaesberg et al., 26 Feb 2025).
Educational Coaching and Human Learning
In coaching/presentation training systems:
- Ideal Presentation Agent: Converts user-supplied materials into model presentations via multi-modal processing.
- Coach Agent: Analyzes user performances against exemplars, simulates audience reactions, and delivers structured feedback (Observation-Impact-Suggestion), forming a closed practice-feedback loop (Chen et al., 19 Nov 2025).
Dose-Finding Clinical Trials
- Ci3+3 Protocol: Employs dual-agent logic in the sense of two treatment agents, using a closed loop of cohort dosing, toxicity feedback, and escalation/de-escalation decisions constrained by equivalence interval rules and Bayesian updating (Yuan et al., 2021).
3. Stepwise CI Loop Protocol and Formalism
A canonical CI loop proceeds as follows (Naqvi et al., 5 Jan 2026, Kaesberg et al., 26 Feb 2025, Chen et al., 19 Nov 2025):
- Initialization:
- Set system parameters (e.g., code commit, requirements, session ID, initial prompts).
- Agents receive inputs and context.
- Generation/Synthesis (Agent 1):
- Produce initial solution(s) (test suite, answer draft, exemplar).
- Evaluation/Execution (Agent 2):
- Conduct analysis (code execution, reasoning critique, feedback).
- Compute metrics (e.g., code coverage , validity ratio , empirical scores).
- Aggregate and structure results.
- Feedback/Refinement:
- Agent 1 receives metric/feedback payload.
- Refines solution using feedback (via LLM prompting, repair heuristics, etc.).
- Loop returns to Step 2 with updated context and/or parameters.
- Convergence Check:
- Algorithm halts if quantitative or qualitative thresholds are satisfied or after fixed iterations.
Mathematical formulations (software QA context):
- Coverage improvement:
- Reward signal:
- Convergence: and , or for iterations
Decision protocol (Collective Improvement, reasoning context):
4. Communication, Data Flow, and Orchestration
Agents interact via REST endpoints or message queues, using structured schemas (JSON), with an orchestrator managing the invocation order, artifact persistence, and metrics collection (Naqvi et al., 5 Jan 2026).
Primary message types:
- Generation requests/responses (inputs, task data, drafts)
- Evaluation or execution results (test logs, coverage metrics, critique feedback)
- Structured logs for traceability and later analysis
Artifact and metrics stores (databases, Git, S3) ensure reproducibility and enable trend analysis.
CI/CD Integration: The protocol is embedded in pipelines (e.g., GitHub Actions, Jenkins), with specifically defined jobs and artifact archiving, and triggers on code push or PR events (Naqvi et al., 5 Jan 2026).
5. Convergence, Stopping Criteria, and Algorithmic Guarantees
Termination conditions are formalized around improvement metrics and thresholds to avoid infinite loops or redundant computation.
Common convergence criteria:
- Target metric achievement: e.g.,
- Improvement stagnation: 0 for 1 rounds
- Maximum iterations: 2
- In debate, fixed number of improvement rounds 3 with voting on final outputs (Kaesberg et al., 26 Feb 2025).
Theoretical properties are sometimes given, such as bounded number of replanning steps as a function of minimum score improvement per iteration and maximum attainable score (Qu et al., 5 Sep 2025).
6. Evaluation, Empirical Results, and Best Practices
Deployment studies of Dual-Agent CI Loop Protocols exhibit substantial quantitative improvements:
| Application Area | Metric | Baseline | Dual-Agent Result | Δ Improvement |
|---|---|---|---|---|
| Software QA (Naqvi et al., 5 Jan 2026) | Invalid Test Rate (%) | 38.2 | 14.7 | −61.5% |
| Statement Coverage (%) | 72.8 | 94.9 | +30.3% | |
| Branch Coverage (%) | 61.5 | 91.7 | +49.2% | |
| QA Time (hrs) | 11.8 | 3.4 | −71.2% | |
| Reasoning (StrategyQA) (Kaesberg et al., 26 Feb 2025) | Accuracy (3 agents) | 62.8 | 65.7 | +7.4% (over CoT) |
| Presentation Coaching (Chen et al., 19 Nov 2025) | PRCS Score (Δ) | +16.1 | +36.3 | Statistically significant |
Best Practices:
- Tune the number of loop iterations and convergence/stall thresholds to balance compute cost with quality gain.
- Pre-tabulate decision rules and establish clear escalation/exclusion controls in clinical protocols (Yuan et al., 2021).
- Employ deterministic tie-breaking in agent voting when the number of agents is even (Kaesberg et al., 26 Feb 2025).
- Monitor trend metrics and enforce artifact versioning for reproducibility.
7. Applications and Domain Adaptations
The dual-agent CI loop protocol is highly adaptable:
- In CI/CD-based agentic testing, it delivers autonomous improvement to test suites with minimal human oversight (Naqvi et al., 5 Jan 2026).
- For multi-agent LLM systems, it supports debate, reasoning, and answer diversification (Kaesberg et al., 26 Feb 2025).
- In presentation and skill coaching, it enables a user-facing, iterative cycle of modeling and personalized feedback, enhancing learning outcomes (Chen et al., 19 Nov 2025).
- Within clinical trial design, it operationalizes transparent, safe dose-finding for combination therapies (Yuan et al., 2021).
The protocol’s modular agent roles, quantitative convergence logic, and structured communication paradigms constitute a robust template for iterative improvement and co-optimization across diverse research and engineering disciplines.