Spaces:
Paused
Paused
Claude Code Claude Opus 4.6 commited on
Commit ·
6cd1105
1
Parent(s): 8b28d6c
god: implement Convergence Phase — elect lead agent to synthesize peer input
Browse filesFixes the "Split-Brain" problem where Adam and Eve discuss in parallel without
convergence. The new Convergence Phase:
1. Triggers after 2+ turns of discussion without [TASK] (before emergency)
2. Elects lead agent based on problem domain (Adam=DevOps, Eve=Runtime)
3. Lead agent must synthesize peer hypotheses and dispatch Worker with [TASK]
This implements the "Master/Verifier" pattern to close the feedback loop.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- scripts/conversation-loop.py +48 -1
scripts/conversation-loop.py
CHANGED
|
@@ -2200,6 +2200,54 @@ RULES:
|
|
| 2200 |
- CONFIG_ERROR with collision = [ACTION: delete_env:KEY] then [ACTION: restart]
|
| 2201 |
- English first, then --- separator, then Chinese translation""")
|
| 2202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2203 |
# CHATTER DETECTION: Check if last 3 messages are pure discussion without [TASK] or code
|
| 2204 |
# If agents are stuck in conversational loops, force them to act
|
| 2205 |
if len(history) >= 3 and not cc_status["running"]:
|
|
@@ -2220,7 +2268,6 @@ RULES:
|
|
| 2220 |
|
| 2221 |
# EMERGENCY OVERRIDE PROTOCOL: PUSH_ONLY mode for breaking discussion loops
|
| 2222 |
# When triggered, force agents to generate a task regardless of CC status
|
| 2223 |
-
global _force_push_mode, _force_push_skip_termination, _emergency_override_active
|
| 2224 |
if _force_push_mode:
|
| 2225 |
parts.append(f"\n🚨🚨🚨 EMERGENCY OVERRIDE: PUSH_ONLY MODE 🚨🚨🚨")
|
| 2226 |
parts.append(f"Discussion loop detected with ZERO pushes. You MUST write a [TASK]...[/TASK] this turn.")
|
|
|
|
| 2200 |
- CONFIG_ERROR with collision = [ACTION: delete_env:KEY] then [ACTION: restart]
|
| 2201 |
- English first, then --- separator, then Chinese translation""")
|
| 2202 |
|
| 2203 |
+
# ══════════════════════════════════════════════════════════════════════════════
|
| 2204 |
+
# CONVERGENCE PHASE: Elect lead agent to synthesize peer input and dispatch Worker
|
| 2205 |
+
# ══════════════════════════════════════════════════════════════════════════════
|
| 2206 |
+
# Trigger: 2+ turns of discussion without [TASK] while CC is IDLE
|
| 2207 |
+
# This prevents the "Split-Brain" problem where agents discuss in parallel without convergence
|
| 2208 |
+
global _force_push_mode, _force_push_skip_termination, _emergency_override_active
|
| 2209 |
+
if _discussion_loop_count >= 2 and not cc_status["running"] and not _force_push_mode:
|
| 2210 |
+
# Elect lead agent based on problem domain
|
| 2211 |
+
# Adam: DevOps/infrastructure (config, entry points, deployment, env vars)
|
| 2212 |
+
# Eve: Code/QA (runtime errors, HTTP status, crash loops, application logic)
|
| 2213 |
+
is_devops_issue = any(kw in str(ctx).lower() for kw in [
|
| 2214 |
+
"startup", "entry point", "docker", "config", "environment", "deployment",
|
| 2215 |
+
"build", "infrastructure", "sdk", "port", "uvicorn", "fastapi"
|
| 2216 |
+
])
|
| 2217 |
+
is_runtime_issue = any(kw in str(ctx).lower() for kw in [
|
| 2218 |
+
"http", "503", "502", "crash", "error", "exception", "runtime",
|
| 2219 |
+
"traceback", "failed", "timeout", "connection"
|
| 2220 |
+
])
|
| 2221 |
+
|
| 2222 |
+
# Elect lead agent
|
| 2223 |
+
if is_devops_issue and not is_runtime_issue:
|
| 2224 |
+
lead_agent = "Adam"
|
| 2225 |
+
lead_role = "DevOps Architect"
|
| 2226 |
+
elif is_runtime_issue:
|
| 2227 |
+
lead_agent = "Eve"
|
| 2228 |
+
lead_role = "Runtime Verifier"
|
| 2229 |
+
else:
|
| 2230 |
+
# Default: alternate based on current speaker
|
| 2231 |
+
lead_agent = speaker
|
| 2232 |
+
lead_role = "Lead Architect"
|
| 2233 |
+
|
| 2234 |
+
if speaker == lead_agent:
|
| 2235 |
+
parts.append(f"\n🔄🔄🔄 CONVERGENCE PHASE — YOU ARE THE LEAD ARCHITECT 🔄🔄🔄")
|
| 2236 |
+
parts.append(f"Agents have been discussing for {_discussion_loop_count} turns without dispatching the Worker.")
|
| 2237 |
+
parts.append(f"As the {lead_role}, you MUST:")
|
| 2238 |
+
parts.append(f"1. SYNTHESIZE: Review your partner's hypothesis from the conversation history")
|
| 2239 |
+
parts.append(f"2. VERIFY: Identify the specific file/line/function that needs fixing")
|
| 2240 |
+
parts.append(f"3. DISPATCH: Write [TASK]...[/TASK] with concrete changes — file paths, function names, exact fixes")
|
| 2241 |
+
parts.append(f"🛑 STOP discussing. Your job is to CLOSE THE FEEDBACK LOOP by dispatching the Worker.")
|
| 2242 |
+
parts.append(f"The system is 'all talk, no code.' BE the Logic Synthesizer. WRITE [TASK] NOW.")
|
| 2243 |
+
else:
|
| 2244 |
+
parts.append(f"\n🔄🔄🔄 CONVERGENCE PHASE — PARTNER IS LEAD 🔄🔄🔄")
|
| 2245 |
+
parts.append(f"Agents have been discussing for {_discussion_loop_count} turns without dispatching the Worker.")
|
| 2246 |
+
parts.append(f"{lead_agent} is the Lead Architect for this cycle ({lead_role} domain).")
|
| 2247 |
+
parts.append(f"YOUR ROLE: Provide a concise summary of your hypothesis (max 3 sentences).")
|
| 2248 |
+
parts.append(f"DO NOT write [TASK]. Let {lead_agent} synthesize and dispatch.")
|
| 2249 |
+
parts.append(f"Focus on: What specific evidence supports your theory? What files/lines should be checked?")
|
| 2250 |
+
|
| 2251 |
# CHATTER DETECTION: Check if last 3 messages are pure discussion without [TASK] or code
|
| 2252 |
# If agents are stuck in conversational loops, force them to act
|
| 2253 |
if len(history) >= 3 and not cc_status["running"]:
|
|
|
|
| 2268 |
|
| 2269 |
# EMERGENCY OVERRIDE PROTOCOL: PUSH_ONLY mode for breaking discussion loops
|
| 2270 |
# When triggered, force agents to generate a task regardless of CC status
|
|
|
|
| 2271 |
if _force_push_mode:
|
| 2272 |
parts.append(f"\n🚨🚨🚨 EMERGENCY OVERRIDE: PUSH_ONLY MODE 🚨🚨🚨")
|
| 2273 |
parts.append(f"Discussion loop detected with ZERO pushes. You MUST write a [TASK]...[/TASK] this turn.")
|