Skip to content

ci(#6668): add exponential backoff to dispatch polling - #6669

Merged
waynesun09 merged 1 commit into
mainfrom
agent/6668-dispatch-backoff
Aug 27, 2026
Merged

ci(#6668): add exponential backoff to dispatch polling#6669
waynesun09 merged 1 commit into
mainfrom
agent/6668-dispatch-backoff

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

Add exponential backoff to E2E behaviour test dispatch polling to reduce flaky failures caused by transient GitHub Actions API delays. The dispatch detection loop now starts polling at 2-second intervals, doubles each iteration up to a 30-second cap, with a 5-minute total timeout window.

Related Issue

Changes

  • Replace fixed dispatchPoll (5s) × dispatchMaxTry (48) constants with exponential backoff constants: dispatchPollInit (2s), dispatchPollMax (30s), dispatchTimeout (5min)
  • Add nextBackoff() helper that doubles the interval up to a cap
  • Update WaitForWorkflow from count-based to deadline-based loop with backoff
  • Update WaitForHarnessAgent and WaitForFailedHarnessAgent to use backoff intervals
  • Add countSettlePoll constant for CountHarnessDispatches (retains fixed 5s interval since it polls for run settlement, not dispatch detection)
  • Add TestNextBackoff unit test and TestDispatchPollingBackoff integration test verifying exponential interval growth
  • Update TestDispatchDetectionWindow_AtLeast4Minutes to validate dispatchTimeout

Testing

  • All 45 existing tests in pkg/behaviourtest/drivers/ci/githubactions/ pass
  • New TestNextBackoff verifies backoff doubling and cap behavior
  • New TestDispatchPollingBackoff verifies that WaitForWorkflow uses exponentially growing intervals (2s → 4s → 8s → 16s → 30s)
  • go vet passes
  • Secret scan passes

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • I wrote this contribution myself and can explain all changes in it

Closes #6668

Post-script verification

  • Branch is not main/master (agent/6668-dispatch-backoff)
  • Secret scan passed (gitleaks — 6c44cb2dfcd83b9bca5f7c9641b3ab5063d68457..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

Replace fixed 5-second poll intervals in E2E behaviour test dispatch
detection with exponential backoff (2s initial, doubling to 30s cap,
5-minute total timeout). This makes dispatch polling more tolerant
of transient GitHub Actions API delays that caused flaky "was not
dispatched" and "no recent workflow runs found" failures.

The change applies to WaitForWorkflow, WaitForHarnessAgent, and
WaitForFailedHarnessAgent. CountHarnessDispatches retains a fixed
5-second interval via countSettlePoll since it polls for run
settlement, not dispatch detection.

Closes #6668
@fullsend-ai-coder
fullsend-ai-coder Bot requested a review from a team as a code owner August 26, 2026 21:44
@fullsend-ai-coder fullsend-ai-coder Bot added the ready-for-review Triggers review agent dispatch label Aug 26, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Aug 26, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 9:46 PM UTC · Completed 10:05 PM UTC

Commit: 13b6040 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $6.43

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Aug 26, 2026
@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Moderate risk driven primarily by Tier 2 git history signals: the githubactions CI driver is a high-churn file with 11+ commits in 30 days, 5 distinct authors, and 8 fix-related commits in 90 days, indicating an active stabilization area. However, the PR itself is well-scoped (2 files, 161 lines, 50% test ratio), touches no protected paths, security-sensitive files, CI workflows, or dependencies, and is authored by a known bot. The change aligns precisely with the linked issue scope and is trivially revertible.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [edge-case] pkg/behaviourtest/drivers/ci/githubactions/githubactions.go:84 — In WaitForWorkflow, worst-case single-poll detection latency increased from 5s to 30s due to the exponential backoff cap. A dispatch that appears after the interval reaches steady state will take up to 30s to detect, versus 5s under the old fixed-interval scheme. This is an acknowledged trade-off: the total detection window increased from 4 to 5 minutes, and early polls are faster (2s initial vs 5s fixed).

  • [test-inadequate] pkg/behaviourtest/drivers/ci/githubactions/githubactions_test.goTestDispatchPollingBackoff only covers the WaitForWorkflow path. WaitForHarnessAgent and WaitForFailedHarnessAgent also adopt exponential backoff but have no corresponding integration test verifying backoff intervals. Existing tests use instantAfter which fires immediately regardless of the duration argument. The nextBackoff helper is well-tested via TestNextBackoff, and the wiring pattern is identical across all three callers, so the risk is low.
    Remediation: Consider adding similar backoff-interval-recording tests for the Harness wait functions, or document why the WaitForWorkflow test provides sufficient coverage for the shared pattern.

Comment thread pkg/behaviourtest/drivers/ci/githubactions/githubactions.go
@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Aug 26, 2026
@waynesun09
waynesun09 added this pull request to the merge queue Aug 27, 2026
Merged via the queue into main with commit 402aa00 Aug 27, 2026
77 of 78 checks passed
@waynesun09
waynesun09 deleted the agent/6668-dispatch-backoff branch August 27, 2026 19:51
@fullsend-ai-retro

fullsend-ai-retro Bot commented Aug 27, 2026

Copy link
Copy Markdown

🤖 Finished Retro · ✅ Success · Started 7:53 PM UTC · Completed 8:05 PM UTC

Commit: 13b6040 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.71

@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #6669ci(#6668): add exponential backoff to dispatch polling

Workflow quality: Strong

This was a clean end-to-end automated workflow — from retro-originated issue through merge — with zero rework. The retro agent identified E2E dispatch polling flakiness on PR #6620 and filed issue #6668 with clear validation criteria. The code agent implemented exponential backoff correctly on the first attempt (+146/-15 across 2 files, 100% patch coverage), and the review agent approved with 2 well-calibrated low-severity findings.

Timeline

Time (UTC) Event Cost
08-26 21:26 Retro agent files #6668
08-26 21:26–21:32 Triage (run): identified related issues, applied ready-to-code $0.96
08-26 21:32–21:44 Code (run): implemented backoff, opened PR #6669 $3.56
08-26 21:45–22:05 Review (run): approved with 2 low findings $6.43
08-27 11:53 Human review (rh-hemartin): approved
08-27 19:51 Merged by waynesun09
Total agent cost $10.95

Observations

Code agent debugging mid-run (positive signal): The code agent hit a test failure during development — a monotonicity assertion broke when the backoff interval (30s cap) transitioned into the completion-wait loop (15s pollInterval). The agent correctly diagnosed the issue and fixed the test to only assert on dispatch-phase intervals. This demonstrates good iterative debugging capability.

Review agent challenger filtering (positive signal): The review sub-agents initially produced 6 findings. The challenger sub-agent filtered 2 as false positives (a naming-consistency finding and a dead-code finding already addressed in the diff) and downgraded 2 to info-level (filtered by severity threshold). The final 2 low findings were both relevant.

Review sub-agent model failures (known issue): 3 of 5 review sub-agents failed because claude-sonnet-4-5@20250929 was unavailable, then retried on opus. This inflated review cost. Already tracked in #6666 (stale sonnet model version mapping inflates review sub-agent costs ~5x) and #1771 (review sub-agents should fall back to an available model).

Duplicate review dispatch (known issue): Two review runs triggered simultaneously on PR open; one was cancelled. This pattern is extensively tracked across #766, #4960, #5139, and the consolidation meta-issue #5817.

Autonomy alignment: The review agent approved and the human approved without comments — review judgment was aligned for this class of change (test infrastructure resilience fix, well-scoped, high test ratio). Relevant tracking in #6210 (criteria for review agent automated approvals).

Proposals

No new proposals. All identified improvement areas are already covered by existing open issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge ready-for-review Triggers review agent dispatch risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add exponential backoff to E2E behaviour test dispatch polling

2 participants