From b9f98fcc1951898bf4c26f781a36a65d53e44548 Mon Sep 17 00:00:00 2001 From: Eyejoker Date: Wed, 25 Mar 2026 04:01:48 +0900 Subject: [PATCH] feat: log token count on auto-compact trigger Log pre_tokens and trigger type from compact_boundary message in both main query loop and /compact slash command path. --- runners/agent-runner/src/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runners/agent-runner/src/index.ts b/runners/agent-runner/src/index.ts index a476a76..6cbbcab 100644 --- a/runners/agent-runner/src/index.ts +++ b/runners/agent-runner/src/index.ts @@ -672,6 +672,11 @@ async function runQuery( log(`Session initialized: ${newSessionId}`); } + if (message.type === 'system' && (message as { subtype?: string }).subtype === 'compact_boundary') { + const meta = (message as { compact_metadata?: { trigger?: string; pre_tokens?: number } }).compact_metadata; + log(`Compact boundary — trigger=${meta?.trigger || '?'} pre_tokens=${meta?.pre_tokens ?? '?'}`); + } + if (message.type === 'system' && (message as { subtype?: string }).subtype === 'task_notification') { const tn = message as { task_id: string; status: string; summary: string }; log(`Task notification: task=${tn.task_id} status=${tn.status} summary=${tn.summary}`); @@ -943,7 +948,8 @@ async function main(): Promise { // Observe compact_boundary to confirm compaction completed if (message.type === 'system' && (message as { subtype?: string }).subtype === 'compact_boundary') { compactBoundarySeen = true; - log('Compact boundary observed — compaction completed'); + const meta = (message as { compact_metadata?: { trigger?: string; pre_tokens?: number } }).compact_metadata; + log(`Compact boundary — trigger=${meta?.trigger || '?'} pre_tokens=${meta?.pre_tokens ?? '?'}`); } if (message.type === 'result') {