fix: avoid invalid UTF-16 in truncation (#567)

This commit is contained in:
Peter Steinberger
2026-01-09 14:19:25 +01:00
parent fd535a50d3
commit 63f5fa47de
7 changed files with 70 additions and 7 deletions

View File

@@ -49,7 +49,7 @@ import {
import { registerAgentRunContext } from "../infra/agent-events.js";
import { parseTelegramTarget } from "../telegram/targets.js";
import { resolveTelegramToken } from "../telegram/token.js";
import { normalizeE164 } from "../utils.js";
import { normalizeE164, truncateUtf16Safe } from "../utils.js";
import type { CronJob } from "./types.js";
export type RunCronAgentTurnResult = {
@@ -68,7 +68,7 @@ function pickSummaryFromOutput(text: string | undefined) {
const clean = (text ?? "").trim();
if (!clean) return undefined;
const limit = 2000;
return clean.length > limit ? `${clean.slice(0, limit)}` : clean;
return clean.length > limit ? `${truncateUtf16Safe(clean, limit)}` : clean;
}
function pickSummaryFromPayloads(