There was an error while loading. Please reload this page.
1 parent 48eb552 commit b951611Copy full SHA for b951611
1 file changed
packages/agent-core-v2/src/agent/task/persist.ts
@@ -23,7 +23,11 @@ interface Utf8TailPreview {
23
export function utf8TailPreview(data: Uint8Array, maxBytes: number): Utf8TailPreview {
24
const limit = Math.max(0, Math.trunc(maxBytes));
25
let start = Math.max(0, data.byteLength - limit);
26
- while (start < data.byteLength && (data[start]! & 0xc0) === 0x80) start += 1;
+ while (start < data.byteLength) {
27
+ const byte = data[start];
28
+ if (byte === undefined || (byte & 0xc0) !== 0x80) break;
29
+ start += 1;
30
+ }
31
const tail = data.subarray(start);
32
return { text: textDecoder.decode(tail), bytes: tail.byteLength };
33
}
0 commit comments