The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): a continued Desktop chat from before the upgrade keeps its desktop label
unsupportedpastelsff0118384cf2
diff --git a/gateway/session_a2a.py b/gateway/session_a2a.pyindex a64d48b3d88..32cd10411db 100644--- a/gateway/session_a2a.py+++ b/gateway/session_a2a.py@@ -68,8 +68,11 @@ def storage_source(db, source, session_id, fallback):label = receipt['policy']['source']# An adopted pre-authority row (main's cli/tui/gui history) keeps the label main wrote: its# ``sessions list --source``, ``-c`` and stale-open sweeps key on it, as they did before the upgrade.+ # That is the adopted row's own label, which adoption never rewrites: the policy's creation source+ # folds main's ``desktop`` into ``gui``, so a Desktop chat (a Bot Chat) was re-sourced on its first turn.if 'legacy_session_id' in receipt:- return label+ root = db.get_session(receipt['legacy_session_id'])+ return (root or {}).get('source') or labelreturn fallback if label in {'cli', 'tui', 'gui', 'acp'} else labeldiff --git a/tests/gateway/test_legacy_session_continue_label.py b/tests/gateway/test_legacy_session_continue_label.pynew file mode 100644index 00000000000..a0b732bd8ed--- /dev/null+++ b/tests/gateway/test_legacy_session_continue_label.py@@ -0,0 +1,41 @@+"""Continuing an adopted pre-authority session keeps the label main wrote on its row (T20).++Every turn of a local session refreshes its routing peer (``SessionStore._record_gateway_session_peer``),+which rewrites ``sessions.source`` through ``session_a2a.storage_source``. For an adopted legacy row that+must stay main's own label: ``hermes sessions list --source``, ``-c`` and the stale-open sweeps key on it.+"""+from types import SimpleNamespace++import pytest++[email protected]('label, title', [('cli', 'old cli'), ('tui', 'old tui'), ('desktop', 'Bot Chat'),+ ('gui', 'old gui')])+async def test_a_turn_on_an_adopted_legacy_row_keeps_its_source(tmp_path, monkeypatch, label, title):+ from gateway import run+ from gateway.config import GatewayConfig+ from gateway.session import SessionStore+ from gateway.session_authority import initialize_session_authority+ from gateway.session_contract import Principal+ from gateway.session_local_title import resolve_titled_session++ monkeypatch.setenv('HERMES_HOME', str(tmp_path))+ monkeypatch.setattr(run, '_load_gateway_config', lambda: {'platform_toolsets': {'cli': []}})+ store = SessionStore(tmp_path / 'sessions', GatewayConfig())+ db = store._db+ db.create_session('old', source=label, model='old', cwd=str(tmp_path))+ db.set_session_title('old', title)+ runner = SimpleNamespace(session_store=store, _session_db=db, adapters={}, _draining=False)+ authority = await initialize_session_authority(runner, profile_id=str(tmp_path), instance_id='first')+ native = Principal('native', str(tmp_path), frozenset({'session:read', 'session:create'}), 'socket')+ authority._native_legacy_transports = {native.transport_id: native}+ try:+ ref = resolve_titled_session(authority, native, title)+ assert db.get_session('old')['source'] == label, 'adoption itself keeps the label'+ live = authority.sessions[ref.session_id]+ store._record_gateway_session_peer('old', live.route, live.source) # what every turn does+ row = db.get_session('old')+ assert (row['source'], row['title']) == (label, title)+ finally:+ db.close()