Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 47a3d56

Browse files
committed
Only include environment details in summary for automatic condensing
For automatic condensing (during attemptApiRequest), environment details are included in the summary because the API request is already in progress and the next user message won't have fresh environment details injected. For manual condensing (via condenseContext button), environment details are NOT included because fresh details will be injected on the very next turn via getEnvironmentDetails() in recursivelyMakeClineRequests(). This uses the existing isAutomaticTrigger flag to differentiate behavior.
1 parent b1edf1d commit 47a3d56

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/core/condense/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,14 @@ export type SummarizeResponse = {
131131
* - Post-condense, the model sees only the summary (true fresh start)
132132
* - All messages are still stored but tagged with condenseParent
133133
* - <command> blocks from the original task are preserved across condensings
134-
* - <environment_details> is included to provide current workspace context
134+
*
135+
* Environment details handling:
136+
* - For AUTOMATIC condensing (isAutomaticTrigger=true): Environment details are included
137+
* in the summary because the API request is already in progress and the next user
138+
* message won't have fresh environment details injected.
139+
* - For MANUAL condensing (isAutomaticTrigger=false): Environment details are NOT included
140+
* because fresh environment details will be injected on the very next turn via
141+
* getEnvironmentDetails() in recursivelyMakeClineRequests().
135142
*
136143
* @param {ApiMessage[]} messages - The conversation messages
137144
* @param {ApiHandler} apiHandler - The API handler to use for summarization and token counting
@@ -140,7 +147,7 @@ export type SummarizeResponse = {
140147
* @param {boolean} isAutomaticTrigger - Whether the summarization is triggered automatically
141148
* @param {string} customCondensingPrompt - Optional custom prompt to use for condensing
142149
* @param {ApiHandlerCreateMessageMetadata} metadata - Optional metadata to pass to createMessage (tools, taskId, etc.)
143-
* @param {string} environmentDetails - Optional environment details string to include in the summary
150+
* @param {string} environmentDetails - Optional environment details string to include in the summary (only used when isAutomaticTrigger=true)
144151
* @returns {SummarizeResponse} - The result of the summarization operation (see above)
145152
*/
146153
export async function summarizeConversation(
@@ -294,8 +301,10 @@ ${commandBlocks}
294301
})
295302
}
296303

297-
// Add environment details as a separate text block if provided
298-
if (environmentDetails?.trim()) {
304+
// Add environment details as a separate text block if provided AND this is an automatic trigger.
305+
// For manual condensing, fresh environment details will be injected on the next turn.
306+
// For automatic condensing, the API request is already in progress so we need them in the summary.
307+
if (isAutomaticTrigger && environmentDetails?.trim()) {
299308
summaryContent.push({
300309
type: "text",
301310
text: environmentDetails,

0 commit comments

Comments
 (0)