fix(agents): always launch all 18 supervisors fresh, stop existing sessions first
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / e2e_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / benchmark-regression (push) Blocked by required conditions
CI / benchmark-publish (push) Waiting to run
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / helm (push) Waiting to run
CI / push-validation (push) Waiting to run
CI / status-check (push) Blocked by required conditions
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / e2e_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / benchmark-regression (push) Blocked by required conditions
CI / benchmark-publish (push) Waiting to run
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / helm (push) Waiting to run
CI / push-validation (push) Waiting to run
CI / status-check (push) Blocked by required conditions
Previously the product-builder would adopt existing supervisor sessions from prior runs and skip launching those already running. This caused stale sessions to persist with outdated configuration and context. Now Phase C.0 discovers and gracefully stops all existing supervisor sessions before Phase C.2 unconditionally launches all 18 fresh.
This commit is contained in:
@@ -634,17 +634,17 @@ milestones = list of all milestones to complete (ordered)
|
||||
ref_summary = result from ref-reader
|
||||
SERVER = "http://localhost:4096"
|
||||
|
||||
# ── PHASE C.0: Resume Existing Supervisor Sessions ──────────────
|
||||
# ── PHASE C.0: Discover and Stop Existing Supervisor Sessions ────
|
||||
# Check if there are already-running supervisor sessions from a
|
||||
# previous product-builder invocation. If found, ADOPT them into
|
||||
# the monitoring loop instead of launching duplicates.
|
||||
# previous product-builder invocation. If found, STOP them before
|
||||
# launching fresh supervisors. This ensures a clean slate every time
|
||||
# the product-builder starts — all 18 supervisors are ALWAYS launched
|
||||
# fresh regardless of whether prior sessions exist.
|
||||
#
|
||||
# This enables "continue where you left off" — if the user restarts
|
||||
# the product-builder, it reconnects to the existing supervisors
|
||||
# rather than killing them and starting fresh.
|
||||
#
|
||||
# To start completely fresh (kill all old sessions), run the
|
||||
# session-cleanup agent BEFORE starting the product-builder.
|
||||
# A fresh launch guarantees all supervisors start with current
|
||||
# configuration and context, avoiding stale state from previous
|
||||
# sessions. Supervisors are stateless (all persistent state lives
|
||||
# on Forgejo) so stopping and re-launching loses nothing.
|
||||
|
||||
# Step 1: Query all sessions from the server
|
||||
ALL_SESSIONS = bash("curl -s ${SERVER}/session", timeout=30000)
|
||||
@@ -686,26 +686,32 @@ for s in sessions:
|
||||
print(display_name + '=' + s['id'])
|
||||
\"", timeout=30000)
|
||||
|
||||
# Step 3: Check status of each existing session
|
||||
# Build a map of which supervisors are already running
|
||||
existing_supervisors = {} # display_name -> session_id
|
||||
# Step 3: Stop ALL existing supervisor sessions
|
||||
# Every previous supervisor MUST be stopped before launching fresh ones.
|
||||
# This guarantees exactly one instance of each supervisor type and
|
||||
# prevents stale sessions from interfering with the new launch.
|
||||
stopped_count = 0
|
||||
stopped_names = []
|
||||
for line in EXISTING (one per line):
|
||||
name, session_id = line.split("=")
|
||||
# Get session status via async-agent-manager
|
||||
status_result = task(
|
||||
# Stop the existing session via async-agent-manager
|
||||
stop_result = task(
|
||||
subagent_type="async-agent-manager",
|
||||
prompt="Get session status for all sessions"
|
||||
prompt="Stop async agent session ${session_id} (supervisor: ${name}). \
|
||||
Perform graceful shutdown and cleanup."
|
||||
)
|
||||
STATUS = status_result
|
||||
if session_id is active/running in STATUS:
|
||||
existing_supervisors[name] = session_id
|
||||
echo "✓ Stopped existing supervisor: ${name} (session ${session_id})"
|
||||
stopped_count += 1
|
||||
stopped_names.append(name)
|
||||
|
||||
if existing_supervisors:
|
||||
if stopped_count > 0:
|
||||
invoke session-persister with:
|
||||
checkpoint: "Phase C.0: Found <len(existing_supervisors)> existing
|
||||
supervisor sessions from a previous run. Adopting them.
|
||||
Running: <list of names>.
|
||||
Will launch only the missing supervisors."
|
||||
checkpoint: "Phase C.0: Found ${stopped_count} existing
|
||||
supervisor sessions from a previous run. STOPPED all of them.
|
||||
Stopped: ${stopped_names}.
|
||||
Will now launch all 18 supervisors fresh."
|
||||
else:
|
||||
echo "No existing supervisor sessions found — clean start."
|
||||
|
||||
# ── PHASE C.1: Planning (SKIPPED) ───────────────────────────────
|
||||
# Planning is now handled by the continuous epic-planner supervisor.
|
||||
@@ -725,7 +731,7 @@ if existing_supervisors:
|
||||
# 3. Record the session ID
|
||||
#
|
||||
# IMPORTANT: Use the Bash tool to run curl commands. Each curl call
|
||||
# returns instantly (prompt_async returns 204). All 16 supervisors
|
||||
# returns instantly (prompt_async returns 204). All 18 supervisors
|
||||
# launch within seconds, fully independent of each other.
|
||||
#
|
||||
# Before dispatching, output a pre-flight checklist:
|
||||
@@ -751,16 +757,10 @@ Pre-flight: Launching 18 supervisors via prompt_async:
|
||||
18. [ ] system-watchdog (system-watchdog-pool-supervisor)
|
||||
|
||||
# ── Helper function: launch one supervisor ───────────────────────
|
||||
# For EACH supervisor, SKIP if already running (adopted in Phase C.0).
|
||||
# ALL 18 supervisors are ALWAYS launched fresh. Any existing sessions
|
||||
# were already stopped in Phase C.0.
|
||||
|
||||
function launch_supervisor(agent_name, display_name, tag, prompt_text):
|
||||
# Check if this supervisor was adopted from a previous run
|
||||
if display_name in existing_supervisors:
|
||||
# Already running — record its session ID and skip launch
|
||||
echo "${display_name}=${existing_supervisors[display_name]}" \
|
||||
>> /tmp/supervisor-sessions.env
|
||||
return # Do NOT create a new session
|
||||
|
||||
# Use async-agent-manager to launch the supervisor
|
||||
launch_result=$(task(
|
||||
subagent_type="async-agent-manager",
|
||||
|
||||
Reference in New Issue
Block a user