Fix NameError: _effective_mode not defined (500 on chat_stream) #935

Merged
sleepy merged 1 commit from fix/effective-mode-undefined into dev 2026-06-04 16:12:26 +02:00
Owner

Root Cause

The long-context agent split stream.py → stream_generator.py but _effective_mode was a closure variable from the outer scope. After the split, it was no longer in scope when stream_with_save() executed at runtime.

Fix

  • Added _effective_mode: str parameter to run_stream() in stream_generator.py
  • Pass _effective_mode=_effective_mode from stream.py where it is computed

Testing

  • 1178 passed, 9 pre-existing failures (unchanged)

Fixes the 500 error on every chat message send.

## Root Cause The long-context agent split `stream.py` → `stream_generator.py` but `_effective_mode` was a closure variable from the outer scope. After the split, it was no longer in scope when `stream_with_save()` executed at runtime. ## Fix - Added `_effective_mode: str` parameter to `run_stream()` in `stream_generator.py` - Pass `_effective_mode=_effective_mode` from `stream.py` where it is computed ## Testing - 1178 passed, 9 pre-existing failures (unchanged) Fixes the 500 error on every chat message send.
The long-context split of stream.py into stream_generator.py left
_effective_mode as a closure variable reference, but it's no longer in
scope. Added it as an explicit parameter to run_stream() and passed it
from stream.py where it's computed.
Sign in to join this conversation.
No description provided.