2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { ResponsePartKind, type ResponsePart, type Turn } from './state/sessionState.js';
7
>
8
>
/**
9
>
* Options for {@link buildConversationContext}.
10
>
*/
11
>
export interface IConversationContextOptions {
12
>
/**
13
>
* Soft upper bound, in characters, for the conversation portion of the
14
>
* produced context string. When the conversation exceeds this budget its
15
>
* middle is removed (marked with `...`) via {@link truncateMiddle}. The
16
>
* optional {@link framing} is always preserved in full and does not count
17
>
* against this budget.
18
>
*/
19
>
readonly maxChars: number;
20
>
21
>
/**
22
>
* Optional framing text prepended to the conversation (e.g. a note that the
23
>
* conversation was branched from an earlier chat). Always preserved in full
24
>
* — only the conversation is truncated to {@link maxChars}.
25
>
*/
26
>
readonly framing?: string;
27
>
}
28
>
29
>
/**
30
>
* Concatenates the normal textual (markdown) response parts of a turn into a
31
>
* single string. Tool calls, reasoning, content references, and other
32
>
* non-markdown parts are intentionally ignored so that only the assistant's
33
>
* user-facing prose is included — this keeps utility-model prompts focused and
34
>
* free of large tool payloads or subagent traces.
35
>
*/
36
>
export function renderResponseMarkdown(parts: readonly ResponsePart[]): string {
37
const segments: string[] = [];
38
for (const part of parts) {