The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: a colliding legacy A2A title no longer refuses every peer forever
Teknium316905303092
diff --git a/gateway/session_a2a.py b/gateway/session_a2a.pyindex e0c6d975f35..c84c3a837c5 100644--- a/gateway/session_a2a.py+++ b/gateway/session_a2a.py@@ -4,11 +4,13 @@ from contextvars import ContextVarfrom dataclasses import asdict, replaceimport hashlibimport json+import loggingfrom pathlib import Pathfrom gateway.session_contract import SessionRef, Submissionfrom hermes_state_runtime import RuntimeStoreError+logger = logging.getLogger(__name__)_forward_identity = ContextVar('a2a_forward_identity', default=None)@@ -81,12 +83,17 @@ async def forward(connection, params):raise RuntimeStoreError('admission_conflict')ref = restore_local_session(authority, sid)else:- # Historical titles discarded peer identity and collapsed context characters.- # Never silently adopt somebody else's history or create a replacement for it.+ # Historical `a2a-{agent}-{slug}` titles discarded peer/tenant identity and collapsed+ # context characters, and those `hermes chat --source a2a` rows stored no origin, so a+ # titled row never proves it belongs to this exact conversation. Never adopt or retitle+ # it (that would hand one peer another's history), and never refuse every peer whose+ # slug collides: start this identity's own canonical session and leave the old row be.from plugins.platforms.a2a.adapter import _safe_context_slug- legacy = authority.db.get_session_by_title(f'a2a-{params["agent"]}-{_safe_context_slug(params["context_id"])}')+ title = f'a2a-{params["agent"]}-{_safe_context_slug(params["context_id"])}'+ legacy = authority.db.get_session_by_title(title)if legacy is not None:- raise RuntimeStoreError('runtime_coordination_required')+ logger.warning('A2A: pre-authority session %s titled %r has no peer identity; '+ 'forwarding into a new session instead of adopting it', legacy['id'], title)token = _forward_identity.set(identity)try:ref = create_local_session(authority, actor, {'source': 'a2a', 'request_id': key})diff --git a/tests/gateway/test_session_a2a.py b/tests/gateway/test_session_a2a.pyindex 575f7e9d5c0..a324e5324b5 100644--- a/tests/gateway/test_session_a2a.py+++ b/tests/gateway/test_session_a2a.py@@ -96,8 +96,12 @@ async def test_forwarding_does_not_merge_lossy_context_or_peer_identity(tmp_pathdb.set_session_title('legacy', 'a2a-dev-old-context')legacy = await conn.dispatch({'id': 3, 'method': 'a2a.forward', 'params': dict(agent='dev', tenant='team', peer='alice', context_id='old/context', input_id='first', text='hello')})- assert legacy['error']['message'] == 'runtime_coordination_required'+ # A colliding pre-authority title is neither adopted nor a permanent refusal: the exact+ # identity gets its own session and the old row keeps its title and history.+ assert 'result' in legacy, legacy+ assert legacy['result']['session_id'] not in {'legacy', *ids}assert db.get_session('legacy')['title'] == 'a2a-dev-old-context'+ assert db.get_messages('legacy') == []denied = AuthorityConnection(authority, SimpleNamespace(write=lambda frame: None),{'user_id': 'reader', 'capabilities': ['session:read']})result = await denied.dispatch({'id': 1, 'method': 'a2a.forward', 'params': dict(