The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: preserve legacy native text admission retries
Tekniumca226b68230f
diff --git a/gateway/session_envelope.py b/gateway/session_envelope.pyindex 5972a74071f..19952dfdd15 100644--- a/gateway/session_envelope.py+++ b/gateway/session_envelope.py@@ -15,8 +15,8 @@ _EVENT_FIELDS = ('user_id', 'user_name', 'message_id', 'platform_update_id','reply_to_message_id', 'reply_to_text', 'reply_to_author_id','reply_to_author_name', 'reply_to_is_own_message', 'allow_gateway_control',- 'auto_skill', 'channel_prompt', 'channel_context', 'media_types', 'media_text_inlined',)+_CONTEXT_FIELDS = ('auto_skill', 'channel_prompt', 'channel_context')def _validate_native(runner, event):@@ -61,9 +61,17 @@ def snapshot_native(runner, event):envelope = {'source': encoded_source,'route': runner.session_store._generate_session_key(event.source),'event': deepcopy({name: getattr(event, name) for name in _EVENT_FIELDS}),- 'timestamp': event.timestamp.isoformat(),- 'message_type': event.message_type.value,- 'media': capture_native_media(event.media_urls)}+ 'timestamp': event.timestamp.isoformat()}+ # Omit new defaults so an identical retry of an older text admission retains+ # its fingerprint. Explicit context (including an empty skill list) is exact.+ envelope['event'].update({name: deepcopy(getattr(event, name)) for name in _CONTEXT_FIELDS+ if getattr(event, name) is not None})+ if event.message_type != MessageType.TEXT:+ envelope['message_type'] = event.message_type.value+ if event.media_urls:+ envelope['media'] = capture_native_media(event.media_urls)+ envelope['event'].update(media_types=list(event.media_types),+ media_text_inlined=list(event.media_text_inlined))# Keep the private dispatch key so previously committed text-only rows recover# under the same authority; optional media/context fields extend that envelope.return {'text': event.text, 'native_text_v1': envelope}diff --git a/tests/gateway/fixtures/native_ingress_media_peer.py b/tests/gateway/fixtures/native_ingress_media_peer.pyindex 02ec0ef7d44..43001b5ce27 100644--- a/tests/gateway/fixtures/native_ingress_media_peer.py+++ b/tests/gateway/fixtures/native_ingress_media_peer.py@@ -142,6 +142,28 @@ async def probe(mode, peer):deliveries=adapter.deliveries, recovery=result, retained=before['retained'], rows=after)))return+ # A committed text row from before media support must keep its retry identity.+ from hermes_state_runtime import admit_session_input, cancel_session_input+ old_event = MessageEvent(text='legacy native input', source=source, message_id='legacy-text')+ ref = authority.register(source)+ encoded_source = source.to_dict()+ encoded_source['is_bot'] = source.is_bot+ legacy = {'text': old_event.text, 'native_text_v1': {+ 'source': encoded_source, 'route': runner.session_store._generate_session_key(source),+ 'timestamp': old_event.timestamp.isoformat(), 'event': {+ key: getattr(old_event, key) for key in (+ 'user_id', 'user_name', 'message_id', 'platform_update_id',+ 'reply_to_message_id', 'reply_to_text', 'reply_to_author_id',+ 'reply_to_author_name', 'reply_to_is_own_message', 'allow_gateway_control')}}}+ principal = 'messaging:' + json.dumps([source.profile, source.platform.value, source.chat_id,+ source.thread_id, source.user_id], separators=(',', ':'))+ old_row = admit_session_input(authority.db, epoch=authority.epoch, principal_id=principal,+ session_id=ref.session_id, request_id=old_event.message_id, payload=legacy)+ cancel_session_input(authority.db, epoch=authority.epoch, admission_id=old_row['admission_id'])+ retried = authority.admit_native(old_event)+ assert retried.admission_id == old_row['admission_id'] and retried.status == 'terminal'+ assert rows(ref.session_id)[0]['payload'] == legacy+# Closed owner context: lists are copied, public source codec never carries trust.event = MessageEvent(text='context', source=source, auto_skill=['first', 'second'],channel_prompt='channel policy', channel_context='backfilled history')