@@ -72,8 +72,8 @@ function convertToVsCodeLmTools(tools: OpenAI.Chat.ChatCompletionTool[]): vscode
7272 * Copilot's backend enforces its own context window and, for third-party `sendRequest` callers,
7373 * trims an over-window request in a way that is NOT tool-pair-aware: it can drop the assistant
7474 * message holding a `tool_use` while keeping the matching `tool_result`, after which Anthropic
75- * rejects the request with "unexpected tool_use_id". To keep trimming on OUR side — where
76- * pairing is preserved — we shrink oversized `tool_result` payloads before sending. Only
75+ * rejects the request with "unexpected tool_use_id". To keep trimming on OUR side — where
76+ * pairing is preserved — we shrink oversized `tool_result` payloads before sending. Only
7777 * `tool_result` text is truncated (never `tool_use`, assistant text, summaries, or environment
7878 * details), and only when the request would otherwise exceed the budget.
7979 */
@@ -85,7 +85,7 @@ function convertToVsCodeLmTools(tools: OpenAI.Chat.ChatCompletionTool[]): vscode
8585 * the tool schemas, image placeholders, or per-message framing the backend adds, so it cannot give
8686 * the true total for the request we are about to send. It is also an async, per-call RPC, and the
8787 * budget is needed for every message on every turn. We therefore keep a character estimate here
88- * and stay deliberately conservative — 3 chars/token rather than the ~4 typical of English —
88+ * and stay deliberately conservative — 3 chars/token rather than the ~4 typical of English —
8989 * because the token-dense JSON, logs, and code that dominate oversized tool results tokenize to
9090 * fewer characters per token than prose. Under-counting biases toward trimming too early, which is
9191 * recoverable; over-counting sends an over-window request, which is not.
@@ -160,7 +160,7 @@ export function middleOutTruncate(text: string, maxChars: number): string {
160160 const headLength = Math . ceil ( keep / 2 )
161161 const tailLength = keep - headLength
162162 let head = text . slice ( 0 , headLength )
163- // Don't end the head on a lone high surrogate — its low half is in the removed middle, and a lone
163+ // Don't end the head on a lone high surrogate — its low half is in the removed middle, and a lone
164164 // surrogate cannot be encoded as UTF-8 (the backend 400s the whole request). Drop the split half.
165165 if ( head . length > 0 && ( head . charCodeAt ( head . length - 1 ) & 0xfc00 ) === 0xd800 ) {
166166 head = head . slice ( 0 , - 1 )
@@ -206,7 +206,7 @@ function estimateContentChars(content: Anthropic.Messages.MessageParam["content"
206206
207207/**
208208 * Shrinks oversized `tool_result` payloads (largest first, middle-out) until the conversation fits
209- * `budgetChars`. Mutates the tool_result blocks of the supplied messages in place — callers pass a
209+ * `budgetChars`. Mutates the tool_result blocks of the supplied messages in place — callers pass a
210210 * cloned array (see `createMessage`) so stored history is never mutated. A no-op when the
211211 * conversation already fits.
212212 */
0 commit comments