Changesets · Branches · Tags · Compare
| Changeset | b3de9ab5c28c976bf51883f1e1b60810d8cb0d1951f8ed2d7a41ee194f05585f |
|---|---|
| Author | Ting-Wai <40179554+tingwai@users.noreply.github.com> · 2025-09-19 21:56 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-19 21:56 -07:00 |
| Parents | 00059b20c148 |
1 file changed
modified extensions/cli/src/stream/streamChatResponse.ts +25 −0
| @@ -358,6 +358,31 @@ | ||
| 358 | 358 | } |
| 359 | 359 | logger.debug("Starting conversation iteration"); |
| 360 | 360 | |
| 361 | + // Pre-API auto-compaction checkpoint | |
| 362 | + const { wasCompacted: preCompacted, chatHistory: preCompactHistory } = | |
| 363 | + await handleAutoCompaction(chatHistory, model, llmApi, { | |
| 364 | + isHeadless, | |
| 365 | + callbacks: { | |
| 366 | + onSystemMessage: callbacks?.onSystemMessage, | |
| 367 | + onContent: callbacks?.onContent, | |
| 368 | + }, | |
| 369 | + }); | |
| 370 | + | |
| 371 | + if (preCompacted) { | |
| 372 | + logger.debug("Pre-API compaction occurred, updating chat history"); | |
| 373 | + // Update chat history after pre-compaction | |
| 374 | + const chatHistorySvc2 = services.chatHistory; | |
| 375 | + if ( | |
| 376 | + typeof chatHistorySvc2?.isReady === "function" && | |
| 377 | + chatHistorySvc2.isReady() | |
| 378 | + ) { | |
| 379 | + chatHistorySvc2.setHistory(preCompactHistory); | |
| 380 | + chatHistory = chatHistorySvc2.getHistory(); | |
| 381 | + } else { | |
| 382 | + chatHistory = [...preCompactHistory]; | |
| 383 | + } | |
| 384 | + } | |
| 385 | + | |
| 361 | 386 | // Recompute tools on each iteration to handle mode changes during streaming |
| 362 | 387 | const tools = await getAllTools(); |
| 363 | 388 |