Repository navigation
Conversation
OpenCode 2.x answers session/resume and session/new with its ServiceUnavailableError (HTTP 503, "Location plugins did not finish activating") for the first seconds after initialize. Its ACP bridge maps that to "Internal service failure" and keeps only the error name, so codeg saw a generic protocol error. The same request succeeds a moment later. Retry resume, load and new on that specific wording, backing off from 500 ms to 4 s inside one 20 s budget shared by the whole resume -> load -> new chain. A rejected establishment request created nothing, so repeating it is safe; every other failure, including Method not found and Authentication required, stays terminal. Handshake cancellation still stops the wait immediately. Recognize the current ServiceUnavailableError name in both the rendered message and the error data, plus the older "OpenCode service failure" wording. Unit tests cover the classifier, the retry, the deadline, and cancellation.
…n setup The startup-retry classifier also matched "OpenCode service failure" and a bare "service unavailable" phrase. The former is OpenCode 1.x wording, which codeg refuses to launch, and was 1.x's catch-all for permanent failures too (a proxy misrouting its loopback server), so it would stall a doomed handshake for the full 20 s budget; the latter matches any agent's text. OpenCode 2.x reports the plugin-activation 503 as `data.errorName = "ServiceUnavailableError"`, so match that name only. Tests: the OpenCode fixture now has the wire shape (message "Internal service failure", object data), the classifier rejects the 1.x and bare-phrase wordings, and a new test cancels the handshake during the backoff sleep rather than before the first attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…past the budget A session/load that still answers ServiceUnavailableError once the startup budget is spent fell through to the generic session/new fallback. With the retries delaying that fallback, the new session tends to land just after OpenCode finishes activating, binding the reopened conversation to an empty session while the original one is intact. End the handshake with the agent's error instead, as for a Claude Code refusing to start, so a reconnect opens the original session. The handshake budget is shortened under cfg(test) so a handshake test can spend it in real time; the reopen harness gets a configurable quiet gap so the backoff is not mistaken for the end of the handshake. The backoff-cancel test now also asserts the sleep is cut short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verdict: the approach holds. I checked it against the OpenCode v2.3.2 source. Until plugins finish activating, Two problems, fixed on top of the PR:
Also added: a test that cancels during the backoff sleep and asserts the sleep is cut short. The existing cancellation test cancels before the first attempt. Verification: server lib tests and the full desktop With these changes it looks ready to me. The changes were pushed to this pull request (1 file, +162/-29). 🤖 Generated with Codeg |
OpenCode 2.x answers
session/resumeandsession/newwith itsServiceUnavailableError(HTTP 503, "Location plugins did not finish activating") for the first seconds afterinitialize. Its ACP bridge maps that toInternal service failureand keeps only the error name, so codeg surfaced a generic protocol error even though the same request succeeds a moment later.This retries
session/resume,session/loadandsession/newwhen the agent reports that specific startup condition, backing off from 500 ms to 4 s inside one 20 s budget shared by the whole resume → load → new chain. A rejected establishment request created nothing, so repeating it is safe. Every other failure (Method not found, Authentication required, session_busy, …) stays terminal, and handshake cancellation stops the wait immediately.The classifier reads the
ServiceUnavailableErrorname from the rendered message and from the errordata, and also accepts the older "OpenCode service failure" wording.Tests cover the classifier, a retry that succeeds on the third attempt, a non-retryable failure that is attempted once, the deadline bound, and cancellation. Verified with the server-feature test binary (
--no-default-features --features server-bin --bin codeg-server --lib) and withcargo check; clippy on this tree still reports the existing unrelated lints inwork_task/engine.rs,parsers/codex.rs,web/browser_tunnel/mod.rs, andacp/codex_catalog_commit/mod.rs.