Skip to content

The agent that grows with you

fix(compress): report the canonical /compress outcome like native /compress

teknium103f987dab841
diff --git a/gateway/session_mutation_compress.py b/gateway/session_mutation_compress.py
index 14da4831b7e..55faef46eef 100644
--- a/gateway/session_mutation_compress.py
+++ b/gateway/session_mutation_compress.py
@@ -67,6 +67,11 @@ async def prepare_compress(authority, live, payload, prepared):
focus_topic=request.focus_topic)
if not any(m.get('_compressed_summary') for m in compressed):
raise RuntimeStoreError('nothing_to_compress')
- return rejoin_compressed_head_and_tail(compressed, tail)
- compressed = await asyncio.to_thread(summarize)
- return dict(prepared, messages=compressed, in_place=is_truthy_value(options.get('in_place'), default=True))
+ return rejoin_compressed_head_and_tail(compressed, tail), compressor
+ compressed, compressor = await asyncio.to_thread(summarize)
+ # The same report every native /compress prints ("Compressed: N → M messages").
+ from agent.manual_compression_feedback import summarize_manual_compression
+ summary = summarize_manual_compression(messages, compressed, estimate_request_tokens_rough(messages),
+ estimate_request_tokens_rough(compressed), compression_state=compressor)
+ return dict(prepared, messages=compressed, summary=summary,
+ in_place=is_truthy_value(options.get('in_place'), default=True))
diff --git a/hermes_state_mutation_compress.py b/hermes_state_mutation_compress.py
index b2657946878..fd5044fcf0c 100644
--- a/hermes_state_mutation_compress.py
+++ b/hermes_state_mutation_compress.py
@@ -23,4 +23,5 @@ def compress_in_transaction(db, conn, session_id, payload, prepared):
conn.execute('UPDATE sessions SET runtime_generation=runtime_generation+1 WHERE id=?', (session_id,))
generation = conn.execute('SELECT runtime_generation FROM sessions WHERE id=?', (session_id,)).fetchone()[0]
return affected, {'target_session_id': child, 'previous_target_session_id': target,
- 'execution_generation': generation, 'message_count': len(prepared['messages'])}
+ 'execution_generation': generation, 'message_count': len(prepared['messages']),
+ 'summary': prepared.get('summary')}
diff --git a/ui-tui/src/app/slash/canonicalSessionControls.ts b/ui-tui/src/app/slash/canonicalSessionControls.ts
index ad3a986d28e..c5fd4afca47 100644
--- a/ui-tui/src/app/slash/canonicalSessionControls.ts
+++ b/ui-tui/src/app/slash/canonicalSessionControls.ts
@@ -190,7 +190,16 @@ export async function runCanonicalSessionControl(
ctx.transcript.setHistoryItems([introMsg(info), ...toTranscriptMessages(snapshot.messages)])
patchUiState({ info })
- ctx.transcript.sys('✓ transcript compressed')
+ // The authority's report (headline, token line, note), as the native /compress prints it.
+ const summary = result.summary as { headline?: string; noop?: boolean; note?: string; token_line?: string } | null
+
+ ctx.transcript.sys(summary?.headline ? `${summary.noop ? '' : '✓ '}${summary.headline}` : '✓ transcript compressed')
+
+ for (const line of [summary?.token_line, summary?.note]) {
+ if (line) {
+ ctx.transcript.sys(` ${line}`)
+ }
+ }
}
} catch (error) {
ctx.guardedErr(error)