fix(opencode): transition subagent ToolPart to error state on RunErrorEvent - #93
Closed
Million-mo wants to merge 2 commits into
Closed
fix(opencode): transition subagent ToolPart to error state on RunErrorEvent#93Million-mo wants to merge 2 commits into
Million-mo wants to merge 2 commits into
Conversation
…rEvent When a subagent fails, it emits RunErrorEvent which was silently dropped by EventProcessor.process() - no match arm existed for it. The parent session's ToolPart stayed in ToolStateRunning forever, making the UI show the subagent as perpetually running even after it crashed. Changes: - Add RunErrorEvent handler in _process_subagent_event() that transitions ToolPart from ToolStateRunning to ToolStateError with error message - Emit SessionErrorEvent for child session (matching TS client behavior) - Add is_errored flag to EventProcessorContext to prevent subsequent StreamCompleteEvent from overriding the error state - Add TDD tests: error transition, error without prior spawn, error state terminal (not overridden by late StreamCompleteEvent)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This was referenced Aug 22, 2026
Closed
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
RunErrorEvent), the parent session's ToolPart stays inToolStateRunningforever, making the UI show the subagent as perpetually "running" even after it crashedEventProcessor.process()had no match arm forRunErrorEvent— it was silently dropped. The_process_subagent_event()method only handledStreamCompleteEvent(happy path)RunErrorEventhandler in_process_subagent_event()that transitions ToolPart toToolStateError, emitsSessionErrorEventfor the child session, and prevents subsequentStreamCompleteEventfrom overriding the error stateChanges
event_processor.pyRunErrorEvent+SessionErrorEventimports; add step 8 handler forRunErrorEventin_process_subagent_event(); guardStreamCompleteEventwithis_erroredcheckevent_processor_context.pyis_errored: boolfield to prevent error state overridetest_subagent_error_state.pyTest plan
test_subagent_run_error_transitions_toolpart_to_error— RunErrorEvent transitions ToolPart to ToolStateError with correct error message, emits SessionErrorEventtest_subagent_run_error_without_prior_spawn— RunErrorEvent as first event still creates context and transitions to errortest_subagent_stream_complete_after_run_error_stays_error— Error state is terminal, late StreamCompleteEvent doesn't override