fix(gateway): consume was_auto_reset so /model survives session auto-reset (#48031)#51025
Merged
Merged
Conversation
Contributor
🔎 Lint report:
|
kshitijk4poor
force-pushed
the
salvage/cron-autoreset-override
branch
from
June 24, 2026 13:42
dc51f20 to
fe12d30
Compare
…reset
When `/model X` is the FIRST message after an idle/daily/suspended auto-reset,
the slash-command path stores a session model override but leaves
`session_entry.was_auto_reset = True` (it never passes through
`_handle_message_with_agent`, which is where the flag was consumed). On the
NEXT regular message, the auto-reset cleanup block pops the freshly-stored
model/reasoning override BEFORE the flag is consumed — so the switch is
silently lost and resolution falls back to the config default, while the
session DB still shows the switched model (a two-sources-of-truth divergence).
Consume the flag at both sites:
1. gateway/run.py — capture `was_auto_reset` into a local and set the
attribute False immediately at the top of the cleanup block, so the
cleanup can't re-fire on a later message and wipe an override stored
between turns. Downstream reads use the captured local.
2. gateway/slash_commands.py — the model path consumes the flag before
storing the override, so a /model-first-after-auto-reset isn't wiped by
the next message's cleanup.
Salvaged from #48062 by x7peeps (authorship preserved).
Tests: tests/gateway/test_48031_model_switch_after_auto_reset.py — AST
invariants pinning both consume sites (load-bearing; verified they fail when
either consume is removed). Mirrors the AST-pin approach in
test_35809_auto_reset_clean_context.py. Gateway session/reset suite: 16 passed.
Fixes #48031
kshitijk4poor
force-pushed
the
salvage/cron-autoreset-override
branch
from
June 24, 2026 13:42
fe12d30 to
6879d77
Compare
kshitijk4poor
enabled auto-merge
June 24, 2026 13:45
This was referenced Jun 24, 2026
Closed
Closed
This was referenced Jun 27, 2026
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
liuchanchen
pushed a commit
to liuchanchen/hermes-agent
that referenced
this pull request
Jul 3, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
Methodician
added a commit
to Methodician/hermes-agent
that referenced
this pull request
Jul 4, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
kulikman
pushed a commit
to kulikman/hermes-agent
that referenced
this pull request
Jul 16, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…autoreset-override fix(gateway): consume was_auto_reset so /model survives session auto-reset (NousResearch#48031)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
/model Xis the first message after an idle/daily/suspended auto-reset, the slash-command path stores a session model override but leavessession_entry.was_auto_reset = True(it never passes through_handle_message_with_agent, where the flag was consumed). On the next regular message, the auto-reset cleanup block pops the freshly-stored model/reasoning override before the flag is consumed — so the switch is silently lost and resolution falls back to the config default, while the session DB still shows the switched model (a two-sources-of-truth divergence). (#48031)Fix
Consume
was_auto_resetat both sites:gateway/run.py— capture the flag into a local and set the attributeFalseimmediately at the top of the cleanup block, so the cleanup can't re-fire on a later message and wipe an override stored between turns. Downstream reads use the captured local.gateway/slash_commands.py— the model path consumes the flag before storing the override, so a/model-first-after-auto-reset isn't wiped by the next message's cleanup.Salvage / credit
Salvaged from #48062 by @x7peeps (authorship preserved).
Tests
tests/gateway/test_48031_model_switch_after_auto_reset.py— AST invariants pinning both consume sites (load-bearing: verified they FAIL when either consume is removed). Mirrors the AST-pin approach intest_35809_auto_reset_clean_context.py. Gateway session/reset suite: 16 passed.Closes
Fixes #48031
Review status
The automated review batch timed out on the slow full
tests/gateway/run, so I verified manually with a scoped suite + targeted edge-case checks:was_auto_resetreads in_handle_message_with_agentuse the captured_was_auto_resetlocal (lines 8941, 8977); the only post-consume attribute writes are the False-assignments. No read depends on the flag still being True.~line 9036) is now redundant for the flag but still clearsauto_reset_reason— harmless, not conflicting.session_store.get_or_create_session()returns the same cached entry object for a given key (confirmed ingateway/session.py), so the slash-command path's consume mutates the same object the message handler later reads — the wipe is genuinely prevented.