Uh oh!
There was an error while loading. Please reload this page.
Fix ECONNREFUSED driver_exit failures in Copilot SDK engine by gating on api-proxy listener readiness - #52994
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Triage
Zero-diff WIP PR auto-created by an agent to debug a failed Daily Ambient Context Optimizer run. No files changed yet. Revisit once a diff lands or close if stale.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds provider-listener readiness checks to prevent Copilot SDK startup races.
Changes:
- Probes provider TCP/TLS listeners before SDK requests.
- Adds one-shot
ECONNREFUSEDretry handling. - Adds readiness and retry tests.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/awf_reflect.cjs | Implements listener readiness probing. |
actions/setup/js/awf_reflect.test.cjs | Tests probe behavior and timeouts. |
actions/setup/js/copilot_harness.cjs | Gates SDK startup and handles refused connections. |
actions/setup/js/copilot_harness.test.cjs | Adds detection and retry tests. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Balanced
| // provider died in the narrow window between the probe and the first request — retry | ||
| // once as a fresh run. Later attempts (attempt > 0) fall through to the generic retry | ||
| // handling below instead of taking this one-shot path. | ||
| if (attempt === 0 && isConnectionRefused && maxRetries > 0) { |
| socket.once(readyEvent, () => { | ||
| clear(); | ||
| // Remove the error listener before tearing down the socket: a successful handshake has | ||
| // already settled this probe as ready, and a late/trailing error (e.g. an abrupt RST) | ||
| // must not overwrite lastError or otherwise affect the already-settled result. | ||
| socket.removeAllListeners("error"); | ||
| socket.destroy(); | ||
| settle(true); | ||
| }); | ||
| socket.once("error", err => { | ||
| clear(); | ||
| lastError = getErrorMessage(err); | ||
| socket.destroy(); | ||
| settle(false); | ||
| }); |
| function decideConnectionRefusedRetry(isConnectionRefused, attempt, maxRetries) { | ||
| if (attempt === 0 && isConnectionRefused && maxRetries > 0) { | ||
| return { action: "retry", nextDelayMs: FIRST_CONNECTION_REFUSED_RETRY_DELAY_MS }; | ||
| } | ||
| return { action: "continue" }; |
gh-aw-bot
commented
Aug 16, 2026
@copilot this PR looks ready for a finishing pass. Please:
Run: https://github.com/github/gh-aw/actions/runs/31918518969
|
…or listener, test production helper Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Finishing pass done in 047e2a8:
Branch is up to date with |
gh-aw-bot
commented
Aug 16, 2026
@copilot this PR looks ready for a finishing pass. Please:
Run: https://github.com/github/gh-aw/actions/runs/31921676473
|
Uh oh!
There was an error while loading. Please reload this page.
🎉 This pull request is included in a new release. Release: |
Daily Ambient Context Optimizer (and other docker-sbx + Copilot SDK workflows) failed repeatedly because the harness sent its first chat-completion request to the api-proxy sidecar before its per-provider listener was actually accepting connections, exhausting all retries on
ECONNREFUSEDand ending the run with zero agent turns (driver_exit).Root cause
/reflecthealthy and passes key validation before the per-provider listener (e.g.http://api-proxy:10002) is actually accepting TCP connections.Fix
awf_reflect.cjs: addedwaitForProviderListenerReady(), which probes a real TCP connect (TLS handshake forhttps://baseUrls) against a provider listener with a bounded timeout/retry cadence.copilot_harness.cjs: in SDK multi-provider mode, gates on listener readiness for every unique provider baseUrl before the first request, and classifies a first-attemptECONNREFUSEDas a one-shot short-backoff retry instead of burning the full retry budget on a known-transient race.awf_reflect.test.cjs/copilot_harness.test.cjs, resolving conflicts with unrelated test additions merged since.Run: https://github.com/github/gh-aw/actions/runs/31921676473> Generated by 👨🍳 PR Sous Chef · gpt54 · 3.82 AIC · ⌖ 5.65 AIC · ⊞ 8.7K · ◷