f2a528fb59
Ephemeral empty-response/prefill recovery scaffolding (the synthetic assistant "(empty)" turn, the user nudge, the terminal "(empty)" sentinel, and the thinking-only prefill placeholder) exists only to drive the next API retry; the in-memory loop pops it before appending the real response. The append-only flush did not mirror that, so a mid-turn persist could commit scaffolding to the SQLite session store (and JSON log), and a resumed session would replay synthetic "(empty)"/nudge turns as genuine context — re-poisoning the empty-retry boundary forever. Filter ephemeral scaffolding at both durable-write sites (_flush_messages_to_session_db + _save_session_log), by flag not position, so buried scaffolding (an answered nudge leaves the synthetic pair mid-list) is skipped too. Covers all three flags including _thinking_prefill. Adapted onto current main's identity-tracking flush. Cherry-picked from #41281 by petrichor-op.