diff --git a/runners/agent-runner/src/index.ts b/runners/agent-runner/src/index.ts index 6f16740..a7e8c32 100644 --- a/runners/agent-runner/src/index.ts +++ b/runners/agent-runner/src/index.ts @@ -551,11 +551,11 @@ async function runQuery( log(`Task notification: task=${tn.task_id} status=${tn.status} summary=${tn.summary}`); } - if ((message as { type: string }).type === 'task_progress') { - const tp = message as { task_id: string; summary?: string }; - const summary = tp.summary || ''; - log(`Subagent progress: task=${tp.task_id} summary=${summary.slice(0, 200)}`); + if (message.type === 'system' && (message as { subtype?: string }).subtype === 'task_progress') { + const tp = message as Record; + const summary = typeof tp.summary === 'string' ? tp.summary : ''; if (summary) { + log(`Subagent progress: ${summary.slice(0, 200)}`); writeOutput({ status: 'success', phase: 'progress', @@ -565,7 +565,7 @@ async function runQuery( } } - if ((message as { type: string }).type === 'task_started') { + if (message.type === 'system' && (message as { subtype?: string }).subtype === 'task_started') { const ts = message as { task_id: string; teammate_name?: string }; log(`Subagent started: task=${ts.task_id} name=${ts.teammate_name || 'unknown'}`); } @@ -644,6 +644,10 @@ async function runQuery( if (message.type === 'assistant') { const stopReason = (message as { stop_reason?: string }).stop_reason; const textResult = extractAssistantText(message); + // Only log when there's something interesting (text or terminal) + if (textResult || stopReason === 'end_turn') { + log(`Assistant: stop=${stopReason} text=${textResult ? textResult.length + ' chars' : 'null'}`); + } if (stopReason === 'end_turn' && textResult) { resultCount++; log( @@ -659,6 +663,16 @@ async function runQuery( stream.end(); break; } + // Intermediate assistant text between tool calls → progress + if (stopReason !== 'end_turn' && textResult) { + log(`Intermediate assistant text (${textResult.length} chars, stop=${stopReason})`); + writeOutput({ + status: 'success', + phase: 'progress', + result: textResult, + newSessionId, + }); + } } } diff --git a/src/agent-runner.ts b/src/agent-runner.ts index 330f97a..c7da5e4 100644 --- a/src/agent-runner.ts +++ b/src/agent-runner.ts @@ -238,7 +238,7 @@ export async function runAgentProcess( const lines = chunk.trim().split('\n'); for (const line of lines) { if (!line) continue; - if (line.includes('Turn in progress')) { + if (line.includes('Turn in progress') || line.includes('Subagent') || line.includes('Intermediate assistant')) { logger.info( { group: group.name, chatJid: input.chatJid, runId: input.runId }, line.replace(/^\[.*?\]\s*/, ''), diff --git a/src/message-turn-controller.ts b/src/message-turn-controller.ts index 863ed68..c6d7f9e 100644 --- a/src/message-turn-controller.ts +++ b/src/message-turn-controller.ts @@ -212,7 +212,10 @@ export class MessageTurnController { if (minutes > 0) elapsedParts.push(`${minutes}분`); elapsedParts.push(`${seconds}초`); - return `${TASK_STATUS_MESSAGE_PREFIX}${text}\n\n${elapsedParts.join(' ')}`; + const suffix = `\n\n${elapsedParts.join(' ')}`; + const maxText = 2000 - TASK_STATUS_MESSAGE_PREFIX.length - suffix.length; + const truncated = text.length > maxText ? text.slice(0, maxText - 1) + '…' : text; + return `${TASK_STATUS_MESSAGE_PREFIX}${truncated}${suffix}`; } private clearProgressTicker(): void {