fix(gateway): clear stale pending model note on session reset

This commit is contained in:
johnncenae 2026-04-26 14:16:09 +03:00 committed by Teknium
parent 88a85d30c1
commit 00c6480a05
2 changed files with 8 additions and 0 deletions

View File

@ -5313,6 +5313,8 @@ class GatewayRunner:
# picks up configured defaults instead of previous session switches.
self._session_model_overrides.pop(session_key, None)
self._set_session_reasoning_override(session_key, None)
if hasattr(self, "_pending_model_notes"):
self._pending_model_notes.pop(session_key, None)
# Clear session-scoped dangerous-command approvals and /yolo state.
# /new is a conversation-boundary operation — approval state from the

View File

@ -81,11 +81,13 @@ async def test_new_command_clears_session_model_override():
"api_mode": "openai",
}
runner._session_reasoning_overrides[session_key] = {"enabled": True, "effort": "high"}
runner._pending_model_notes[session_key] = "[Note: switched to gpt-4o.]"
await runner._handle_reset_command(_make_event("/new"))
assert session_key not in runner._session_model_overrides
assert session_key not in runner._session_reasoning_overrides
assert session_key not in runner._pending_model_notes
@pytest.mark.asyncio
@ -126,6 +128,8 @@ async def test_new_command_only_clears_own_session():
}
runner._session_reasoning_overrides[session_key] = {"enabled": True, "effort": "high"}
runner._session_reasoning_overrides[other_key] = {"enabled": True, "effort": "low"}
runner._pending_model_notes[session_key] = "[Note: switched to gpt-4o.]"
runner._pending_model_notes[other_key] = "[Note: switched to claude-sonnet-4-6.]"
await runner._handle_reset_command(_make_event("/new"))
@ -133,3 +137,5 @@ async def test_new_command_only_clears_own_session():
assert other_key in runner._session_model_overrides
assert session_key not in runner._session_reasoning_overrides
assert other_key in runner._session_reasoning_overrides
assert session_key not in runner._pending_model_notes
assert other_key in runner._pending_model_notes