Commit e460c4a
fix(types): distinguish a legitimate None result from never-set in streaming
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>1 parent 9d72e26 commit e460c4a
2 files changed
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
345 | | - | |
| 345 | + | |
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | | - | |
557 | | - | |
| 556 | + | |
| 557 | + | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
182 | 194 | | |
183 | 195 | | |
184 | 196 | | |
| |||
0 commit comments