fix(opencode): adopt upstream #3617 resume robustness onto fork base#6
Merged
patroza merged 1 commit intoJul 14, 2026
Merged
Conversation
…ork base Ports the OpenCode session-resume hardening from upstream PR pingdotgg#3617 (pingdotgg#3604) onto this fork's directory-aware adapter, rather than cherry-picking (the fork runs ahead on @opencode-ai/sdk 1.17 and passes per-call `directory`, so the upstream diff does not apply cleanly). - Schema-versioned resume cursor (OPENCODE_RESUME_VERSION / parseOpenCodeResume); malformed/foreign cursors are ignored. - isOpenCodeNotFound classifies only structured 404 / NotFoundError signals; a confirmed miss falls back to session.create, while transport/auth/5xx errors propagate instead of masquerading as a new empty session. - cwd change forks the session (session.fork) into the requested directory to preserve history; session.update re-applies runtimeMode permissions on reuse/fork. - Race-cleanup aborts only a session this call created; sendTurn echoes resumeCursor so ProviderService keeps the persisted cursor fresh. - Keeps the fork's per-call `directory` and isOpenCodeMessageAborted. Regression tests cover resume, fork-on-cwd, stale-404 fallback, transient-error propagation, malformed-cursor rejection, and isOpenCodeNotFound classification. tsgo clean; adapter 23/23; full provider + orchestration suites 539 pass; vp check clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
patroza
merged commit Jul 14, 2026
0e5fb26
into
patroza/import-external-sessions
6 of 10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adopts the OpenCode session-resume hardening from upstream pingdotgg/t3code#3617 (fixes the pingdotgg#3604 class of silent context loss) onto this fork's adapter.
Why hand-ported, not cherry-picked
This fork runs ahead of upstream on
@opencode-ai/sdk(1.17 vs the PR's 1.3) and passes a per-calldirectoryto everyclient.session.*call, and it already had an independent, strict resume implementation. The upstream diff does not apply cleanly, so the PR's robustness was ported onto the fork's directory-aware base instead.What changed (
OpenCodeAdapter.ts)OPENCODE_RESUME_VERSION/parseOpenCodeResume; malformed or foreign cursors are ignored (treated as "no resume") instead of throwing.isOpenCodeNotFoundclassifies only structured 404 /NotFoundErrorsignals. A confirmed miss falls back tosession.create; transport / auth / 5xx errors propagate rather than masquerading as a brand-new empty session.session.forkcarries history into the requested directory instead of dropping context.session.updatere-applies the currentruntimeModeruleset on reuse/fork.sendTurnechoesresumeCursorsoProviderServicekeeps the persisted cursor fresh every turn.directoryandisOpenCodeMessageAborted.Tests (
OpenCodeAdapter.test.ts)Regression coverage for: resume (no create), fork-on-cwd, stale-404 fallback-to-create, transient-error propagation, malformed-cursor rejection, and direct
isOpenCodeNotFoundclassification. The two obsolete hard-error-on-directory-mismatch tests were replaced.Validation
tsgo --noEmitcleanOpenCodeAdapter.test.ts23/23; fullsrc/provider+src/orchestrationsuites 539 pass (6 pre-existing skips)vp checkclean🤖 Generated with Claude Code