refactor: address Phase-2 review findings on /new boundary handoff

- Return the boundary snapshot from
  _launch_session_boundary_memory_flush as a local value instead of
  staging it on self._session_boundary_snapshot. The instance-attr
  handoff could leak (no memory manager configured) or mis-fire a
  stale snapshot on a later /new if an exception hit between staging
  and consumption. A local variable eliminates the class; the helper
  also returns None when no memory manager is configured so
  new_session takes the inline-switch path.
- Drop the now-dead session_id kwarg from commit_memory_session:
  after the redesign no production caller passes it (gateway, TUI,
  compression all use the default), and speculative params are
  rejected per AGENTS.md. The explicit-old-session need is served by
  cli.py's direct engine call + commit_session_boundary_async.
- Drop the dead providers snapshot in commit_session_boundary_async
  (only the emptiness check used it).
- Tests updated accordingly (dead-kwarg test removed, snapshot
  assertion now covered by return-value contract).

Phase-2 gates: 2a tests/cli 1048 passed + 6 memory files 137 passed;
2b programmatic live smoke 0.38ms non-blocking caller, end→switch→sync
ordering verified; 2c structured 4-angle review — no Criticals, these
warnings fixed.
This commit is contained in:
Kshitij Kapoor 2026-07-09 03:14:56 +05:30 committed by kshitij
parent d8bc4f242f
commit e0ed5dc9ed
5 changed files with 21 additions and 44 deletions

View file

@ -811,8 +811,7 @@ class MemoryManager:
``_submit_background`` degrades to inline execution the pre-#16454
synchronous behavior, slow but correct.
"""
providers = list(self._providers)
if not providers:
if not self._providers:
return
snapshot = list(messages or [])