From 5b149501537151fd1234e7a0324e847508a5968d Mon Sep 17 00:00:00 2001 From: Contributor Date: Sat, 21 Mar 2026 12:50:14 +0800 Subject: [PATCH] fix(subagent): cap truncated announce text to maxAnnounceChars - Reserve space for truncation marker before slicing findings - Prevents final result from exceeding configured character limit - Addresses Codex review feedback on PR #46863 Before: findings.slice(max) + marker (exceeds max by marker length) After: findings.slice(max - marker.length) + marker (respects max) --- src/agents/subagent-announce.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agents/subagent-announce.ts b/src/agents/subagent-announce.ts index e95e657eb19..fb8ee54a157 100644 --- a/src/agents/subagent-announce.ts +++ b/src/agents/subagent-announce.ts @@ -1398,12 +1398,12 @@ export async function runSubagentAnnounceFlow(params: { }); // Apply maxAnnounceChars truncation if specified + const TRUNCATION_MARKER = "\n\n[truncated — full output in transcript]"; const truncatedFindings = typeof params.maxAnnounceChars === "number" && params.maxAnnounceChars >= 1 && findings.length > params.maxAnnounceChars - ? findings.slice(0, params.maxAnnounceChars) + - "\n\n[truncated — full output in transcript]" + ? findings.slice(0, params.maxAnnounceChars - TRUNCATION_MARKER.length) + TRUNCATION_MARKER : findings; const internalEvents: AgentInternalEvent[] = [