Skip to content

The agent that grows with you

fix(contracts): declare messages_omitted on the canonical resume snapshot

Teknium1b96f079da12
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 8a7e702a17c..55ebb975baf 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -4979,6 +4979,7 @@ export interface CanonicalSnapshot {
session_id: string
stored_session_id: string
messages: TranscriptMessage[]
+ messages_omitted?: boolean | null
display_messages?: TranscriptMessage[] | null
message_count: number
running: boolean
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index de705649271..6b6253d3cb3 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -10323,6 +10323,18 @@
"title": "Messages",
"type": "array"
},
+ "messages_omitted": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Messages Omitted"
+ },
"display_messages": {
"anyOf": [
{
diff --git a/tests/gateway/test_resume_omit_messages.py b/tests/gateway/test_resume_omit_messages.py
index 8c187d817a9..879ce5afbaa 100644
--- a/tests/gateway/test_resume_omit_messages.py
+++ b/tests/gateway/test_resume_omit_messages.py
@@ -107,3 +107,20 @@ async def test_omitted_resume_keeps_an_undone_plan_gone_after_a_rotated_compress
assert full['todo_state'] is None
omitted = await _resume(authority, actor, ref, omit_messages=True)
assert omitted['todo_state'] == full['todo_state']
+
+
+async def test_omitted_resume_reply_passes_the_wire_contract(tmp_path, monkeypatch):
+ """Through ``dispatch``, which checks the reply against ``CanonicalSnapshot`` (strict under tests)."""
+ from gateway.session_controls import AuthorityConnection
+ from gateway import session_local
+ authority, actor, ref, physical = await _local_session(tmp_path, monkeypatch)
+ monkeypatch.setattr(session_local, 'local_session_info', lambda *a: {'desktop_protocol': 'hermes-gateway-v1'})
+ _seed_compacted(authority.db, physical)
+ conn = AuthorityConnection(authority, object(), {'user_id': 'owner'})
+ conn.actor = actor
+ authority.events[actor.transport_id] = object()
+ reply = await conn.dispatch({'jsonrpc': '2.0', 'id': 1, 'method': 'session.resume',
+ 'params': {'session_id': ref.session_id, 'omit_messages': True}})
+ assert 'error' not in reply, reply
+ assert reply['result']['messages'] == [] and reply['result']['messages_omitted'] is True
diff --git a/tui_gateway/contracts/canonical_sessions.py b/tui_gateway/contracts/canonical_sessions.py
index 8ba38f8d295..642364a17f0 100644
--- a/tui_gateway/contracts/canonical_sessions.py
+++ b/tui_gateway/contracts/canonical_sessions.py
@@ -138,6 +138,8 @@ class CanonicalSnapshot(Result):
session_id: str
stored_session_id: str
messages: list[TranscriptMessage]
+ # True when the resume asked ``omit_messages``: ``messages`` is empty and the client pages the transcript.
+ messages_omitted: bool | None = None
# Present only when ``display_projection`` was asked: the rows as main's TUI rendered them.
display_messages: list[TranscriptMessage] | None = None
message_count: int