Skip to content

Commit dfe6f2d

Browse files
Fix terminal truncation to trim middle of long outputs instead of suffix (#9365)
Co-authored-by: openhands <[email protected]>
1 parent 743c814 commit dfe6f2d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/src/services/observations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export function handleObservationMessage(message: ObservationMessage) {
1313
let { content } = message;
1414

1515
if (content.length > 5000) {
16-
const head = content.slice(0, 5000);
17-
content = `${head}\r\n\n... (truncated ${message.content.length - 5000} characters) ...`;
16+
const halfLength = 2500;
17+
const head = content.slice(0, halfLength);
18+
const tail = content.slice(content.length - halfLength);
19+
content = `${head}\r\n\n... (truncated ${message.content.length - 5000} characters) ...\r\n\n${tail}`;
1820
}
1921

2022
store.dispatch(appendOutput(content));

0 commit comments

Comments
 (0)