---
title: Dual-Agent CI Loop Protocol
url: https://www.emergentmind.com/topics/dual-agent-ci-loop-protocol
type: topic
---

# Dual-Agent CI Loop Protocol

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 [2601.02454, 2502.19130, 2511.15253].

## 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 [2601.02454].

### 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 [2502.19130].

### 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 [2511.15253].

### 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 [2103.13693].

## 3. Stepwise CI Loop Protocol and Formalism

A canonical CI loop proceeds as follows [2601.02454, 2502.19130, 2511.15253]:

1. **Initialization**:
   - Set system parameters (e.g., code commit, requirements, session ID, initial prompts).
   - Agents receive inputs and context.
2. **Generation/Synthesis** (Agent 1):
   - Produce initial solution(s) (test suite, answer draft, exemplar).
3. **Evaluation/Execution** (Agent 2):
   - Conduct analysis (code execution, reasoning critique, feedback).
   - Compute metrics (e.g., code coverage $C_i$, validity ratio $V_i$, empirical scores).
   - Aggregate and structure results.
4. **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.
5. **Convergence Check**:
   - Algorithm halts if quantitative or qualitative thresholds are satisfied or after fixed iterations.

**Mathematical formulations** (software QA context):

- Coverage improvement: $\Delta C_i = C_i - C_{i-1}$
- Reward signal: $R_i = \alpha \cdot \Delta C_i - \beta \cdot (1 - V_i)$
- Convergence: $C_i \geq C^*$ and $V_i \geq V^*$, or $\Delta C_i < \epsilon$ for $k$ iterations

**Decision protocol (Collective Improvement, reasoning context):**

- $s_i^{(t)} = \arg\max_{y} p_\theta(y | P_i, x, S^{(t-1)})$

## 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 [2601.02454].

**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 [2601.02454].

## 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., $C_i \geq C^*, V_i \geq V^*$
- Improvement stagnation: $|\Delta C_i| < \epsilon$ for $k$ rounds
- Maximum iterations: $i \geq N_{\mathrm{max}}$
- In debate, fixed number of improvement rounds $T$ with voting on final outputs [2502.19130].

**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 [2509.04993].

## 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 [2601.02454]   | 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) [2502.19130] | Accuracy (3 agents) | 62.8         | 65.7              | +7.4% (over CoT)      |
| Presentation Coaching [2511.15253] | 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 [2103.13693].
- Employ deterministic tie-breaking in agent voting when the number of agents is even [2502.19130].
- 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 [2601.02454].
- For multi-agent LLM systems, it supports debate, reasoning, and answer diversification [2502.19130].
- In presentation and skill coaching, it enables a user-facing, iterative cycle of modeling and personalized feedback, enhancing learning outcomes [2511.15253].
- Within clinical trial design, it operationalizes transparent, safe dose-finding for combination therapies [2103.13693].

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.

Source: https://www.emergentmind.com/topics/dual-agent-ci-loop-protocol