fix(opencode): recover stuck stop boundaries - #2738
Open
timigod wants to merge 7 commits into
Open
Conversation
timigod
marked this pull request as ready for review
August 1, 2026 09:38
Contributor
|
| Filename | Overview |
|---|---|
| packages/server/src/server/agent/agent-manager.ts | Adds coordinated OpenCode recovery, replacement registration, cancellation admission, bounded cleanup, and lifecycle-race handling. |
| packages/server/src/server/agent/agent-run-state.ts | Extends pending-run tracking to stage startup events and settle admitted turns safely. |
| packages/server/src/server/agent/agent-sdk-types.ts | Adds typed startup rejection, admission, close, resume, and provider-provenance contracts. |
| packages/server/src/server/agent/provider-registry.ts | Preserves typed base-provider provenance when wrapping derived provider sessions. |
| packages/server/src/server/agent/providers/opencode-agent.ts | Classifies stop-boundary failures and fences asynchronous startup against cancellation and autonomous activity. |
| packages/server/src/server/agent/agent-manager.test.ts | Adds broad behavioral coverage for recovery, replacement ownership, cancellation, and shutdown races. |
| packages/server/src/server/agent/providers/opencode-agent.test.ts | Covers OpenCode startup generation fencing, stop-boundary classification, and slash-command discovery races. |
| packages/server/src/server/agent/provider-registry-wrap.test.ts | Verifies wrapped sessions retain their derived identity and typed base-provider provenance. |
| packages/server/src/server/agent/providers/opencode/test-utils/test-opencode-harness.ts | Extends the OpenCode test harness to coordinate and observe asynchronous startup scenarios. |
Sequence Diagram
sequenceDiagram
participant C as Client
participant M as AgentManager
participant O as Old OpenCode session
participant R as Replacement session
C->>M: Submit prompt
M->>O: startTurn(prompt)
O-->>M: previous_turn_still_stopping
M->>R: Resume isolated provider generation
M->>M: Revalidate ownership
M->>M: Atomically register replacement
M->>O: Close old session (bounded)
alt Stop, close, or shutdown before admission
C->>M: Cancel
M->>M: Abort recovery
M-->>C: turn_canceled
else Retry admitted
M->>R: Retry original prompt once
R-->>M: Turn events
M-->>C: Stream turn result
end
Reviews (2): Last reviewed commit: "Merge latest main into OpenCode stop rec..." | Re-trigger Greptile
timigod
marked this pull request as draft
August 1, 2026 13:45
11 tasks
timigod
marked this pull request as ready for review
August 1, 2026 18:56
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.
Summary
Testing
npx vitest run packages/server/src/server/agent/providers/opencode-agent.test.ts --bail=1(92 passed)npx vitest run packages/server/src/server/agent/agent-manager.test.ts --bail=1(165 passed)npx vitest run packages/server/src/server/agent/provider-registry-wrap.test.ts --bail=1(2 passed)npm run build:servernpm run typechecknpm run lintnpm run formatnpm run format:checkgit diff --check