Skip to content

fix(state): strip _delegate_from from gateway main sessions (#109073) - #109081

Open
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-109073
Open

kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-109073

Conversation

@kyssta-exe

Copy link
Copy Markdown

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:

  • _insert_session_row: strip _delegate_from when session_key is set (new gateway sessions)
  • _merge_model_config_json: strip _delegate_from after merge when target row has session_key (patches like _usage_anchor persistence)
  • _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.

Closes #109073

…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.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state P2 Medium — degraded but workaround exists labels Sep 13, 2026
@whyyagswhy

Copy link
Copy Markdown

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.

cursor Bot pushed a commit to duhman/hermes-agent that referenced this pull request Sep 25, 2026
…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.
@kyssta-exe

Copy link
Copy Markdown
Author

Closing PR because: PR is not mergeable (has merge conflicts)

@kyssta-exe kyssta-exe closed this Oct 1, 2026
@kyssta-exe kyssta-exe reopened this Oct 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

3 participants