fix(types): distinguish a legitimate None result from never-set in streaming#6534
Open
chuenchen309 wants to merge 1 commit into
Open
fix(types): distinguish a legitimate None result from never-set in streaming#6534chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughStreaming outputs now distinguish an unset result from a completed result set to ChangesStreaming result state
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…reaming
StreamingOutputBase (base for FlowStreamingOutput/CrewStreamingOutput)
initialized self._result to None and treated None as "not set" when
raising RuntimeError("No result available"). This misfires whenever the
actual result legitimately is None -- e.g. a Flow whose final method
returns nothing -- even though streaming completed successfully with no
error.
The sibling StreamSessionBase class in the same file already solves this
correctly with a module-level _MISSING sentinel. Apply the same pattern
to StreamingOutputBase, and fix the one other call site that assumed
None-means-unset (CrewStreamingOutput.results' fallback to self._result).
Added a regression test confirming FlowStreamingOutput.result returns
None (rather than raising) when _set_result(None) was called. Confirmed
it fails against the pre-fix code and passes after. Ran the full
test_streaming.py suite (38 passed), ruff check/format, and mypy (clean).
Disclosure: I used an AI coding assistant (Claude) to help identify this
bug and draft the fix. I independently traced every other read site of
self._result in this file to catch a second place (CrewStreamingOutput
.results) that also assumed None-means-unset and would have silently
broken had I only patched the reported location.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
chuenchen309
force-pushed
the
fix/streaming-result-none-sentinel
branch
from
July 15, 2026 06:19
e460c4a to
345b198
Compare
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.
AI-generated contribution disclosure
I used an AI coding assistant (Claude) to help identify this bug and draft the fix. I reviewed the diff, wrote/verified the regression test in both red and green states, traced every other read site of the affected field to check for related issues, and ran the full local test suite + ruff + mypy before opening this PR. Per CONTRIBUTING.md I understand this should carry the
llm-generatedlabel — as an external contributor I don't have permission to apply labels myself, so flagging it here explicitly; happy for a maintainer to add it.Problem
StreamingOutputBase(the base class behindFlowStreamingOutput/CrewStreamingOutput) initializesself._resulttoNoneand treatsNoneas "no result was ever set":This misfires whenever the actual streamed result legitimately is
None— e.g. aFlowwhose final method has no return value — even though streaming completed successfully with no error.The sibling
StreamSessionBaseclass in the same file already solves exactly this problem correctly, using a module-level_MISSING = object()sentinel instead of comparing toNone.Fix
Apply the same
_MISSINGsentinel pattern toStreamingOutputBase. While tracing every read site ofself._resultin the file to make sure I wasn't missing a related spot, I found one more:CrewStreamingOutput.results' fallback branch (if self._result is not None: return [self._result]) made the same None-means-unset assumption and needed the same fix, or it would have silently broken (returning[_MISSING]) once the default changed.Testing
test_result_can_legitimately_be_nonetoTestFlowStreamingOutputintests/test_streaming.py, confirming.resultreturnsNone(rather than raising) after_set_result(None). Verified it fails against the pre-fix code and passes after.tests/test_streaming.pysuite (38 passed).ruff check/ruff format --checkclean;mypyclean on the changed file.