Commit cf72fd9
refactor: replace
The sentinel was a no-op placeholder for the error path: setting
`parsed = None` just so `isinstance(parsed, dict)` would skip the
forwarding block on the next line. Using the `try/except/else`
structure expresses the same intent directly — the dict-handling logic
runs only when `json.loads` succeeds — and drops the sentinel
assignment plus the redundant dict check on the JSON-error path.
Behavior preserved: the inner `isinstance(parsed, dict)` still gates
forwarding for valid-but-non-dict JSON (lists, strings, numbers).
Covered by the existing stream tests (`test_agent.py::test_stream_json_*`).
Co-authored-by: Ralphify <noreply@ralphify.co>parsed = None sentinel with try/except/else in _read_agent_stream
1 parent 1751d89 commit cf72fd9
1 file changed
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
| |||
0 commit comments