refactor(session): effectify session processor#19485
Merged
kitlangton merged 12 commits intodevfrom Mar 28, 2026
Merged
Conversation
Pure structural refactor — no Effect yet. Extracts the switch statement into a standalone handleEvent function and the cleanup section into a cleanup function. ProcessorContext object shares mutable state via getters/setters. Zero behavior change (verified by two review agents).
Replace the while(true) + for-await + try/catch pattern with: - Stream.fromAsyncIterable + Stream.runForEachWhile for event consumption - Recursive Effect for retry logic (preserves SessionRetry.delay backoff) - Effect.ensuring for cleanup guarantees - Effect.catch for error classification process() still returns Promise externally (via Effect.runPromise) so callers don't change. Event handling and cleanup logic unchanged.
1950b3e to
8e81a77
Compare
Keep the Effect stream path, retry handling, and compaction integration aligned with the prior processor behavior while adding direct regression coverage for prompt, processor, and compaction flows.
Stop retrying unknown parsed JSON errors and finalize interrupted session parts during processor cleanup so aborted runs leave consistent state.
Preserve aborted assistant state through the exported processor wrapper, make compaction setup interrupt-safe, and add wrapper-level and effect-native regression coverage for retry, compact, and cleanup paths.
Move the processor-specific regression coverage into processor-effect.test.ts, drop the duplicate processor.test.ts harness, and keep the session processor tests on the effect-native test path.
katosun2
pushed a commit
to katosun2/opencode
that referenced
this pull request
Mar 29, 2026
e-n-0
pushed a commit
to e-n-0/opencode
that referenced
this pull request
Mar 29, 2026
loocor
pushed a commit
to loocor/opencode
that referenced
this pull request
Mar 30, 2026
afanty2021
pushed a commit
to afanty2021/opencode
that referenced
this pull request
Mar 30, 2026
This was referenced Apr 1, 2026
balcsida
pushed a commit
to balcsida/opencode
that referenced
this pull request
Apr 8, 2026
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
SessionProcessorinto an Effect service and move event handling, cleanup, and retry orchestration onto direct service dependenciesVerification