Preserve actionable initialize errors after CLI process exit#702
Open
shuofengzhang wants to merge 1 commit intoanthropics:mainfrom
Open
Preserve actionable initialize errors after CLI process exit#702shuofengzhang wants to merge 1 commit intoanthropics:mainfrom
shuofengzhang wants to merge 1 commit intoanthropics:mainfrom
Conversation
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.
What changed
resultmessages withsubtype="error_during_execution"inQuery._read_messagesand store the CLI-provided error text.ProcessError, propagate the captured CLI error text to pending control requests (such asinitialize) instead of the generic process-exit placeholder.TestInitializeErrorPropagation) that reproduces the failure mode and verifies the propagated exception contains the real CLI error text.Why
error_during_executionresult on the message stream and then exit non-zero.ProcessError("Check stderr output for details") that overwrote pending control requests, so callers waiting oninitialize()lost the actionable root-cause message.Insight / Why this matters
The core issue is a cross-channel ordering bug:
resultmessage (error_during_execution) on the message stream.initialize()is waiting on the control-response channel, not message iteration.ProcessError, and that generic error replaced the pending control result.This is easy to miss because both error signals exist, but only one is observed by initialize callers. Preserving the CLI-emitted execution error keeps diagnostics aligned with actual root cause.
Practical gain / Why this matters
Testing
pytest -q tests/test_query.py -k "initialize_uses_error_during_execution_result_text"pytest -qRisk analysis
ProcessErrorfollows a knownerror_during_executionresult.