@@ -25,6 +25,7 @@ import { recoverPendingRequests as recoverPendingRequestsInternal } from "@/core
2525import { prepareRuntimeSession } from "@/core/runtime/session-bootstrap" ;
2626import { runOpenRequest } from "@/core/runtime/open-request" ;
2727import { buildMessageOptions } from "@/core/runtime/message-options" ;
28+ import { splitResultMessage } from "@/core/runtime/result-message" ;
2829import type { OpenCodeOptions } from "@/agents" ;
2930
3031type RuntimeDeps = {
@@ -160,19 +161,34 @@ export function createCoreRuntime(deps: RuntimeDeps) {
160161 text : string ;
161162 } ) : Promise < void > {
162163 const { channelId, threadId, statusTs, text } = params ;
163- if ( resolveStatusMessageFormat ( ) === "aggressive" ) {
164- await deps . im . sendMessage ( channelId , threadId , text , true ) ;
164+ const statusFormat = resolveStatusMessageFormat ( ) ;
165+ const finalChunks = splitResultMessage ( text ) ;
166+ const singleChunk = finalChunks [ 0 ] ?? text ;
167+
168+ if ( finalChunks . length > 1 ) {
169+ if ( statusFormat !== "aggressive" ) {
170+ await deps . im . updateMessage ( channelId , statusTs , "Final result posted below in multiple messages." , false ) ;
171+ }
172+
173+ for ( const chunk of finalChunks ) {
174+ await deps . im . sendMessage ( channelId , threadId , chunk , true ) ;
175+ }
176+ return ;
177+ }
178+
179+ if ( statusFormat === "aggressive" ) {
180+ await deps . im . sendMessage ( channelId , threadId , singleChunk , true ) ;
165181 return ;
166182 }
167183
168184 const maxEditableMessageChars = deps . im . maxEditableMessageChars ;
169185 if ( typeof maxEditableMessageChars === "number" && text . length > maxEditableMessageChars ) {
170- await deps . im . updateMessage ( channelId , statusTs , "_Final result posted below._ " , false ) ;
171- await deps . im . sendMessage ( channelId , threadId , text , true ) ;
186+ await deps . im . updateMessage ( channelId , statusTs , "Final result posted below." , false ) ;
187+ await deps . im . sendMessage ( channelId , threadId , singleChunk , true ) ;
172188 return ;
173189 }
174190
175- await deps . im . updateMessage ( channelId , statusTs , text , true ) ;
191+ await deps . im . updateMessage ( channelId , statusTs , singleChunk , true ) ;
176192 }
177193
178194 async function handleUserMessageInternal ( context : CoreMessageContext , text : string ) : Promise < void > {
0 commit comments