Why do you think this wrong? This is the default behavior of DISCARD ALL since when 8.3 introduced it.
Docs say DISCARD ALL means:
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
CLOSE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
DISCARD PLANS;
DISCARD SEQUENCES;
DISCARD TEMP;
The "RESET ALL" command is what causes the GUCs to be reset. If you don't wish for them to be reset create a function the does all of the above minus the RESET ALL.