MCPcopy Index your code
hub / github.com/continuedev/continue / getHistoryForLLM

Function getHistoryForLLM

extensions/cli/src/compaction.ts:222–238  ·  view source on GitHub ↗
(
  fullHistory: ChatHistoryItem[],
  compactionIndex: number | null,
)

Source from the content-addressed store, hash-verified

220}
221
222export function getHistoryForLLM(
223 fullHistory: ChatHistoryItem[],
224 compactionIndex: number | null,
225): ChatHistoryItem[] {
226 if (compactionIndex === null || compactionIndex >= fullHistory.length) {
227 return fullHistory;
228 }
229
230 // Include system message (if at index 0) and everything from compaction index forward
231 const systemMessage =
232 fullHistory[0]?.message?.role === "system" ? fullHistory[0] : null;
233 const messagesFromCompaction = fullHistory.slice(compactionIndex);
234
235 return systemMessage && compactionIndex > 0
236 ? [systemMessage, ...messagesFromCompaction]
237 : messagesFromCompaction;
238}
239
240/**
241 * Parameters for auto-compaction check

Callers 2

compaction.test.tsFile · 0.85
executeStreamingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected