fix: include initial ask in condense summarization to preserve context #8296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #8293 where the initial user message was excluded from the LLM summarization input during condensation, causing the summary to lose the original task context. When resuming after condensation, the system would re-answer the initial ask instead of continuing the in-progress work.
Problem
As identified by @hannesrudolph in #8293:
summarizeConversation()function was slicing out the first message withmessages.slice(1, -N_MESSAGES_TO_KEEP)Solution
1. Core Fix
summarizeConversation()from(1, -N_MESSAGES_TO_KEEP)to(0, -N_MESSAGES_TO_KEEP)to include the first message in summarization input2. Prompt Enhancement
SUMMARY_PROMPTto always capture and preserve the initial user request3. Comprehensive Testing
Testing
npx vitest run core/condense/__tests__/condense.spec.tsnpx vitest run core/sliding-window/__tests__/Impact
Fixes #8293
Review Confidence
Implementation review completed with 95% confidence score. The fix correctly addresses all requirements identified in the issue analysis.
cc @hannesrudolph - Thanks for the detailed analysis! This implements your suggested fix along with the prompt hardening.
Important
Fixes context loss in summarization by including the initial user message in
summarizeConversation()and updating the prompt to preserve initial requests.summarizeConversation()inindex.tsto include the first message in the summarization input by changing slice from(1, -N_MESSAGES_TO_KEEP)to(0, -N_MESSAGES_TO_KEEP).SUMMARY_PROMPTinindex.tsto explicitly instruct capturing the initial user request.condense.spec.tsto verify inclusion of initial ask in summarization input.This description was created by
for 35500b2. You can customize this summary. It will automatically update as commits are pushed.