Skip to content

Commit 0d49df4

Browse files
committed
fix: ensure truncation handling applies to mcp servers too
1 parent 36f5ba5 commit 0d49df4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/opencode/src/session/prompt.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { SessionStatus } from "./status"
4444
import { LLM } from "./llm"
4545
import { iife } from "@/util/iife"
4646
import { Shell } from "@/shell/shell"
47+
import { Truncate } from "@/tool/truncation"
4748

4849
// @ts-ignore
4950
globalThis.AI_SDK_LOG_WARNINGS = false
@@ -801,10 +802,17 @@ export namespace SessionPrompt {
801802
}
802803
}
803804

805+
const truncated = await Truncate.output(textParts.join("\n\n"), {}, input.agent)
806+
const metadata = {
807+
...(result.metadata ?? {}),
808+
truncated: truncated.truncated,
809+
...(truncated.truncated && { outputPath: truncated.outputPath }),
810+
}
811+
804812
return {
805813
title: "",
806-
metadata: result.metadata ?? {},
807-
output: textParts.join("\n\n"),
814+
metadata,
815+
output: truncated.content,
808816
attachments,
809817
content: result.content, // directly return content to preserve ordering when outputting to model
810818
}

0 commit comments

Comments
 (0)