From e899f0ca9788d163d4511a4ae7159a605f54a4cd Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman Date: Sun, 5 Apr 2026 19:32:24 +0000 Subject: [PATCH] chore(agents): fix ca-test-infra-improver health comment spam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace fragile cycle-modulo health posting guard with timestamp-based approach and state-change-only posting. The inner monitoring loop no longer posts health comments — posting is gated by a 10-minute timer OR meaningful state changes (worker completion, dispatch events). Approved proposal: #3385 Pattern: workflow_fix Evidence: Agent posted 44 of 52 session comments in 20 minutes, all identical, drowning out other agent signals. Fix: Timestamp-based health posting with state-change triggers. ISSUES CLOSED: #3385 --- .opencode/agents/ca-test-infra-improver.md | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.opencode/agents/ca-test-infra-improver.md b/.opencode/agents/ca-test-infra-improver.md index 39bc0f139..ab4578cad 100644 --- a/.opencode/agents/ca-test-infra-improver.md +++ b/.opencode/agents/ca-test-infra-improver.md @@ -133,6 +133,16 @@ If no spec context is provided, invoke `ca-ref-reader` once at startup. ### Pool Supervision Loop +**CRITICAL: Do NOT post health comments on every monitoring iteration. +Health comments MUST be posted at most once every 10 minutes. Use a +separate `last_health_post_time` timestamp to enforce this. If less than +10 minutes have elapsed since the last health comment, do NOT post. +Health comments should also be posted immediately when there is a +meaningful state change (worker completed, new worker dispatched, all +areas analyzed). The inner `while active:` monitoring loop must NEVER +post health comments — health posting belongs ONLY to the outer +supervision cycle, gated by the timestamp check.** + ``` # Check if session state issue number was provided if SESSION_STATE_ISSUE_NUMBER not provided: @@ -157,6 +167,10 @@ analysis_areas = [ analyzed_areas = set() findings_total = 0 cycle = 0 +last_health_post_time = 0 # Timestamp of last health comment (epoch seconds) +HEALTH_INTERVAL_SECONDS = 600 # 10 minutes between health posts +prev_analyzed_count = 0 # Track state changes for event-driven posting +prev_active_count = 0 # ── RESUME: Adopt existing worker sessions from previous run ───── EXISTING_WORKERS = bash("curl -s ${SERVER}/session | python3 -c \" @@ -210,6 +224,9 @@ LOOP: active[area] = SESSION_ID # ── Monitor workers, collect results, refill slots ─────────── + # NOTE: Do NOT post health comments inside this inner loop. + # Health posting is handled ONLY after this loop exits, gated + # by the timestamp check below. remaining_areas = remaining[N:] while active: bash("sleep 10", timeout=30000) @@ -233,8 +250,13 @@ LOOP: NEW_SID = create session + prompt_async for next_area active[next_area] = NEW_SID - # ── Post progress ──────────────────────────────────────────── - if cycle % 60 == 0: # Every ~10 minutes with 10-second monitoring + # ── Post health (ONLY when state changed OR timer expired) ─── + current_time = current epoch seconds + state_changed = (len(analyzed_areas) != prev_analyzed_count + or len(active) != prev_active_count) + timer_expired = (current_time - last_health_post_time >= HEALTH_INTERVAL_SECONDS) + + if state_changed or timer_expired: post comment on session state issue: "[HEALTH] ca-test-infra-improver | Iteration: | Status: active\n" + "- Type: pool-supervisor\n" + @@ -246,6 +268,9 @@ LOOP: "---\n" + "**Automated by CleverAgents Bot**\n" + "Supervisor: Test Infrastructure | Agent: ca-test-infra-improver" + last_health_post_time = current_time + prev_analyzed_count = len(analyzed_areas) + prev_active_count = len(active) ``` --- -- 2.52.0