fix: ensure truncation handling applies to mcp servers too

This commit is contained in:
Aiden Cline
2026-01-19 23:19:21 -06:00
parent 36f5ba52e9
commit 0d49df46ef

View File

@@ -44,6 +44,7 @@ import { SessionStatus } from "./status"
import { LLM } from "./llm"
import { iife } from "@/util/iife"
import { Shell } from "@/shell/shell"
import { Truncate } from "@/tool/truncation"
// @ts-ignore
globalThis.AI_SDK_LOG_WARNINGS = false
@@ -801,10 +802,17 @@ export namespace SessionPrompt {
}
}
const truncated = await Truncate.output(textParts.join("\n\n"), {}, input.agent)
const metadata = {
...(result.metadata ?? {}),
truncated: truncated.truncated,
...(truncated.truncated && { outputPath: truncated.outputPath }),
}
return {
title: "",
metadata: result.metadata ?? {},
output: textParts.join("\n\n"),
metadata,
output: truncated.content,
attachments,
content: result.content, // directly return content to preserve ordering when outputting to model
}