fix(state): strip _delegate_from from gateway main sessions (#109073) - #109081
kyssta-exe wants to merge 1 commit into
Conversation
…arch#109073) A main gateway session (session_key set, e.g. agent:main:telegram:dm:<user>) must never carry _delegate_from. That marker excludes the row from every picker (list_sessions_rich, list_recent_sessions_bounded, /resume) while the gateway keeps routing into it by session_key, so chat keeps flowing but the conversation vanishes from the desktop sidebar. Historic upsert/merge paths could copy a delegate child's model_config onto the main row, producing the impossible _delegate_from+_reset_from pair on the same row observed in prod. Fix: - _insert_session_row: strip _delegate_from when session_key is set. - _merge_model_config_json: strip _delegate_from after merge when the target row has session_key. - _heal_polluted_gateway_delegate_markers: idempotent startup heal that removes _delegate_from from any existing gateway rows (runs on every open, no version gate). Delegate children (no session_key) keep the marker unchanged.
|
Independent verification on the PR head (a6753ca): I exercised all three mechanisms live against a real SQLite store. Insert with marker plus session_key strips it, merge of the marker onto a gateway row strips it, and reopening a pre-polluted store heals the row while keeping the other config keys. Existing session suites pass, 14/14 across test_session_hidden and test_orphan_gateway_session_repair (canonical runner). Required before merge: tests. The repo bar is invariant tests per fix, and the three cases above are directly writable against a tmp store. Minor: the insert guard's membership test assumes model_config is a dict; a JSON-string caller would take the substring branch into .items() and raise. An isinstance check closes it. |
…arch#109073) A main gateway session (session_key set) must never carry _delegate_from — that marker hides the row from every picker while the gateway keeps routing into it. Salvage of kyssta-exe NousResearch#109081 (strip at insert/merge + startup heal) plus regression tests for insert, merge, child-keep, and heal paths.
|
Closing PR because: PR is not mergeable (has merge conflicts) |
A main gateway session (session_key set, e.g. agent:main:telegram:dm:) must never carry _delegate_from. That marker excludes the row from every picker (list_sessions_rich, list_recent_sessions_bounded, /resume) while the gateway keeps routing into it by session_key, so chat keeps flowing but the conversation vanishes from the desktop sidebar.
Historic upsert/merge paths could copy a delegate child's model_config onto the main row, producing the impossible _delegate_from+_reset_from pair observed in prod (#109073). This is the opposite direction of #103789/PR#105284 (children leaking into sidebar).
Fix:
Delegate children (no session_key) keep the marker unchanged.
Closes #109073