Fix terminal truncation to trim middle of long outputs instead of suffix (#9365)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Robert Brennan
2025-06-25 19:19:23 -04:00
committed by GitHub
parent 743c814ee8
commit dfe6f2d8cc

View File

@@ -13,8 +13,10 @@ export function handleObservationMessage(message: ObservationMessage) {
let { content } = message;
if (content.length > 5000) {
const head = content.slice(0, 5000);
content = `${head}\r\n\n... (truncated ${message.content.length - 5000} characters) ...`;
const halfLength = 2500;
const head = content.slice(0, halfLength);
const tail = content.slice(content.length - halfLength);
content = `${head}\r\n\n... (truncated ${message.content.length - 5000} characters) ...\r\n\n${tail}`;
}
store.dispatch(appendOutput(content));