The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): publish model switch session info
KoNit-K59e33784fc3f
diff --git a/gateway/session_mutations.py b/gateway/session_mutations.pyindex 210722fdd2a..ceb4c569f9d 100644--- a/gateway/session_mutations.py+++ b/gateway/session_mutations.py@@ -261,9 +261,9 @@ def _project_committed(authority, ref, operation, result):if operation == 'reasoning':# The picked level is the policy's now; a typed /reasoning override must not shadow it.authority.runner._set_session_reasoning_override(authority.sessions[ref.session_id].route, None)- if operation in {'reasoning', 'workspace'}:- # Every viewer repaints its reasoning pill / workspace from the published policy, as main's- # _emit_session_info did after the live change.+ if operation in {'model', 'reasoning', 'workspace'}:+ # Every viewer repaints its model, reasoning pill or workspace from the published policy,+ # as main's _emit_session_info did after the live change.from gateway.session_local import local_session_infoauthority.sessions[ref.session_id].event_stream.publish(ref.session_id, local_session_info(authority, ref), event_type='session.info')diff --git a/tests/gateway/test_session_mutation_model.py b/tests/gateway/test_session_mutation_model.pyindex 05043f3fedc..fa6de40b395 100644--- a/tests/gateway/test_session_mutation_model.py+++ b/tests/gateway/test_session_mutation_model.py@@ -23,6 +23,29 @@ class CatalogModel(Model):self.wfile.write(payload)+def test_model_commit_republishes_session_info(monkeypatch):+ """A canonical picker switch must repaint the intro/header from its committed policy."""+ from types import SimpleNamespace++ from gateway.session_contract import SessionRef+ from gateway.session_mutations import _project_committed+ from gateway import session_local++ published = []+ authority = SimpleNamespace(+ sessions={"session": SimpleNamespace(event_stream=SimpleNamespace(+ publish=lambda sid, payload, *, event_type: published.append((sid, payload, event_type))))},+ runner=SimpleNamespace(_set_session_reasoning_override=lambda *_args: None),+ _schedule=lambda _ref: None,+ )+ monkeypatch.setattr(session_local, "publish_local_policy", lambda *_args: None)+ monkeypatch.setattr(session_local, "local_session_info", lambda *_args: {"model": "switched"})++ _project_committed(authority, SessionRef("profile", "session"), "model", {})++ assert published == [("session", {"model": "switched"}, "session.info")]++@pytest.mark.platforms("linux")def test_model_receipt_changes_next_wire_and_branch_keeps_independent_history(tmp_path):root = Path(__file__).resolve().parents[2]@@ -137,6 +160,7 @@ async def test_input_queued_while_a_model_receipt_commits_still_runs(tmp_path, mreturn 'ok'runner = SimpleNamespace(session_store=store, _session_db=db, adapters={}, _draining=False,_evict_cached_agent=lambda route: None, _handle_message=handle,+ _cached_agent_for=lambda route: None,_resolve_session_agent_runtime=lambda **k: ('frozen', {}))runner._adapter_for_source = lambda source: runner.adapters.get(source.platform)authority = SessionAuthority(runner, profile_id='owned', instance_id='owner', db=db,