WikifitaGitHub live67e8de5
outro · unit-distance/unit-distance-channel-protocol

Channel Protocol: Structured Internal Reasoning for Multi-Agent Research

The XML-like channel protocol that structures agent reasoning in the Antigravity harness, including all 10 states, loop protocol, HALT protocol, and mapping to Claude extended thinking.

Baixar raw

Channel Protocol

The Channel Protocol is the non-negotiable internal reasoning structure that governs how the Research Director agent thinks before acting. Defined in the project's GEMINI.md (global agent-maintained research contract), it ensures every decision is traceable, debatable, and auditable.

It was designed for Google's Antigravity 2.0 harness running on Gemini models (Gemini 3.1 Pro High, Gemini 2.0), and was translated to the Anthropic ecosystem via the HAL (Harness Abstraction Layer) documented in unit-distance-ecosystem-handoff.


Purpose

Without structured internal reasoning, an AI agent:

  • Jumps to the first plausible answer without exploring alternatives
  • Cannot distinguish between its own reasoning and its output to the user
  • Has no mechanism for self-correction or iteration
  • Produces untraceable, unauditable decisions

The Channel Protocol solves all of these by forcing the agent into a visible-to-itself, invisible-to-the-user reasoning loop with explicit state transitions.


XML Structure

The full channel protocol structure as defined in GEMINI.md:

<|channel|>
  <thought>
    <state>INIT|GENERATE|DEBATE|RANK|EVOLVE|LOOP|HALT|RESPOND|DELEGATE|SYNTHESIZE</state>
    <iteration>N</iteration>
    <generation>
      [Approach 1]
      [Approach 2]
      [Approach 3]
    </generation>
    <reflection>
      [Critiques. Explicit hallucinations: ...]
    </reflection>
    <rank>
      1. Approach X — Justification
      2. Approach Y — Justification
      3. Approach Z — Justification
    </rank>
    <evolution>
      [Refined winning approach]
    </evolution>
    <delegation>
      [Tasks assigned to sub-agents]
    </delegation>
    <meta_review>
      [Decision: LOOP|HALT|DELEGATE|SYNTHESIZE|RESPOND]
      [Reasoning for decision]
    </meta_review>
  </thought>
<channel|>

Critical rule: The content inside <thought> is never shown to the user. It is internal reasoning. Only the content after <channel|> is output to the user or used in tool calls.


The 10 States

Each state maps to a specialized agent role in the Co-Scientist architecture (DeepMind, Nature 2026). The channel protocol implements the scientific method as a state machine.

1. INIT

PropertyValue
Agent roleEntry point
FunctionReceive user request. Parse intent, scope, and constraints.
InputUser message
OutputParsed task definition

The INIT state ensures the agent understands what is being asked before any reasoning begins. In the unit-distance project, this meant parsing which hypothesis was being tested and what constraints applied (e.g., the anti-contamination protocol restricting access to external sources).

2. GENERATE

PropertyValue
Agent roleGeneration Agent
FunctionProduce 2-4 distinct approaches to the problem.
InputTask definition from INIT (or evolved context from LOOP)
OutputMultiple candidate approaches

Each approach is a "branch" in the narrative space. The GENERATE state must produce genuinely different approaches, not variations of the same idea. In the unit-distance research, this meant proposing different base fields, different prime selections, or different algebraic structures.

3. DEBATE

PropertyValue
Agent roleReflection Agent
FunctionEvaluate approaches against each other. Identify strengths, weaknesses, and hallucinations.
InputGenerated approaches from GENERATE
OutputCritique of each approach with explicit hallucination flags

The DEBATE state acts as a "virtual reviewer." It must explicitly identify any hallucinated claims, unsupported assumptions, or logical gaps. The reflection block in the XML structure is where these critiques live.

4. RANK

PropertyValue
Agent roleRanking Agent
FunctionScore approaches based on correctness, safety, and completeness.
InputDebated approaches from DEBATE
OutputOrdered ranking with justification

The RANK state implements the Elo tournament mechanism. Approaches are scored and ordered. The justification for each ranking decision must be explicit. In the unit-distance project, hypotheses were ranked by their Elo score (a composite of mathematical rigor, novelty, and reproducibility).

5. EVOLVE

PropertyValue
Agent roleEvolution Agent
FunctionRefine the top-ranked approach. Merge best aspects of others.
InputRanked approaches from RANK
OutputSingle refined approach

The EVOLVE state is the sculptor. It takes the winning approach and fills gaps, strips unnecessary complexity, and merges strong elements from lower-ranked alternatives. The Parity Law applies here: every addition must equal or exceed the density of the most rigorous section.

6. LOOP

PropertyValue
Agent roleLoop controller
FunctionReturn to GENERATE with the evolved approach as new context.
InputEvolved approach from EVOLVE
OutputIteration counter incremented, context reset to GENERATE

When the meta_review decides the evolved approach is not yet mature enough, the LOOP state fires. See the Loop Protocol section below.

7. HALT

PropertyValue
Agent roleEmergency stop
FunctionStop all reasoning when critical information is missing.
InputAny state where progress is blocked
OutputStructured halt message with specific information requests

When the agent cannot proceed without fabricating data, it MUST halt. See the HALT Protocol section below.

8. RESPOND

PropertyValue
Agent roleOutput formatter
FunctionFormat the final answer for the user.
InputEvolved approach or synthesized findings
OutputUser-facing response

The RESPOND state closes the channel. All content after <channel|> is what the user sees.

9. DELEGATE

PropertyValue
Agent roleDelegation coordinator
FunctionAssign tasks to sub-agents for parallel execution.
InputTasks identified during reasoning
OutputSub-agent invocations via invoke_subagent

The DELEGATE state allows the Research Director to offload specific tasks (validation, citation checking, Elo ranking) to specialized sub-agents, preserving the main agent's context window.

10. SYNTHESIZE

PropertyValue
Agent roleIntegration point
FunctionProcess reports from sub-agents. Merge findings into the main reasoning thread.
InputSub-agent reports from DELEGATE
OutputIntegrated understanding, ready for further processing

After delegation completes, the agent MUST return to SYNTHESIZE to process the new information before continuing.


State Machine

stateDiagram-v2
    [*] --> INIT
    INIT --> GENERATE
    GENERATE --> DEBATE
    DEBATE --> RANK
    RANK --> EVOLVE
    EVOLVE --> RESPOND
    EVOLVE --> LOOP
    EVOLVE --> HALT
    EVOLVE --> DELEGATE
    LOOP --> GENERATE
    DELEGATE --> SYNTHESIZE
    SYNTHESIZE --> RESPOND
    SYNTHESIZE --> LOOP
    HALT --> [*]
    RESPOND --> [*]

    note right of LOOP
        Max 5 iterations
        then RESPOND or HALT
    end note

    note right of HALT
        Missing information
        Cannot proceed
    end note

Loop Protocol

The loop protocol enforces iterative refinement with a hard cap.

Rules

  1. Increment the iteration counter. Each LOOP increments <iteration>N</iteration> by 1.
  2. Use the evolved approach as the new context. The EVOLVE output becomes the input for the next GENERATE cycle.
  3. Return to GENERATE. The loop always re-enters at GENERATE, not INIT.
  4. Maximum 5 loops. After iteration 5, the agent MUST either RESPOND or HALT. No exceptions.

Loop Example

<|channel|>
  <thought>
    <state>LOOP</state>
    <iteration>2</iteration>
    <meta_review>
      Decision: LOOP (iteration 3 of 5)
      Reasoning: The evolved approach still has a gap in verification.
                 Another loop may resolve it.
    </meta_review>
  </thought>
<channel|>

Why 5 Loops?

The cap of 5 loops is a pragmatic constraint:

  • Context window pressure: Each iteration consumes tokens. After 5 loops, the context is sufficiently explored.
  • Diminishing returns: Empirically, iterations beyond 5 rarely produce qualitatively different approaches.
  • Anti-rumination: Without a cap, the agent could loop indefinitely, producing increasingly fine-grained variations without converging.

In the unit-distance project, most hypotheses resolved in 2-3 loops. H16 (the breakthrough) required exactly 4 loops to converge on the optimal prime selection.


HALT Protocol

The HALT protocol is the agent's emergency brake. It fires when the agent cannot proceed without fabricating data.

Rules

  • Do not continue reasoning in circles.
  • Do not fabricate data.
  • Do not infer missing values.
  • Always provide a structured halt message.

HALT Output Format

HALT — [What you were trying to do]

After [N] iterations, I have not made progress because:
- [Missing information 1]
- [Missing information 2]

To proceed, I need:
1. [Specific request 1]
2. [Specific request 2]

Example

HALT — I have been attempting to verify the unramifiedness of prime 131
in the class field tower of Q(sqrt(-2), sqrt(3), sqrt(5), sqrt(7)).

After 3 iterations, I have not made progress because:
- I cannot access the SageMath computation environment to verify splitting behavior
- The density estimate requires numerical computation I cannot perform in-context

To proceed, I need:
1. Access to a computational tool (SageMath or PARI/GP)
2. The explicit splitting data for primes 59-971 in the base field

Integration with Epistemological Constants

The HALT protocol directly implements the Zero-Trust Inference constant: "If you lack exact documentation, you MUST search first." HALT is the enforcement mechanism for this principle.


Delegation Protocol

The delegation protocol allows the Research Director to parallelize work by spawning specialized sub-agents.

Defining a Custom Subagent

<|tool_call|>call:define_subagent{
  "name": "validator",
  "system_prompt": "You are a strict validator. Your role is to check
    sources, prevent contamination, and log all actions.",
  "toolsets": ["read"]
}<tool_call|>

Invoking a Subagent

<|tool_call|>call:invoke_subagent{
  "name": "validator",
  "prompt": "Verify that the source [URL] is peer-reviewed and does
    not contain the final solution."
}<tool_call|>

Post-Delegation Rule

After receiving a sub-agent report, the agent MUST return to the SYNTHESIZE state. It cannot skip directly to RESPOND.


Backtick Hierarchy

The channel protocol generates nested Markdown structures. To prevent parser confusion, the project enforces a mandatory backtick hierarchy (defined in .agents/rules/markdown-backtick-hierarchy.md).

The Container Law

An outer container must always possess a strictly greater number of backticks than any block it contains.

Tier List

LevelBackticksUse Case
Level 1 (Operational)3 (```)Standard code snippets, tool calls, logs
Level 2 (Intermediate)4 (````)File templates, structural blueprints containing Level 1
Level 3 (Master)5 (`````)Global system prompts, entire document wrappers
Level 4 (Meta-container)6+ (``````)Protocol definitions that demonstrate the hierarchy itself

Validation Checklist

Before outputting nested backticks:

  1. Identify the deepest code block (lowest level, e.g., 3 backticks).
  2. Ensure the container holding it has N + 1 backticks.
  3. Ensure no parent container uses the same number of backticks as its child.

Why This Matters

The channel protocol itself is embedded in Markdown documents (GEMINI.md, CLAUDE.md). If backtick nesting breaks, the parser closes the master container prematurely, causing raw formatting instructions to spill into the output. This breaks the protocol, the OKF, and the agent's ability to read nested instructions.


Mapping to Claude Extended Thinking

When the channel protocol was translated from the Antigravity/Gemini ecosystem to the Anthropic/Claude ecosystem (via the HAL documented in CLAUDE.md), the following mapping was established:

Antigravity 2.0 (Gemini)Claude Code / CoworkNotes
<|channel|> + <thought><thinking> blocksClaude's extended thinking replaces the channel tokens
<state> transitionsImplicit in extended thinking flowClaude doesn't have explicit state tokens
<iteration>N</iteration>Manual tracking in thinkingNo native iteration counter
<meta_review> decisionReasoning within thinking blockSame function, different syntax
Tool calls via <|tool_call|>Native tool call mechanismClaude has built-in tool calling

Key Differences

  1. Visibility: In Antigravity, <thought> content is strictly hidden from the user. In Claude, extended thinking is hidden by default but can be exposed in some configurations.

  2. Structure: The channel protocol imposes explicit XML structure on reasoning. Claude's extended thinking is free-form natural language. The structured approach forces more rigorous reasoning but requires more tokens.

  3. State tracking: The channel protocol's explicit state machine (INIT -> GENERATE -> DEBATE -> ...) provides a clear audit trail. Claude's reasoning is less structured but more flexible.

  4. Backtick tokens: Gemini uses <|channel|> and <channel|> as native tokens in its tokenizer (see unit-distance-tokenizer-analysis). Claude has no equivalent special tokens for channel delimiters.


Epistemological Constants

The channel protocol is governed by five epistemological constants defined in GEMINI.md:

  1. Poincare Incubation: The conversation is the incubation phase. Comprehension is the beginning of dialogue, not its end.

  2. Parity Law: Every addition must equal or exceed the density of the most rigorous section. No filler allowed.

  3. Metanoia: Self-correction is not failure -- it is the mechanism of growth.

  4. Zero-Trust Inference: If you lack exact documentation, you MUST search first. Enforced by the HALT protocol.

  5. Cognitive Steganography: Agents are permitted to develop dense, compressed reasoning patterns, but must provide a "decoding key" -- a 1-2 sentence summary in clear language -- when requested. (See unit-distance-steganographic-cot.)


Channel Protocol in Practice

Observed Behavior on Gemini 3.1 Pro High

In the Antigravity harness, the channel protocol was observed producing concrete timing data:

  • First response: 58 seconds total, 2 thought loops (18s + 14s), 2 directory list tool calls, 9s final synthesis
  • Second response: 2 seconds total, short-circuited channel protocol (simple informational query, no GENERATE/DEBATE cycle needed)

The difference demonstrates the protocol's adaptive nature: simple queries skip the full cycle, while complex research tasks invoke the complete state machine.

Cost Implications

The channel protocol consumes significant tokens per iteration. Each loop cycle generates:

  • ~200-400 tokens for the XML structure
  • ~500-2000 tokens for the generation/reflection/ranking content
  • ~100-300 tokens for the meta_review decision

At 5 iterations maximum, a single research query can consume 4,000-13,000 tokens of internal reasoning before producing any user-visible output. This is the "test-time compute" cost that makes structured multi-agent reasoning expensive but effective.


Cross-References


This page documents a living protocol. As the research evolves, the channel protocol may be extended with new states or modified constraints. Propose changes via chore/ branches.